-
-
Save greising/1b65558ee899430dd825364b1b3bb11a to your computer and use it in GitHub Desktop.
Ansible dynamic inventory bash demo
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
| #!/bin/bash | |
| if [ "$1" == "--list" ] ; then | |
| cat<<EOF | |
| { | |
| "bash_hosts": { | |
| "hosts": [ | |
| "10.220.21.24", | |
| "10.220.21.27" | |
| ], | |
| "vars": { | |
| "host_proxy_var": "proxy2" | |
| } | |
| }, | |
| "_meta": { | |
| "hostvars": { | |
| "10.220.21.24": { | |
| "host_specific_var": "towerhost" | |
| }, | |
| "10.220.21.27": { | |
| "host_specific_var": "testhost" | |
| } | |
| } | |
| } | |
| } | |
| EOF | |
| elif [ "$1" == "--host" ]; then | |
| echo '{"_meta": {"hostvars": {}}}' | |
| else | |
| echo "{ }" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment