Abstract
| Goal |
Manage inventories that are generated dynamically from scripts or the automation controller smart inventory feature. |
| Objectives |
|
| Sections |
|
| Lab |
|
Import existing static inventory files managed in a Git repository into automation controller.
If you are adding an existing Ansible project that you have been managing from a traditional control node into automation controller, you might already have a large static inventory file for that project. It can be inconvenient to add that static inventory manually through the web UI. You might also want to continue to manage that static inventory outside of automation controller rather than through the web UI. A number of ways exist to handle these situations.
One of the most effective solutions is to configure automation controller to retrieve a static inventory file from an existing automation controller project. This approach enables you to manage changes to the inventory (and inventory variables) just like changes to other files under version control. Although possible, you should avoid using the web UI to make changes to this type of inventory because automation does not push changes back to your version control system. When you make a change to your source control repository that affects the inventory, you need to synchronize both the associated project and inventory before automation controller recognizes the changes.
Automation controller can use inventory files that you manage in a source code management (SCM) repository. You can continue to store your inventory in a Git repository, and use commits, pull requests, and other features of Git or your repository server to manage updates. You can also use any other type of SCM that is supported by projects in automation controller.
To configure this functionality, start by setting up a project that points to your Git repository. This is done in exactly the same way as when you are setting up a project to be part of a job template. Specify the Source Control Type (such as Git) and Source Control URL of the repository containing the inventory file or files. You also need to specify the Source Control Credential that contains the authentication information for that repository. You can specify a particular branch, tag, or commit to use, and whether the contents of the project should update the revision on launch like any other project.
After you have set up the project, you can configure the inventory in automation controller. Create the inventory normally and open it for editing. Click , and then click to add a new source.
On the page, give the source a name and then select a source. Selecting the → source exposes extra fields on the page. Specify the that contains your inventory. Select the inventory file from the list, or enter the file name if it does not appear.
You can enter an SCM credential in the field if one is needed to access the project’s Git repository. You can also select the checkbox to refresh the inventory after every project update that involves a Git revision update. Finally, you can save the changes and synchronize the inventory with the project.
For more information about adding inventories to automation controller, refer to the Automation Controller User Guide at https://docs.ansible.com/automation-controller/latest/html/userguide/inventories.html#add-a-new-inventory