Syncing inventories between Ansible and Ansible Tower?

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?

I think you could use awx-manage utility for this task. More detail by follow this:

https://docs.ansible.com/ansible-tower/latest/html/administration/tower-manage.html

Regards,
Tu DT

Hey Jeffrey,

you can import your Inventory from a Git Repository. See Inventory → New → Sources.

I hope this will help you :slight_smile:

Fabian

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.

https://github.com/ansible/ansible/pull/41816

but that’s still a little ways off from being released.