Skip to content

Instantly share code, notes, and snippets.

@greenbrian
Last active August 15, 2016 20:32
Show Gist options
  • Save greenbrian/cc3fbb8b0cfe0f626989dc733d929862 to your computer and use it in GitHub Desktop.
Save greenbrian/cc3fbb8b0cfe0f626989dc733d929862 to your computer and use it in GitHub Desktop.
ansible conditional notes
---
- name: do stuff only if first member in a group
command: echo "hello"
when: groups.some_group[0] == inventory_hostname
---
- name: do stuff only if RHEL6 or CentOS6
command:
when: ansible_os_family == "RedHat" and ansible_lsb.major_release|int >= 6
# group_names is a magic variable, list of groups that a host is a membeer of
- name: some module
file:
when: "'app1' in group_names"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment