title: Ansible - Using a logical OR to match host groups
body: <p>I am trying to get this to only apply to my dev and hydra servers. I have 2 host files with hosts in them. The dev-all host group is
  <code>
  [dev-all:children]
  dev-group1
  dev-group2
  </code></p>
  
  <p>The hydra group only contains one server but is in a different host file. When I run ansible I use a command like such for hydra group <code>ansible-playbook -i environments/hydra site.yml</code> and for dev groups I use this command <code>ansible-playbook -i environments/dev site.yml</code>.</p>
  
  <p>My question is, how do I get this when condition to apply only to hydra when I call hydra or only to dev-all when I call dev? This would help me avoid adding this group to prod servers in another host file. The dev-all group contains many dev server groups in the dev file and I am basically trying to include all of them from the host file so I made the dev-all:children group to grab them all.</p>
  
  <p>I cant seem to get them to match the when OR condition. Perhaps there is a better way to write the when statement.</p>
  
  <p><code>
  - name: add dev environment sudo user group
    group:  name=dev_sudo state=present gid=8002
    tags:
      - groups
      - sudo-group
    when: (inventory_hostname in groups["dev-all"]) or (inventory_hostname in groups['hydra'])
  </code></p>