Comments (10)
Good catch. The tests didn't account for anything other than default.conf
being deleted. The incoming PR should address this bug as well as add a proper test case for a whole directory being cleaned up.
from ansible-role-nginx-config.
@alessfg Yes, I actually just found this. Come here to write about my solution :)
The issue is that the latest release published in Galaxy(which I use for my playbooks) contain 0.3.3 version. These changes you write about are absent at this tag and only present only at main
. So I switched source to git repository for requirements.yml.
from ansible-role-nginx-config.
After git pull, it still does not clean up for me. Only cleans up default.conf. Tried recurse set to true and false.
(item=/etc/nginx/conf.d/default.conf) => {"ansible_loop_var": "item", "changed": false, "item": "/etc/nginx/conf.d/default.conf", "path": "/etc/nginx/conf.d/default.conf", "state": "absent"}
from ansible-role-nginx-config.
After Jinja2 update the clean up still does not work. Shall we reopen this?
from ansible-role-nginx-config.
TASK [nginxinc.nginx_config : Find NGINX config files] ************************************************************************************************************************************************************************************************************************
ok: [testing-snap05.MYDOMAIN.TLD] => (item={'directory': ['/etc/nginx/conf.d'], 'recurse': True}) => {"ansible_loop_var": "item", "changed": false, "examined": 7, "files": [{"atime": 1616759901.1814494, "ctime": 1616759896.8093383, "dev": 64780, "gid": 0, "gr_name": "root", "inode": 652060, "isblk": false, "ischr": false, "isdir": false, "isfifo": false, "isgid": false, "islnk": false, "isreg": true, "issock": false, "isuid": false, "mode": "0644", "mtime": 1616759896.5933328, "nlink": 1, "path": "/etc/nginx/conf.d/testing-snap05.staging.MYDOMAIN.TLD_adhoc.conf", "pw_name": "root", "rgrp": true, "roth": true, "rusr": true, "size": 2, "uid": 0, "wgrp": false, "woth": false, "wusr": true, "xgrp": false, "xoth": false, "xusr": false}, {"atime": 1616777440.7914264, "ctime": 1616777440.3514154, "dev": 64780, "gid": 0, "gr_name": "root", "inode": 652158, "isblk": false, "ischr": false, "isdir": false, "isfifo": false, "isgid": false, "islnk": false, "isreg": true, "issock": false, "isuid": false, "mode": "0644", "mtime": 1616777440.13941, "nlink": 1, "path": "/etc/nginx/conf.d/testing-snap05.staging.MYDOMAIN.TLD.conf", "pw_name": "root", "rgrp": true, "roth": true, "rusr": true, "size": 1255, "uid": 0, "wgrp": false, "woth": false, "wusr": true, "xgrp": false, "xoth": false, "xusr": false}], "item": {"directory": ["/etc/nginx/conf.d"], "recurse": true}, "matched": 2, "msg": ""}
TASK [nginxinc.nginx_config : Remove NGINX config files] **********************************************************************************************************************************************************************************************************************
from ansible-role-nginx-config.
The new tests are passing, so I am not entirely sure that this is a bug in the role. I also tried using the same file name as in your example and it got correctly deleted.
Molecule test
TASK [ansible-role-nginx-config : Find NGINX config files] *********************
ok: [ubuntu-bionic] => (item={'directory': ['/etc/nginx/conf.d'], 'recurse': False})
ok: [centos-7] => (item={'directory': ['/etc/nginx/conf.d'], 'recurse': False})
ok: [debian-buster] => (item={'directory': ['/etc/nginx/conf.d'], 'recurse': False})
ok: [alpine-3.10] => (item={'directory': ['/etc/nginx/conf.d'], 'recurse': False})
TASK [ansible-role-nginx-config : Remove NGINX config files] *******************
changed: [centos-7] => (item=/etc/nginx/conf.d/default.conf)
changed: [debian-buster] => (item=/etc/nginx/conf.d/default.conf)
changed: [alpine-3.10] => (item=/etc/nginx/conf.d/default.conf)
changed: [ubuntu-bionic] => (item=/etc/nginx/conf.d/default.conf)
changed: [centos-7] => (item=/etc/nginx/conf.d/mock.conf)
changed: [debian-buster] => (item=/etc/nginx/conf.d/mock.conf)
changed: [alpine-3.10] => (item=/etc/nginx/conf.d/mock.conf)
changed: [ubuntu-bionic] => (item=/etc/nginx/conf.d/mock.conf)
changed: [centos-7] => (item=/etc/nginx/conf.d/testing-snap05.staging.MYDOMAIN.TLD.conf)
changed: [ubuntu-bionic] => (item=/etc/nginx/conf.d/testing-snap05.staging.MYDOMAIN.TLD.conf)
changed: [debian-buster] => (item=/etc/nginx/conf.d/testing-snap05.staging.MYDOMAIN.TLD.conf)
changed: [alpine-3.10] => (item=/etc/nginx/conf.d/testing-snap05.staging.MYDOMAIN.TLD.conf)
ok: [centos-7] => (item=/etc/nginx/conf.d/default.conf)
ok: [ubuntu-bionic] => (item=/etc/nginx/conf.d/default.conf)
ok: [debian-buster] => (item=/etc/nginx/conf.d/default.conf)
ok: [alpine-3.10] => (item=/etc/nginx/conf.d/default.conf)
Have you tried updating to the latest Ansible release? The modules used behind the scenes might have been updated since Ansible 2.9.6
. (The absolute minimum Ansible release you should be using these days is 2.9.10
due to its native support of Ansible collections.)
from ansible-role-nginx-config.
I have Ansible 2.9.6 which is the latest available for latest Ubuntu LTS, which is Ubuntu 20.04.
from ansible-role-nginx-config.
You can install the latest release using pip
or Ansible's package repository https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-ansible-on-ubuntu. Otherwise you are stuck with the latest release available on Ubuntu's package repository, which is usually not ideal.
from ansible-role-nginx-config.
Got this error on mine too. Latest available ansible from brew
:
> ansible --version
ansible [core 2.11.3]
with debug
register: nginx_config_files
- debug:
msg: "{{ nginx_config_files.files }}"
- name: Remove NGINX config files
I'm getting
TASK [nginxinc.nginx_config : Find NGINX config files] *********************************************************************************
ok: [ansible-test] => (item={'directory': ['/etc/nginx/conf.d', '/etc/nginx/snippets'], 'recurse': True})
TASK [nginxinc.nginx_config : debug] ***************************************************************************************************
fatal: [ansible-test]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'files'\n\nThe error appears to be in '...../roles/nginxinc.nginx_config/tasks/config/cleanup-config.yml': line 11, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- debug:\n ^ here\n"}
from ansible-role-nginx-config.
Like I mentioned in an earlier comments, there are explicit tests for this use case now, and they are all passing (https://github.com/nginxinc/ansible-role-nginx-config/blob/main/molecule/cleanup_module/converge.yml). There might be some edge cases that still cause the role to fail, but I'd need more details to be able to reproduce it myself. From what I can tell given your task output, the issue might be that the recurse
keyword belongs in each directory dictionary item, not outside those items (check the Molecule test I linked earlier for more details).
P.S.: nginx_config_files.files
is not used (https://github.com/nginxinc/ansible-role-nginx-config/blob/main/tasks/config/cleanup-config.yml#L11-L17) 😄
from ansible-role-nginx-config.
Related Issues (20)
- How to omit load_module: modules/ngx_http_js_module.so HOT 3
- mime.types not included in default nginx configuration HOT 4
- Add `include` support in default.conf.j2 template HOT 1
- Templating error HOT 2
- "mappings" from the "map" directive are not applied to a resulting configuration HOT 2
- Role should restart/reload Nginx when SSL certificates change HOT 3
- How to set "global" variables in the HTTP context HOT 5
- Allow nginx.conf.j2 to create gzip settings HOT 2
- Nested location HOT 2
- Question - nginx-config and proxy rewrite HOT 4
- Question - QUIC config HOT 5
- Enforcing numeric types breaks certain templating patterns. HOT 3
- http2 directive uses enable but http3 uses enabled
- Variables for gzip_static HOT 1
- Logrotate does not format correctly HOT 2
- add map inside stream HOT 3
- Validate configuration HOT 3
- Role version 0.7.1 is not published to the ansible-galaxy repo HOT 1
- set_real_ip_from (ngx_http_realip_module) should be a list HOT 1
- Listen directive in servers['core'] not workign properly HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansible-role-nginx-config.