Hello !
I have read through some forum posts that i could use env variables but i really do not want to do so. So wanted to know if ansible dynamic inventory can accept a variable
Ritesh
Hello !
I have read through some forum posts that i could use env variables but i really do not want to do so. So wanted to know if ansible dynamic inventory can accept a variable
Ritesh
Dynamic inventory scripts only accept 2 arguments that ansible will actively attempt to call: --host and --list.
To provide additional configuration, your inventory script could have a config file, or utilize ENV vars as suggested in the other posts you have read.
Not sure exactly what you mean by “accept arguments”.
You can do something like add the varible into the play book
hosts: ’ {{ hosts }}’
and then when you run the playbook you can say something like
ansible-playbook -e “hosts=HOSTNAME” playbook.yml
OR better yet, use the inventory generated tag names lik
ansible-playbook -e “hosts=tag_Name_cronbox-ops1-cronbox” playbook.yml
In “-e” you can add several value pairs that will act as variables.
Bob
don't use variables that overlap with keywords, use 'targets' instead
of 'hosts', for example