Created
May 8, 2023 03:01
-
-
Save tjhop/5ec0f0c10d16183fb73c7720dccdce12 to your computer and use it in GitHub Desktop.
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
~/go/src/github.com/tjhop/mango (main [ ]) -> cat test/mockup/inventory/hosts/testbox/variables | |
mango_host_template_var="Hi, I'm a host variable!" | |
mango_host_var_for_override="This is the original host variable content." | |
~/go/src/github.com/tjhop/mango (main [ ]) -> cat test/mockup/inventory/modules/test-template/variables | |
mango_module_template_var="Hi, I'm a module variable!" | |
mango_host_var_for_override="Module has updated host var!" | |
~/go/src/github.com/tjhop/mango (main [ ]) -> cat test/mockup/inventory/modules/test-template/apply | |
#!/usr/bin/env bash | |
FILE="/tmp/$(basename ${0%/*})-$$" | |
cat > ${FILE} <<EOF | |
Testing templating! | |
Printing all variables available, via template | |
------------------- | |
Printing host variables: | |
{{- range $k, $v := .HostVars }} | |
{{ $k }} : {{ $v }} | |
{{- end }} | |
------------------- | |
Printing module variables: | |
{{- range $k, $v := .ModuleVars }} | |
{{ $k }} : {{ $v }} | |
{{- end }} | |
------------------- | |
Printing all variables (merged, where module variables override host variables): | |
{{- range $k, $v := .Vars }} | |
{{ $k }} : {{ $v }} | |
{{- end }} | |
------------------- | |
Done. | |
EOF | |
~/go/src/github.com/tjhop/mango (main [ ]) -> cat /tmp/test-template-1359274 | |
Testing templating! | |
Printing all variables available, via template | |
------------------- | |
Printing host variables: | |
mango_host_template_var : Hi, I'm a host variable! | |
mango_host_var_for_override : This is the original host variable content. | |
------------------- | |
Printing module variables: | |
mango_host_var_for_override : Module has updated host var! | |
mango_module_template_var : Hi, I'm a module variable! | |
------------------- | |
Printing all variables (merged, where module variables override host variables): | |
mango_host_template_var : Hi, I'm a host variable! | |
mango_host_var_for_override : Module has updated host var! | |
mango_module_template_var : Hi, I'm a module variable! | |
------------------- | |
Done. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment