Hello,
Since ansible 2.2.0 when using a when condition for a block, inner when are no more evaluated and are executed.
Ex:
when: block_condition
It is fine with ansible 2.1.0
Since ansible 2.2.0 when using a when condition for a block, inner
when are no more evaluated and are executed.
Hmm, I can't reproduce this. In your example playbook, you say "blocks"
rather than "block", but that gives an immediate syntax error.
Here's how I tried to reproduce it. foo.yml:
- hosts: localhost
tasks:
- block:
- include: alpha.yml
when: checkpoint_alpha is defined
- include: bravo.yml
when: checkpoint_bravo is defined
when: checkpoints is defined
alpha.yml:
- debug: msg="checkpoint alpha"
bravo.yml:
- debug: msg="checkpoint bravo"
If I run foo.yml with:
(no extra-vars)
--extra-vars "checkpoint_alpha=1"
--extra-vars "checkpoint_alpha=1 checkpoints=1"
--extra-vars "checkpoint_alpha=1 checkpoint_bravo=1 checkpoints=1"
The first two don't print any debug messages; the third prints the alpha
debug message but not the bravo on; the fourth prints both debug messages.
Same behavior in 2.1.1.0-1 and 2.2.0.0-1.
-Josh (jbs@care.com)
(apologies for the automatic corporate disclaimer that follows)
This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.
There are a few issues open on this on Github, currently digging into it to figure out why. It appears to be a more long-standing bug than 2.2, as forcing includes to be dynamic in 2.1 shows the same bug in most cases.