Last active
August 15, 2016 20:32
-
-
Save greenbrian/cc3fbb8b0cfe0f626989dc733d929862 to your computer and use it in GitHub Desktop.
ansible conditional notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: do stuff only if first member in a group | |
command: echo "hello" | |
when: groups.some_group[0] == inventory_hostname |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: do stuff only if RHEL6 or CentOS6 | |
command: | |
when: ansible_os_family == "RedHat" and ansible_lsb.major_release|int >= 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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