Git Product home page Git Product logo

Comments (10)

alessfg avatar alessfg commented on August 18, 2024 1

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.

rhombl4 avatar rhombl4 commented on August 18, 2024 1

@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.

ghomem avatar ghomem commented on August 18, 2024

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.

ghomem avatar ghomem commented on August 18, 2024

After Jinja2 update the clean up still does not work. Shall we reopen this?

from ansible-role-nginx-config.

ghomem avatar ghomem commented on August 18, 2024
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.

alessfg avatar alessfg commented on August 18, 2024

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.

ghomem avatar ghomem commented on August 18, 2024

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.

alessfg avatar alessfg commented on August 18, 2024

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.

rhombl4 avatar rhombl4 commented on August 18, 2024

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.

alessfg avatar alessfg commented on August 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.