-
-
Save AlBichutsky/9df94e4c5fd0c6cb98f26ac226878c71 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