Skip to content

Instantly share code, notes, and snippets.

@halberom
Last active June 18, 2021 07:50
Show Gist options
  • Save halberom/e7791aa22c7dd1ef3f1ece3c815b4af8 to your computer and use it in GitHub Desktop.
Save halberom/e7791aa22c7dd1ef3f1ece3c815b4af8 to your computer and use it in GitHub Desktop.
ansible - testing constructed inventory plugin
[inventory]
enable_plugins = ini, constructed
plugin: constructed
strict: False
keyed_groups:
- prefix: foo
key: foo|default('none')
host1
host2 foo=bar
host3 foo=foo
host4
host5 foo=foo
ansible host5 -i hosts -i dynamic.config -m debug -a 'var=groups'
host5 | SUCCESS => {
"changed": false,
"groups": {
"all": [
"host1",
"host2",
"host3",
"host4",
"host5"
],
"foo_bar": [
"host2"
],
"foo_foo": [
"host5",
"host3"
],
"foo_none": [
"host4",
"host1"
],
"ungrouped": [
"host1",
"host2",
"host3",
"host4",
"host5"
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment