Skip to content

Check mode is broken by ansible version validation #840

Closed
@Al-thi

Description

@Al-thi

Caution

Remember to redact any sensitive information such as authentication credentials or license keys.

Describe the bug

TASK [nginxinc.nginx : Verify that you are using a supported Jinja2 version on your Ansible host] **********************************************************************************************************************************
fatal: [test.rtone.fr -> localhost]: FAILED! => {"msg": "Unexpected templating type error occurred on (Jinja2 {{ jinja2_version['stdout'] | regex_search('jinja version = ([\\\\d.]+)', '\\\\1') | first }} is supported.): 'NoneType' object is not iterable. 'NoneType' object is not iterable"}

To reproduce

Steps to reproduce the bug:

Just run a playbook including nginxinc.nginx in check mode (ansible-playbook -C my-playbook.yml)

Expected behavior

Check mode finishes without crashing and show the expected diff to be deployed on the remote target.

Your environment

  • Version of the Ansible NGINX role (or specific commit): 0.25.0
ansible [core 2.18.1]
  config file = /home/[USER]/code/[REPO]/ansible.cfg
  configured module search path = ['/home/[USER]/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.12/site-packages/ansible
  ansible collection location = /home/[USER]/code/[REPO]/external/collections
  executable location = /usr/bin/ansible
  python version = 3.12.7 (main, Oct  1 2024, 11:15:50) [GCC 14.2.1 20240910] (/usr/bin/python)
  jinja version = 3.1.4
  libyaml = True

Additional context (optional)

I know my version is not supported, but it seems there is a bug here:

I would rewrite this as follow to perform the command tasks even in check mode:

 - name: Extract the version of Jinja2 installed on your Ansible host
   ansible.builtin.command: ansible --version
   register: jinja2_version
   changed_when: false
   delegate_to: localhost
   become: false
+  check_mode: false
 - name: Extract the list of Ansible collections installed on your Ansible host
   ansible.builtin.command: ansible-galaxy collection list
   register: collection_list
   changed_when: false
   delegate_to: localhost
   become: false
+  check_mode: false

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions