# Ansible 1.2 - conditionals

**URL:** <https://forum.ansible.com/t/ansible-1-2-conditionals/12790>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [May 10, 2013, 1:40pm UTC](https://forum.ansible.com/t/ansible-1-2-conditionals/12790 "2013-05-10T13:40:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [May 10, 2013, 1:40pm UTC](https://forum.ansible.com/t/ansible-1-2-conditionals/12790/1 "2013-05-10T13:40:54Z")

</div>

So, some things.

“when\_foo” and “only\_if” are the way things used to work. There’s the new “when” in 1.2 that is intended to simplify everything. The when\_boolean stuff is something you should not be using in 1.2, because the new keyword is “when”. The old ways were too messy and confusing, so now we have something that evaluates Jinja2 conditionals just like templates have. Note that it’s not raw Python, it’s evaluated by Jinja2, so the ‘any’ function isn’t available (neither is os.path.unlink :))

Thus what you want is basically just:

when: ‘gitservers-pr’ in group\_names or ‘gitservers-st’ in group\_names

However, really, if you think about it, what’s a group selector? “Hosts!”. That already exists in playbooks.

So it is really the intent of Ansible that you never have to write conditionals like this. You should not need to, because you are allowed multiple plays.

Suppose you want to talk to things in group “foo” that are in ‘gitservers-pr’ and ‘gitservers-st’. That’s just like this:

- hosts: gitservers-pr:gitservers-st:&mandatory-other-group

Or if you just wanted to cleanly say “just things in those two groups”, it’s simpler:

- hosts: gitservers-pr:gitservers-st
