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:host_filter field to determine membership dynamically.
Constructed Inventory
Parses multiple source inventories using the constructed inventory plugin to create a unified view:constructed that processes the input inventories.
Key Fields
From the Inventory model (awx/main/models/inventory.py:71):
| Field | Type | Description |
|---|---|---|
name | String | Inventory name (unique within organization) |
description | String | Optional description |
organization | ForeignKey | Organization that owns this inventory |
kind | Choice | Inventory type: '' (standard), smart, or constructed |
host_filter | SmartFilterField | Filter for smart inventories |
input_inventories | ManyToMany | Source inventories for constructed inventories |
variables | TextField | Inventory-level variables (JSON or YAML) |
instance_groups | ManyToMany | Instance groups to run jobs against this inventory |
prevent_instance_group_fallback | Boolean | Prevent falling back to organization instance groups |
Hosts
Hosts are individual systems managed by AWX (awx/main/models/inventory.py:509-656):
Host Fields
| Field | Type | Description |
|---|---|---|
name | String | Hostname or IP address (unique within inventory) |
description | String | Optional description |
inventory | ForeignKey | Parent inventory |
enabled | Boolean | Whether host is available for jobs |
instance_id | String | Unique ID from inventory source |
variables | TextField | Host variables (JSON or YAML) |
ansible_facts | JSON | Cached Ansible facts |
Host Variables
Hosts can have variables defined in JSON or YAML format: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
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:Job Slicing
Inventories support job slicing for parallel execution:job_slice_count > 1, AWX distributes hosts across multiple parallel jobs.
Smart Inventory Filters
Smart inventories use a powerful filtering system: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
Host Metrics
AWX tracks host automation metrics for licensing:Best Practices
Use Groups for Organization
Use Groups for Organization
Organize hosts into logical groups (e.g., webservers, databases, production) to simplify variable management and job targeting.
Leverage Inventory Sources
Leverage Inventory Sources
Use inventory sources to sync from cloud providers rather than manually maintaining hosts. This ensures accuracy and reduces maintenance.
Smart Inventories for Dynamic Groups
Smart Inventories for Dynamic Groups
Use smart inventories to create dynamic views of your infrastructure based on facts or properties.
Enable Host Facts
Enable Host Facts
Use
use_fact_cache in job templates to cache Ansible facts. These facts can be used in smart inventory filters.Set Variables at Appropriate Levels
Set Variables at Appropriate Levels
Place variables at the most appropriate level: inventory-wide variables in the inventory, group-specific in groups, and host-specific in hosts.
Related Resources
- Job Templates - Use inventories in job templates
- Credentials - Configure inventory source credentials
- Organizations - Organize inventories by organization
- Hosts - Host management API