Skip to content

Instantly share code, notes, and snippets.

@tgerla
Last active August 29, 2015 14:14
Show Gist options
  • Save tgerla/09859fef4050bef6f071 to your computer and use it in GitHub Desktop.
Save tgerla/09859fef4050bef6f071 to your computer and use it in GitHub Desktop.
---
- hosts: localhost
connection: local
vars:
fake_group_names:
- web
- db
tasks:
- debug: msg="should match"
when: '"web" in fake_group_names or "foo" in fake_group_names'
- debug: msg="should not match"
when: '"foo" in fake_group_names or "bar" in fake_group_names'
Timothys-MacBook-Pro:ansible-test tgerla$ ansible-playbook -i localhost, test-in.yml
PLAY [localhost] **************************************************************
GATHERING FACTS ***************************************************************
ok: [localhost]
TASK: [debug msg="should match"] **********************************************
ok: [localhost] => {
"msg": "should match"
}
TASK: [debug msg="should not match"] ******************************************
skipping: [localhost]
PLAY RECAP ********************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment