Can check mode be trusted when a playbook mixes core and third-party Ansible modules?
0 reputation · 21 Apr 2024, 09:28 UTC
I want to validate an Ansible playbook against a staging inventory before any real run, using ansible-playbook --check --diff so nothing is actually modified. The playbook mixes core modules (template, service, package) with a few third-party collection modules that manage an external API.
My understanding is that each module decides whether it honors check mode via its supports_check_mode declaration, and modules that do not support it are skipped rather than executed. That raises a concern: a skipped task means later tasks using when conditionals or registered variables from that task may fail or evaluate differently than they would in a real run, making the simulation misleading.
Assume Ansible core 2.15+ with collections installed from Ansible Galaxy.
- Is there a reliable way to identify which modules in a playbook will be skipped under
--checkbefore running it? - How should tasks that register variables from check-mode-skipped modules be structured so downstream
whenconditions still evaluate predictably? - Does
--checkcombined with--diffstill report accurate pending changes when earlier tasks in the play were skipped?