Created
October 21, 2020 20:17
-
-
Save s-hertel/14b57b8ffa6f1473900ed81fadf724c4 to your computer and use it in GitHub Desktop.
test composing variables
This file contains hidden or 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
# add hosts and hostvars to inventory with the yaml inventory plugin | |
all: | |
hosts: | |
host1: | |
a: 'is_defined' | |
host2: |
This file contains hidden or 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
# compose variables from the hosts in inventory | |
plugin: constructed | |
compose: | |
var: a is defined | ternary('is_defined', 'is_not_defined') |
This file contains hidden or 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 -i inventory_source_1.yml -i inventory_source_2.yml --list | |
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying out features under development. This is a rapidly | |
changing source of code and can become unstable at any point. | |
{ | |
"_meta": { | |
"hostvars": { | |
"host1": { | |
"a": "is_defined", | |
"var": "is_defined" | |
}, | |
"host2": { | |
"var": "is_not_defined" | |
} | |
} | |
}, | |
"all": { | |
"children": [ | |
"ungrouped" | |
] | |
}, | |
"ungrouped": { | |
"hosts": [ | |
"host1", | |
"host2" | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment