Use an existing static inventory stored in a Git repository in automation controller.
Outcomes
Use an existing static inventory file stored in a Git repository.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command ensures that automation controller is installed and configured with any necessary resources created in previous exercises.
[student@workstation ~]$ lab start advinventory-static
Procedure 7.1. Instructions
Use an existing static inventory file stored in a Git repository.
Navigate to https://controller.lab.example.com and log in as the admin user with redhat as the password.
Create a new inventory. Navigate to → and then click → .
Use Git Inventory as the name, use Inventory with Git source as the description, and then click .
On the page, click the tab and then click to add a source.
Fill in the details as follows and then click .
| Field | Value |
|---|---|
| Name |
Git Source
|
| Description |
Git source for inventory
|
| Source | |
| Project |
Advanced Inventory
|
| Inventory file | |
| Update options |
You might see the following message below the field even if you selected the project name from the list of projects:
That value was not found. Please enter or select a valid value.
The message disappears as soon as you select a different field.
Click and wait until displays .
Navigate to → and click .
Review the tab and the tab and notice the hosts and groups that were added to the inventory.
View the details of the web_servers host group and notice that the variables are also imported.
![]() |
Although the variables are displayed in JSON format here, the web UI can also display variables in YAML format.
Modify an existing job template to use the new inventory.
Navigate to → .
Click the icon for the job template.
On the page, enter Git Inventory in the field.
Click to save the changes.
On the page, click .
Review the page. Notice that the job runs on three hosts: servera.lab.example.com, serverb.lab.example.com, and serverc.lab.example.com.
Clone the https://git.lab.example.com/git/advanced-inventory.git Git repository into the /home/student/git-repos directory.
From a terminal, create the /home/student/git-repos directory if it does not already exist, and then change into it.
[student@workstation ~]$mkdir -p ~/git-repos/[student@workstation ~]$cd ~/git-repos/
Clone the advanced-inventory git repository and then change into the cloned repository:
[student@workstation git-repos]$git clone \>https://git.lab.example.com/git/advanced-inventory.gitCloning into 'advanced-inventory'... ...output omitted... [student@workstation git-repos]$cd advanced-inventory
Review the files in the project directory using the tree command:
[student@workstation advanced-inventory]$ tree
.
├── ansible.cfg
├── group_vars
│ └── web_servers
│ └── packages.yml
├── hello_world.yml
└── inventory
2 directories, 4 filesAdd serverd.lab.example.com to the [lb_servers] section of the inventory file. The first three lines of the file should consist of the following content:
[student@workstation advanced-inventory]$ head -n 3 inventory
[lb_servers]
servera.lab.example.com
serverd.lab.example.comAdd the changes to the index, commit the changes using Updated inventory as the commit message, and then push the changes to the remote repository.
[student@workstation advanced-inventory]$git add inventory[student@workstation advanced-inventory]$git commit -m "Updated inventory"[main e76b744] Updated inventory 1 file changed, 1 insertion(+) [student@workstation advanced-inventory]$git push -u origin mainEnumerating objects: 5, done. Counting objects: 100% (5/5), done. ...output omitted... Branch 'main' set up to track remote branch 'main' from 'origin'.
Verify that the changes are reflected in the inventory.
From the automation controller web UI, navigate to → .
Click the icon for the project. Wait until the synchronization is complete.
Navigate to → and click the icon for the job template.
After the job is finished, review the page. Notice that the job runs on four hosts: servera.lab.example.com, serverb.lab.example.com, serverc.lab.example.com, and serverd.lab.example.com.
Navigate to → and click . Review the tab and notice that serverd.lab.example.com is now present in the inventory.