Created
December 14, 2021 18:53
-
-
Save rockaut/73e8ee1c6c105405191c519004ec0360 to your computer and use it in GitHub Desktop.
Ansible-Inventory YAML Anchor
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
--- | |
all: | |
vars: | |
ansible_connection: local | |
children: | |
grp_a: | |
hosts: &grp_a | |
hosta1: | |
hosta2: | |
grp_b: | |
hosts: &grp_b | |
hostb1: | |
hostb2: | |
grp_ab: | |
hosts: | |
<<: *grp_a | |
<<: *grp_b | |
... |
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
# ansible-inventory --list -i hosts.yml | |
{ | |
"_meta": { | |
"hostvars": { | |
"hosta1": { | |
"ansible_connection": "local" | |
}, | |
"hosta2": { | |
"ansible_connection": "local" | |
}, | |
"hostb1": { | |
"ansible_connection": "local" | |
}, | |
"hostb2": { | |
"ansible_connection": "local" | |
} | |
} | |
}, | |
"all": { | |
"children": [ | |
"grp_a", | |
"grp_ab", | |
"grp_b", | |
"ungrouped" | |
] | |
}, | |
"grp_a": { | |
"hosts": [ | |
"hosta1", | |
"hosta2" | |
] | |
}, | |
"grp_ab": { | |
"hosts": [ | |
"hosta1", | |
"hosta2", | |
"hostb1", | |
"hostb2" | |
] | |
}, | |
"grp_b": { | |
"hosts": [ | |
"hostb1", | |
"hostb2" | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment