Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
cceb99ac
Commit
cceb99ac
authored
Oct 30, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify the group_by example a small bit
parent
0853ece8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
13 deletions
+25
-13
examples/playbooks/group_by.yml
+25
-13
No files found.
examples/playbooks/group_by.yml
View file @
cceb99ac
---
# Example playbook to demonstrate the group_by action plugin.
#
# as we know, the setup module will automatically run in each play, and sets up various
# facts. We can then create temporary (in memory only) groups based on those facts, which
# are useful ways of selecting similar sets of hosts.
#
# Additionally, we can use the 'register' keyword in Ansible to set similar variables
# and use those for grouping. This is not shown in this example.
-
hosts
:
all
# This runs the setup module to gather facts
tasks
:
# Use the ansible_machine variable to create a group for every value,
# prefix the group name with 'ansible-'
-
action
:
group_by key=ansible-${ansible_machine}
-
hosts
:
ansible-x86_64
tasks
:
# Run ping on all x86_64 machines
-
action
:
ping
-
hosts
:
all
-
name
:
Create a group of all hosts by operating system
action
:
group_by key=${ansible_distribution}-${ansible_distribution_version}
# the following host group does not exist in inventory and was created by the group_by
# module.
-
hosts
:
CentOS-6.2
tasks
:
# Create a group of all kvm hosts
-
action
:
group_by key=${ansible_virtualization_type}-${ansible_virtualization_role}
-
hosts
:
kvm-host
-
name
:
ping all CentOS 6.2 hosts
action
:
ping
-
hosts
:
CentOS-6.3
tasks
:
-
action
:
ping
-
name
:
ping all CentOS 6.3 hosts
action
:
ping
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment