Chapter 5. Inventory File Importing With automation controller you can select an inventory file from source control, rather than creating one from scratch. The files are non-editable, and as inventories are updated at the source, the inventories within the projects are also updated accordingly, including the group_vars and host_vars files or directory associated with them. SCM types can consume both inventory files and scripts. Both inventory files and custom inventory types use scripts. Imported hosts have a description of imported by default. This can be overridden by setting the _awx_description variable on a given host. For example, if importing from a sourced .ini file, you can add the following host variables: [main] 127.0.0.1 _awx_description="my host 1" 127.0.0.2 _awx_description="my host 2" Similarly, group descriptions also default to imported , but can also be overridden by _awx_description . To use old inventory scripts in source control, see Export old inventory scripts in Using automation execution . 5.1. Source control management Inventory Source Fields The source fields used are: source_project : the project to use. source_path : the relative path inside the project indicating a directory or a file. If left blank, "" is still a relative path indicating the root directory of the project. source_vars : if set on a "file" type inventory source then they are passed to the environment variables when running. Additionally: An update of the project automatically triggers an inventory update where it is used. An update of the project is scheduled immediately after creation of the inventory source. Neither inventory nor project updates are blocked while a related job is running. In cases where you have a large project (around 10 GB), disk space on /tmp can be an issue. You can specify a location manually in the automation controller UI from the Add source page of an inventory. Refer to Adding a source for instructions on creating an inventory source. When you update a project, refresh the listing to use the latest source control management (SCM) information. If no inventory sources use a project as an SCM inventory source, then the inventory listing might not be refreshed on update. For inventories with SCM sources, the job Details page for inventory updates displays a status indicator for the project update and the name of the project. The status indicator links to the project update job. The project name links to the project. You can perform an inventory update while a related job is running. 5.1.1. Supported File Syntax Automation controller uses the ansible-inventory module from Ansible to process inventory files, and supports all valid inventory syntax that automation controller requires. Important You do not need to write inventory scripts in Python. You can enter any executable file in the source field and must run chmod +x for that file and check it into Git. The following is a working example of JSON output that automation controller can read for the import: { "_meta": { "hostvars": { "host1": { "fly_rod": true } } }, "all": { "children": [ "groupA", "ungrouped" ] }, "groupA": { "hosts": [ "host1", "host10", "host11", "host12", "host13", "host14", "host15", "host16", "host17", "host18", "host19", "host2", "host20", "host21", "host22", "host23", "host24", "host25", "host3", "host4", "host5", "host6", "host7", "host8", "host9" ] } } Additional resources For examples of inventory files, see test-playbooks/inventories . For an example of an inventory script inside of that, see inventories/changes.py . For information about how to implement the inventory script, see the support article, How to migrate inventory scripts from Red Hat Ansible tower to Red Hat Ansible Automation Platform? .

Commands:
[main] 127.0.0.1 _awx_description="my host 1" 127.0.0.2 _awx_description="my host 2"
{ "_meta": { "hostvars": { "host1": { "fly_rod": true } } }, "all": { "children": [ "groupA", "ungrouped" ] }, "groupA": { "hosts": [ "host1", "host10", "host11", "host12", "host13", "host14", "host15", "host16", "host17", "host18", "host19", "host2", "host20", "host21", "host22", "host23", "host24", "host25", "host3", "host4", "host5", "host6", "host7", "host8", "host9" ] } }