Can someone please suggest a way to keep an inventory file used for Ansible playbooks called from command line (ansible-playbook -i [inventory file] …) with a similar inventory used by Ansible Tower?
For example I have a static inventory file:
[myhosts]
hostname1
hostname2
hostname3
Instead of updating this file and updating a similar inventory in Tower each time a new host is added, is there a way both share the same inventory, or some way to sync one with the other?
This is actually difficult to answer because there are so many ways to do it.
The big question is whether you intend to manage the inventory locally or inside of AWX. If you are primarily managing it locally on your file system, then make a git repo and push it there, and follow the steps that fabiancernota mentioned.
You can also dynamically pull inventory from AWX to use in a local run of ansible-playbook. We have a script in source called tower.py in awx/plugins that has the machinery to be this dynamic inventory source, provided you set some environment vars to define credentials. Soon, an inventory plugin to dynamically source inventory from AWX will make it into Ansible core.