Skip to main content

What is an Inventory?

An Inventory in AWX is a collection of hosts that Ansible can manage. Inventories organize hosts into groups, define host and group variables, and can be synchronized from external sources. They are the foundation of AWX’s infrastructure management capabilities.
Think of inventories as your infrastructure database - they define what systems you can automate against and how they’re organized.

Inventory Types

AWX supports three types of inventories (awx/main/models/inventory.py:77-81):

Standard Inventory

The default type where hosts are directly linked to the inventory. Hosts can be added manually or through inventory sources.

Smart Inventory

A dynamic inventory that uses a filter to automatically include hosts from other inventories:
Smart inventories evaluate the host_filter field to determine membership dynamically.

Constructed Inventory

Parses multiple source inventories using the constructed inventory plugin to create a unified view:
Constructed inventories automatically create an inventory source of type constructed that processes the input inventories.

Key Fields

From the Inventory model (awx/main/models/inventory.py:71):

Hosts

Hosts are individual systems managed by AWX (awx/main/models/inventory.py:509-656):

Host Fields

Host Variables

Hosts can have variables defined in JSON or YAML format:
Special variables like ansible_host override the host name for connections:

Groups

Groups organize hosts into logical collections (awx/main/models/inventory.py:658-863):

Group Structure

Groups can contain:
  • Hosts (many-to-many relationship)
  • Child groups (hierarchical structure)
  • Variables that apply to all members

Group Hierarchy

Groups can have multiple parents, creating complex hierarchies.

Inventory Sources

Inventory sources sync hosts from external systems (awx/main/models/inventory.py:1082):

Supported Source Types

  • Amazon EC2: Sync from AWS EC2 instances
  • Google Compute Engine: Sync from GCP
  • Microsoft Azure: Sync from Azure VMs
  • VMware vCenter: Sync from VMware
  • Red Hat Satellite: Sync from Satellite
  • OpenStack: Sync from OpenStack
  • Ansible Tower/AWX: Sync from another AWX instance
  • Custom Script: Run custom inventory script
  • SCM: Pull inventory from a project
  • Constructed: Process input inventories

Inventory Source Configuration

Update on Launch

Like projects, inventory sources can update automatically:

Inventory Script Output

AWX generates dynamic inventory in Ansible’s JSON format:
This format is used internally by AWX when running playbooks.

Job Slicing

Inventories support job slicing for parallel execution:
When a job template has job_slice_count > 1, AWX distributes hosts across multiple parallel jobs.

Smart Inventory Filters

Smart inventories use a powerful filtering system:
Smart inventory filters are evaluated against the database. Very complex filters may impact performance.

API Endpoints

List Inventories

Create Inventory

Create Smart Inventory

Add Host

Create Group

Add Inventory Source

Update Inventory Source

Permissions

Inventories have the following roles (inventory.py:171-190):
  • Admin Role: Full control over inventory
  • Update Role: Can trigger inventory source updates
  • Ad Hoc Role: Can run ad hoc commands
  • Use Role: Can use inventory in job templates
  • Read Role: Can view inventory details
The use permission is required to select an inventory in a job template. The adhoc permission is required to run ad hoc commands.

Host Metrics

AWX tracks host automation metrics for licensing:
Host metrics track automation activity across all inventories.

Best Practices

Organize hosts into logical groups (e.g., webservers, databases, production) to simplify variable management and job targeting.
Use inventory sources to sync from cloud providers rather than manually maintaining hosts. This ensures accuracy and reduces maintenance.
Use smart inventories to create dynamic views of your infrastructure based on facts or properties.
Use use_fact_cache in job templates to cache Ansible facts. These facts can be used in smart inventory filters.
Place variables at the most appropriate level: inventory-wide variables in the inventory, group-specific in groups, and host-specific in hosts.