Created
March 10, 2016 13:08
-
-
Save tuxfight3r/2c027f8fd70333a8288e to your computer and use it in GitHub Desktop.
Ansible dynamic inventory bash demo
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
#!/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