• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

UnixArena

  • Home
  • kubernetes
  • DevOps
    • Terraform
    • Jenkins
    • Docker
    • Openshift
      • OKD
    • Ansible engine
    • Ansible Tower
      • AWX
    • Puppet
  • Cloud
    • Azure
    • AWS
    • Openstack
    • Docker
  • VMware
    • vCloud Director
    • VMware-Guests
    • Vcenter Appliance 5.5
    • vC OPS
    • VMware SDDC
    • VMware vSphere 5.x
      • vSphere Network
      • vSphere DS
      • vShield Suite
    • VMware vSphere 6.0
    • VSAN
    • VMware Free Tools
  • Backup
    • Vembu BDR
    • Veeam
    • Nakivo
    • Azure Backup
    • Altaro VMBackup
    • Spinbackup
  • Tutorials
    • Openstack Tutorial
    • Openstack Beginner’s Guide
    • VXVM-Training
    • ZFS-Tutorials
    • NetApp cDot
    • LVM
    • Cisco UCS
    • LDOM
    • Oracle VM for x86
  • Linux
    • How to Articles
    • Q&A
    • Networking
    • RHEL7
  • DevOps Instructor-led Training
  • Contact

AWX / Ansible Tower – Inventory & Bulk Hosts Import

December 16, 2018 By Cloud_Devops 7 Comments

AWX / Ansible Tower’s inventory is a key component to start the automation. Creating the inventory could be a lengthy process when you use the graphical user interface. AWX/Tower offers multiple methods to add the hosts into inventory. In this article, we will see that how to add the hosts in Ansible Tower/ AWX inventory using GUI and bulk import using the command line.  The following method will guide you to add the ansible clients using AWX/Tower GUI method.

 

1. Login to Ansible Tower/ AWX with admin privileges.

 

2. Create a new inventory by navigating to they inventories tab. Click on ” + ”  .

Creating New inventory AWX
Creating New inventory AW

3.  Once the new inventory is saved, click on “HOSTS” tab and click “+” to add new hosts.

Adding a New Host in AWX/Tower Inventory
Adding a New Host in AWX/Tower Inventory

4. Enter the host details and description.  You could also add host variable in the bottom of the table.

Enter the host detail - AWX/ Tower
Enter the host detail – AWX/ Tower

5.  Navigate back to the Inventories tab.

List of inventory - AWX / Tower
List of inventory – AWX / Tower

Add Multiple hosts in AWX/ Ansible Tower – Bulk Import

Ansible Tower / AWX offers utility called “awx-manage” to perform plenty of operations in CLI .  One of the most important features of “awx-manage” is bulk hosts import. Using this utility, you could add N-number of ansible clients in few minutes.

1. Login to Ansible Tower’s host or AWX’s task container in interactive mode (Linux Host). Execute the following command to check the “awx-manage” version

[root@awx awx]# awx-manage --version
1.0.8.0
[root@awx awx]#

 

2. Create a file with the list of hosts which needs to be added into Ansible Tower/AWX’s inventory.

[root@awx awx]# cat hosts_add
192.168.3.152
192.168.3.153
192.168.3.154
192.168.3.155
192.168.3.156
192.168.3.157
192.168.3.158
192.168.3.159
[root@awx awx]#

 

3. Once the list is ready, identify the inventory name in which you need to add the hosts from AWX/Tower’s GUI. (Refer Step 5). In the example, I will be adding the prepared hosts into “Linux_UA_Hosts” inventory.

[root@awx awx]# awx-manage inventory_import --inventory-name Linux_UA_Hosts --source hosts_add
   13.320 INFO     Updating inventory 2: Linux_UA_Hosts
   13.965 INFO     Reading Ansible inventory source: /var/lib/awx/hosts_add
   22.051 INFO     Processing JSON output...
   22.052 INFO     Loaded 0 groups, 8 hosts
2018-11-26 17:03:32,529 DEBUG    awx.main.models.inventory Going to update inventory computed fields
2018-11-26 17:03:32,705 DEBUG    awx.main.models.inventory Finished updating inventory computed fields
   22.581 INFO     Inventory import completed for  (Linux_UA_Hosts - 7) in 10.2s
[root@awx awx]#

 

4. Go back to Tower’s/ AWX’s GUI to verify our work.

Hosts Added in AWX's inventory
Hosts Added in AWX’s inventory

 

We have successfully added multiple ansible clients in a single shot using “awx-manage” command.

Filed Under: Ansible engine, Ansible Tower, Automation, AWX, Configuration Management, DevOps Tagged With: Ansible, Ansible Tower, AWX, awx-manage

Reader Interactions

Comments

  1. Javeed says

    April 18, 2023 at 4:51 am

    I have installed AWX via K3s AWX-operator and I am getting below error when I tried to add the inventory via Pod container.

    bash-5.1$ awx-manage inventory_import –inventory-name npd-test-hosts –source /var/tmp/ansible_hosts
    1.076 INFO Updating inventory 2: npd-test-hosts
    2023-04-17 22:56:20,479 INFO [-] awx.analytics.job_lifecycle inventoryupdate-8 created
    1.108 WARNING This command is not able to run on kubernetes-based deployment. This action should be done using the API.
    bash-5.1$

    Reply
  2. ALEX says

    March 15, 2021 at 8:57 pm

    you need to go under the user who installed awx , in the .awx directory , in my case root

    A. cd
    B. /root/.awx/awxcompose
    C. docker exec -it awx_task bash
    D. docker exec -it awx_task bash
    bash-4.4# awx-manage –version
    15.0.1

    Reply
    • Fernando Kleiman says

      January 7, 2022 at 12:29 am

      Thank you! That was a good tip that worked for me!

      Reply
  3. stuck says

    July 24, 2019 at 9:38 am

    awx-manage command not found n the system… any way to solve it ?!

    [root@ansiblemaster awx]# which awx-manage
    /usr/bin/which: no awx-manage in (/sbin:/bin:/usr/sbin:/usr/bin)

    Reply
  4. amine says

    April 4, 2019 at 4:18 pm

    is it possible to make the inventory sync ? that mean if i change in the file of the inventory ( add or remove nodes ) the inventory in the ansible tower change ?

    Reply
    • Lingeswaran R says

      April 6, 2019 at 7:49 pm

      I haven’t tried that.

      Thank you.
      Lingesh

      Reply
  5. Sanjeev Rana says

    February 26, 2019 at 11:25 am

    awx-manage: command not found

    What package need to install ?

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Follow UnixArena

  • Facebook
  • LinkedIn
  • Twitter

Copyright © 2025 · UnixArena ·

Go to mobile version