377bc31311
As documented in #2623, early variable substitution causes when_
tests to fail and possibly other side effects.
I can see the reason for this early substitution, likely introduced
in 1dfe60a6
, to allow many playbook parameters to be templated.
This is a valid goal, but the recursive nature of the utils.template
function means that it goes too far.
At this point removing tasks from the list of parameters to be
substituted seems sufficient to make my tests pass. It may be the
case that other parameters should be excluded, but I suspect not.
Adding a test case. I would prefer to analyse not just the aggregate
statistics but also whether the results are as expected - I can't
see an easy way to do that with the available callbacks at present.
27 lines
486 B
YAML
27 lines
486 B
YAML
---
|
|
- hosts: all
|
|
connection: local
|
|
gather_facts: False
|
|
|
|
vars:
|
|
internal: "print me"
|
|
|
|
tasks:
|
|
- action: debug msg="skip me"
|
|
when_unset: $internal
|
|
|
|
- action: debug msg="$internal"
|
|
when_set: $internal
|
|
|
|
- action: debug msg="skip me"
|
|
when_unset: $external
|
|
|
|
- action: debug msg="$external"
|
|
when_set: $external
|
|
|
|
- action: debug msg="run me"
|
|
when_unset: $this_var_does_not_exist
|
|
|
|
- action: debug msg="skip me"
|
|
when_set: $this_var_does_not_exist
|
|
|