# Include only\_if

**URL:** <https://forum.ansible.com/t/include-only-if/14515>\
**Category:** Ansible Project\
**Created:** [February 6, 2014, 10:33pm UTC](https://forum.ansible.com/t/include-only-if/14515 "2014-02-06T22:33:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![phillip.corchary](https://avatars.discourse-cdn.com/v4/letter/p/eada6e/32.png) [@phillip.corchary](https://forum.ansible.com/u/phillip.corchary)\
**Post date:** [February 6, 2014, 10:33pm UTC](https://forum.ansible.com/t/include-only-if/14515/1 "2014-02-06T22:33:07Z")

</div>

Hello all - This question is for Ansible 1.2 only (required).

Can I do an include with only\_if: is\_set(${some\_var})?

The idea is that if a top-level var is set then the playbook will be included and executed, and otherwise excluded. Any other way to accomplish the same thing?

Or a template for how to install or upgrade some component only if it is missing or the installed version is older (and the only way to check is --version for the component)?

Also as an aside, I see in the docs that “when” is the new syntax … what version was that introduced and will only\_if continue to work after Ansbile 1.2?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [February 7, 2014, 3:28am UTC](https://forum.ansible.com/t/include-only-if/14515/2 "2014-02-07T03:28:30Z")

</div>

includes are not conditional, if anything the only\_if will be applied to all the tasks included.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [February 9, 2014, 9:15pm UTC](https://forum.ansible.com/t/include-only-if/14515/3 "2014-02-09T21:15:51Z")

</div>

Ansible 1.2 is several releases old and all of this syntax is no longer applicable.

You should upgrade to 1.4.4 as soon as possible as many bugfixes and updates are included.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [February 9, 2014, 9:16pm UTC](https://forum.ansible.com/t/include-only-if/14515/4 "2014-02-09T21:16:36Z")

</div>

Also, only\_if has been removed.

It was an absolutely terrible user experience and we are all glad it is gone.

With the advent of “when”, conditionals are as we would like them to be, so no further changes are intended.
