Skip to content

false-negative on check in dry-run mode #906

@SPR0STO

Description

@SPR0STO

Bug Overview

Two validation tasks in the role use ansible.builtin.command with delegate_to: localhost, but lack check_mode: no.

As a result, when running the role in --check mode (dry-run), these tasks are silently skipped, causing register to produce empty results.
This leads to false assertion failures, even though the actual environment (e.g. Jinja2 version and collections) is correctly configured.

Expected Behavior

In dry-run (--check) mode, validation tasks should still execute harmless read-only commands, such as:

  • ansible --version
  • ansible-galaxy collection list

These commands should populate registered variables as expected and allow follow-up assert tasks to evaluate correctly.

Steps to Reproduce the Bug

  1. Set up a valid environment with:
  • A supported version of Jinja2 (e.g. 3.1.6)
  • The community.general collection installed (e.g. via ansible-galaxy collection install)
  1. Run the role with:
ansible-playbook SomePlayBookWithRole.yml --check
  1. Observe failure in either of:
  • Verify Jinja2 version
  • Verify collection 'community.general' is installed
  1. Run again without --check: tasks pass

Environment Details

uname -a
Linux hostname 6.8.0-60-generic #63~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 22 19:00:15 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

ansible --version
ansible [core 2.17.10]
  config file = /home/user/Documents/repository/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/user/.local/bin/ansible
  python version = 3.10.12 (main, May 27 2025, 17:12:29) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.1.6
  libyaml = True

pip show Jinja2
Name: Jinja2
Version: 3.1.6
Summary: A very fast and expressive template engine.
Home-page: 
Author: 
Author-email: 
License: 
Location: /home/user/.local/lib/python3.10/site-packages
Requires: MarkupSafe
Required-by: ansible-core, molecule

ansible-galaxy collection list | grep community.general
community.general                        8.5.0

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions