# Conditional and include

**URL:** <https://forum.ansible.com/t/conditional-and-include/16828>\
**Category:** Ansible Project\
**Created:** [November 19, 2014, 5:39pm UTC](https://forum.ansible.com/t/conditional-and-include/16828 "2014-11-19T17:39:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Oliver](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@John\_Oliver](https://forum.ansible.com/u/John_Oliver)\
**Post date:** [November 19, 2014, 5:39pm UTC](https://forum.ansible.com/t/conditional-and-include/16828/1 "2014-11-19T17:39:52Z")

</div>

My playbook:

- name: Get Java version  
shell: /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -version 2\>&1 | grep ‘^java’ | cut -d’"’ -f2  
register: jre\_ver

- debug: msg=“{{ jre\_ver.stdout }}”

- name: Install JRE 8 if necessary  
include: jre8.yml  
when: jre\_ver.stdout != ‘1.8.0\_25’  
ignore\_errors: true

Result:

GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [eisbock]

TASK: [Get Java version] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [eisbock]

TASK: [debug msg=“{{ jre\_ver.stdout }}”] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [eisbock] =\> {  
“msg”: “1.8.0\_25”  
}

TASK: [Copy JRE 8 installer] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: [eisbock]

TASK: [Mount disk image] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: [eisbock]

TASK: [Dismount installer] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: [eisbock]

TASK: [Clean up dmg] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: [eisbock]

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
eisbock : ok=3 changed=1 unreachable=0 failed=0

Why is ansible still including jre8.yml and skipping each step? I thought it would just not even tough it if the conditional didn’t match.

---

<div class="post-metadata">

**Author:** ![Michael\_Peters](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@Michael\_Peters](https://forum.ansible.com/u/Michael_Peters)\
**Post date:** [November 19, 2014, 5:50pm UTC](https://forum.ansible.com/t/conditional-and-include/16828/2 "2014-11-19T17:50:48Z")

</div>

When you put a conditional on an include ansible adds that conditional  
to each task in the include. So this is the expected behavior.
