# \[ansible 2.2.0\] Blocks and When condiftion

**URL:** <https://forum.ansible.com/t/ansible-2-2-0-blocks-and-when-condiftion/22980>\
**Category:** Ansible Project\
**Created:** [November 8, 2016, 10:24am UTC](https://forum.ansible.com/t/ansible-2-2-0-blocks-and-when-condiftion/22980 "2016-11-08T10:24:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patrick\_Montanari](https://avatars.discourse-cdn.com/v4/letter/p/50afbb/32.png) [@Patrick\_Montanari](https://forum.ansible.com/u/Patrick_Montanari)\
**Post date:** [November 8, 2016, 10:24am UTC](https://forum.ansible.com/t/ansible-2-2-0-blocks-and-when-condiftion/22980/1 "2016-11-08T10:24:48Z")

</div>

Hello,

Since ansible 2.2.0 when using a when condition for a block, inner when are no more evaluated and are executed.

Ex:

- blocks:

- include xxx.yml  
when: condition1

- include: yyy.yml  
when: condition2

when: block\_condition

It is fine with ansible 2.1.0

---

<div class="post-metadata">

**Author:** ![Josh\_Smift1](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@Josh\_Smift1](https://forum.ansible.com/u/Josh_Smift1)\
**Post date:** [November 9, 2016, 2:16pm UTC](https://forum.ansible.com/t/ansible-2-2-0-blocks-and-when-condiftion/22980/2 "2016-11-09T14:16:01Z")

</div>

> 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:

&nbsp;&nbsp;- hosts: localhost  
&nbsp;&nbsp;&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- block:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- include: alpha.yml  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when: checkpoint\_alpha is defined  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- include: bravo.yml  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when: checkpoint\_bravo is defined  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when: checkpoints is defined

alpha.yml:

&nbsp;&nbsp;- debug: msg="checkpoint alpha"

bravo.yml:

&nbsp;&nbsp;- debug: msg="checkpoint bravo"

If I run foo.yml with:

&nbsp;&nbsp;(no extra-vars)  
&nbsp;&nbsp;--extra-vars "checkpoint\_alpha=1"  
&nbsp;&nbsp;--extra-vars "checkpoint\_alpha=1 checkpoints=1"  
&nbsp;&nbsp;--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.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-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.

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [November 9, 2016, 5:41pm UTC](https://forum.ansible.com/t/ansible-2-2-0-blocks-and-when-condiftion/22980/3 "2016-11-09T17:41:40Z")

</div>

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.
