How do i add ansible static and dynamic host inventories in one directory?
-
Link to ansible dynamic inventory documentation: http://docs.ansible.com/ansible/latest/intro_dynamic_inventory.html
Note: Use aws configure for credentials, do not put them into the ec2.ini, because if the entire directory it going onto github, your credentials will be in that file.
Here the aws dynamic inventory is used.
First edit the /etc/ansible/ansible.cfg file and add/uncomment the inventory, this points to a file or directory where your inventory resides.
This specifies the directory where the inventories are found.
inventory = /you ansible dir location/inventory
I prefer to put these two file in the /you ansible dir location/contrib/inventory directory, and create symbolic links from the /you ansible dir location/inventory directory.
Copy ec2.py and ec2.ini into this directory and make your customisations to the two dynamic inventory.
The ec2.py and ec2.ini can be found at:
https://raw.github.com/ansible/ansible/devel/contrib/inventory/ec2.py
https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/ec2.iniSetting it up this way allow you to does away with using longer ansible command line with full path names.
$ ansible -i ec2.py all -m ping
© Lightnetics 2024