Created
December 5, 2012 09:00
-
-
Save cocoy/4214018 to your computer and use it in GitHub Desktop.
ansible group_by example using register
This file contains hidden or 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
- hosts: all | |
tasks: | |
#- name: Create a group of all hosts by operating system | |
# action: group_by key=${ansible_distribution}-${ansible_distribution_version} | |
#- name: Create a group of all hosts by operating system | |
# action: group_by key=${ansible_distribution}-${ansible_distribution_version} | |
- name: register this a lucid | |
action: shell lsb_release -sc | |
register: codename | |
- name: Create a group of all hosts by operating system | |
action: group_by key=${codename.stdout} | |
# the following host group does not exist in inventory and was created by the group_by | |
# module. | |
#- hosts: Ubuntu-10.04 | |
# | |
# tasks: | |
# | |
# - name: ping all CentOS 6.2 hosts | |
# action: ping | |
- hosts: lucid | |
tasks: | |
- name: ping lucid hosts | |
action: ping |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment