Include only_if

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!

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

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.

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.