# New in latest git -- Being able to reuse conditionals in playbooks

**URL:** <https://forum.ansible.com/t/new-in-latest-git-being-able-to-reuse-conditionals-in-playbooks/11363>\
**Category:** Ansible Project\
**Created:** [March 22, 2012, 12:26am UTC](https://forum.ansible.com/t/new-in-latest-git-being-able-to-reuse-conditionals-in-playbooks/11363 "2012-03-22T00:26:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [March 22, 2012, 12:26am UTC](https://forum.ansible.com/t/new-in-latest-git-being-able-to-reuse-conditionals-in-playbooks/11363/1 "2012-03-22T00:26:00Z")

</div>

New syntax upgrade in latest git – I’ve made it possible to reuse conditionals (only\_if) by declaring them in the vars (or vars\_files) section. Here is an example:

[https://github.com/ansible/ansible/blob/master/examples/playbooks/playbook4.yml](https://github.com/ansible/ansible/blob/master/examples/playbooks/playbook4.yml)

You can put them in vars, but you can also use ‘vars\_files’ (as mentioned elsewhere in the docs/examples).

For instance, you could define all of your conditionals in:

vars\_files:

- ‘vars/common.yml’

And easily reuse them between playbooks. (i.e. you can define “is\_centos” or “is\_virtualized” once and only once)

I’ll update the docs to reflect this new capability shortly.

I think this does a lot to improving the syntax of “only\_if”, and should help prove that we can keep the task list short without  
having to nest it… which in the end means really simple to read playbooks.

–Michael
