mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-06-29 07:29:13 +00:00
Add a group_by action plugin.
This commit is contained in:
parent
ea8cb0b2e9
commit
b336d40101
3 changed files with 117 additions and 0 deletions
23
examples/playbooks/group_by.yml
Normal file
23
examples/playbooks/group_by.yml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
# Example playbook to demonstrate the group_by action plugin.
|
||||
|
||||
- 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
|
||||
tasks:
|
||||
# Create a group of all kvm hosts
|
||||
- action: group_by key=${ansible_virtualization_type}-${ansible_virtualization_role}
|
||||
|
||||
- hosts: kvm-host
|
||||
tasks:
|
||||
- action: ping
|
||||
Loading…
Add table
Add a link
Reference in a new issue