Inventory scripts are deprecated as of Ansible Tower Version 3.7.2.
If you use custom inventory scripts, migrate to sourcing these scripts from a project. See Inventory File Importing in the subsequent section, and also refer to Inventory Sources in the Ansible Tower User Guide for more detail.
Tower includes built-in support for syncing dynamic inventory from cloud sources such as Amazon AWS, Google Compute Engine, among others. Tower also offers the ability to use a custom script to pull from your own inventory source.
With the release of Ansible Tower 2.4.0, edits and additions to Inventory host variables now persist beyond an inventory sync as long as
--overwrite_vars is not set. To have inventory syncs behave as they did before, it is now required that both
--overwrite_vars are set.
To manage the custom inventory scripts available in Tower, click the Inventory Scripts ( ) icon from the left navigation bar.
To add a new custom inventory script, click the button.
Enter the name for the script, plus an optional description. Then select the Organization that this script belongs to.
You can then either drag and drop a script on your local system into the Custom Script text box, or cut and paste the contents of the inventory script there.
You can write inventory scripts in any dynamic language that you have installed on the Tower machine (such as shell or python). They must start with a normal script shebang line such as
#!/usr/bin/python. They run as the
awx user. The inventory script invokes with
'--list' to list the inventory, which returns in a JSON hash/dictionary.
Generally, they connect to the network to retrieve the inventory from other sources. When enabling multi-tenancy security (refer to Security for details), the inventory script will not be able to access most of the Tower machine. If this access to the local Tower machine is necessary, configure it in
For more information on dynamic inventory scripts and how to write them, refer to the Intro to Dynamic Inventory and Developing Dynamic Inventory Sources sections of the Ansible documentation, or review the example dynamic inventory scripts on GitHub.