Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Allow for no default config to be generated #234

Open
BenBE opened this issue Nov 14, 2018 · 3 comments
Open

Allow for no default config to be generated #234

BenBE opened this issue Nov 14, 2018 · 3 comments

Comments

@BenBE
Copy link

BenBE commented Nov 14, 2018

The created (and activate) default site (cf. defaults/main.yml) causes interference with configurations where the default host should be configured using a template (either cause a warning about duplicate sites or need to unconfigure things coming from the defaults). Would be nice if there was a simple way to suppress creation of the default site in cases I really want just a bare nginx with only the settings visible in my playbook.

Sample:

    - role: service.nginx
      nginx_sites:
        foo:
          template: foo.conf.j2
          server_name: foo.example.org

Expected behaviour:
Produces only one site (enabled) named foo.

Actual behaviour:
Produces two sites (enabled) called default and foo.

Workaround:

    - role: service.nginx
      keep_only_specified: true
      nginx_remove_sites:
        - default
      nginx_disabled_sites:
        - default
      nginx_sites:
        foo:
          template: foo.conf.j2
          server_name: foo.example.org

NB: Only removing default, without disabling it causes a templating error.

Alternatively /causing a warning on execution) you could override default:

    - role: service.nginx
      nginx_sites:
        default:
          template: foo.conf.j2
          server_name: foo.example.org

Possible desired config:

    - role: service.nginx
      suppress_default_site: true
      nginx_sites:
        foo:
          template: foo.conf.j2
          server_name: foo.example.org
@jdauphant
Copy link
Owner

Thanks for the report.

It's an unexpected behavior.
Normally, default should be removed and if you replace "nginx_sites", no new default should be added.
https://github.com/jdauphant/ansible-role-nginx/blob/a6aa5ed94a05ba84ec48a1e20bf203eafcbffe5a/tasks/remove-defaults.yml
Can you name what files are in your filesystem after the role launch, is it sites-enabled/default.conf or sites-enabled/default ?

@BenBE
Copy link
Author

BenBE commented Nov 16, 2018

The file is sites-enabled/default.conf

Locally using commit 6863343

Further note: Running FreeBSD on that host; using the role to configure inside a cbsd jail.

Running with ansible 2.5.1 on Ubuntu; in case this matters.

@jdauphant
Copy link
Owner

Ok the file should not exist if it's not defined by you.
What's the content ?
It's what specify here : https://github.com/jdauphant/ansible-role-nginx/blob/master/defaults/main.yml#L49 or another things ?
Do you have "nginx_keep_only_specified" at False (default) or True ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants