Skip to content

Instantly share code, notes, and snippets.

@cocoy
Created December 5, 2012 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cocoy/4214018 to your computer and use it in GitHub Desktop.
Save cocoy/4214018 to your computer and use it in GitHub Desktop.
ansible group_by example using register
- 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