jdauphant / ansible-role-nginx

Ansible role to install and manage nginx configuration
655 stars 302 forks source link

remove a site is not taken in consideration #205

Closed valvin1 closed 6 years ago

valvin1 commented 6 years ago

I'm a newbie on ansible so please forgive me if i've made a mistake somewhere.

I'm using this role with this simple playblook which works well :

---
- hosts: all
  roles:
    - role: jdauphant.nginx
      nginx_http_params:
        - sendfile "on"
        - access_log "/var/log/nginx/access.log"
      nginx_sites:
        foo:
          - listen 8080
          - location / { try_files $uri $uri/ /index.html; }
          - location /images/ { try_files $uri $uri/ /index.html; }
      nginx_configs:
        proxy:
          - proxy_set_header X-Real-IP  $remote_addr
          - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for

then i want to change site configuration like this :

---
- hosts: all
  roles:
    - role: jdauphant.nginx
      nginx_http_params:
        - sendfile "on"
        - access_log "/var/log/nginx/access.log"
      nginx_sites:
        bar:
          - listen 80
          - location / { try_files $uri $uri/ /index.html; }
          - location /images/ { try_files $uri $uri/ /index.html; }
      nginx_configs:
        proxy:
          - proxy_set_header X-Real-IP  $remote_addr
          - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for

when I run my playbook I get an error :

"msg": "Unable to reload service nginx: Job for nginx.service failed because the control process exited with error code.\nSee \"systemctl status nginx.service\" and \"journalctl -xe\" for details.\n"

for and bar sites are setup and if i restart nginx it listens on 80 and 8080. foo site has not been disabled.

Is there a way to clean its configuration to be sure to run only sites we have setup ?

jdauphant commented 6 years ago

nginx_remove_sites: ["foo"] or keep_only_specified

Don't hesitate to read : defaults/main.yml of a role, if you have already read that and you haven't understood it: you make an issue about that

valvin1 commented 6 years ago

thank you for the help and the advice :)