AWX17.1.0 - Create inventory with multiple hosts in single shot

Hi,
I am using AWX 17.1.0 installed on Ubuntu server. I need to create the host inventory file which has more than 25 host entries in a single shot. How to create those server lists in the inventory file? Any suggestions on this?

My understanding is you want to create a Inventory with host entries without having to enter each host individually.
The easiest way I have found is using the awx-manage command from the CLI.

  1. First create your inventory in AWX, giving it a name without spaces or special characters in the name. Once the hosts are loaded you can change the name if needed.
    For my example below my inventory name is “inventory1”

  2. Log into the AWX Host or AWX’s task container with a userid that has the ability to make changes to awx (usually either the awx user or any root type user).

[root@awx awx]#

  1. Create a file with the list of hosts to be added to the inventory. You can use hostnames or ip addresses.
    You can also include host variables similar to an ansible hosts file.
    [root@awx awx]# cat hosts_add
    192.168.3.151

192.168.3.152
192.168.3.153
192.168.3.154
192.168.3.155
webserver.example.com ansible_user=myuser
[root@awx awx]#

  1. Once your list is ready, using the awx-manage command to add the hosts to the inventory you created above.
    [root@awx awx]# awx-manage inventory_import --inventory-name inventory1 --source hosts_add
    13.320 INFO Updating inventory 1: inventory1
    13.965 INFO Reading Ansible inventory source: /var/lib/awx/hosts_add

    22.581 INFO Inventory import completed for ( inventory1 - 6) in 10.2s
    [root@awx awx]#

  2. Go back to AWX’s GUI to verify your work.

  • Ray

I’ll mention there is a feature in the works that will allow you to add multiple hosts to an inventory in a single request, you can follow the work here https://github.com/ansible/awx/pull/13462

Once this lands, you can upgrade to the newest AWX to start using that feature!

AWX Team

Thanks for this info.
I have awx 17.1.0 installed on Ubuntu. Here I could not see the awx-manage utility. How to get that?
please suggest.

My awx-manage is installed in /usr/bin/awx-manage
You should be able to use the apt-file search in Ubuntu to find out where it can be installed from.
We are using Enterprise Linux so my packages are different but I did not have to install anything extra to get awx-manage.

Ray