Ansible AWX Adding new target hosts
If you have followed the setup of Ansible AWX in this post, you should have Ansible AWX up and running.
This post will explain how to add new target host machines to run Ansible on.
Method 1 : Using the AWX webpage
- Login to the AWX frontend using your admin credentials
- Click on inventories from the left menu
As part of the initial setup, there will be 1 inventory built in called: Demo Inventory
In this example, I’ve created a new inventory to demonstrate on how to also create one.
- Click the green plus sign which can be found on the right of the page
- Select Inventory
- Fill in the desired fields, then click Save
The newly created inventory will have 0 hosts associated with it.
So, the next steps show how to add a new host.
With the inventory page open. Click on the HOSTS button.
- Click on the green plus icon
- Fill in the required fields - Hostname
- Click save
Once saved the new host will show up in the inventory
Method 2 : Utilising the awx-manage command
The awx-manage command comes in handy; especially when you need to import several machines at a time.
-
Connect to the docker container - awx_task (note this is the default name of the container used during the initial setup of AWX).
-
Create a source hosts file .e.g. /var/tmp/ansible_hosts
-
Enter the list of IP-Addresses or Hostname’s (ensuring these can be resolved) of the target machines you wish to import
Then invoke the following command
awx-manage inventory_import --inventory-name ${name of inventory} --source ${full_path_to_hosts_file}