Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ansible/awx/llms.txt
Use this file to discover all available pages before exploring further.
The AWX CLI follows a consistent pattern for all operations: awx [options] <resource> <action> [arguments]. This guide covers common usage patterns and workflows.
Command Structure
Every AWX CLI command follows this format:
awx [<global-options>] <resource> <action> [<arguments>]
- global-options: Configuration flags like
--conf.host, -f, -v
- resource: The type of AWX object (users, jobs, projects, etc.)
- action: The operation to perform (list, get, create, modify, delete, etc.)
- arguments: Action-specific parameters
Discovering Resources
To see all available resources:
awx --conf.host https://awx.example.org --help
This displays resources like:
users - User accounts
organizations - Organizations
projects - Project definitions
inventories - Inventory definitions
job_templates - Job templates
jobs - Job executions
credentials - Credentials
- And many more…
Discovering Actions
To see available actions for a resource:
Common actions include:
list - List all resources
get - Get a specific resource by ID or name
create - Create a new resource
modify - Update an existing resource
delete - Delete a resource
Some resources have special actions like launch, update, monitor, etc.
Basic Operations
Listing Resources
List all resources of a type:
awx users list
awx projects list
awx job_templates list
With human-readable output:
With custom columns:
awx users list -f human --filter 'id,username,email,is_superuser'
Getting a Specific Resource
Retrieve by ID:
Retrieve by name (for resources that support it):
With human-readable output:
awx users get alice -f human
Creating Resources
Create a new resource:
awx users create \
--username bob \
--password secret123 \
--email bob@example.com \
--first_name Bob \
--last_name Smith
To see required arguments:
Modifying Resources
Update an existing resource:
awx users modify alice --email alice.new@example.com
awx users modify 1 --first_name Alice
Deleting Resources
Delete by ID or name:
awx users delete bob
awx users delete 42
Advanced Operations
Filtering Lists
Filter results using query parameters:
# Filter users by username
awx users list --username alice
# Filter jobs by status
awx jobs list --status successful
# Filter projects by organization
awx projects list --organization 1
By default, the CLI returns the first page of results. To get all pages:
Sorting
Sort results by field:
# Sort ascending
awx jobs list --order_by created
# Sort descending
awx jobs list --order_by '-created'
# Multiple sort fields
awx jobs list --order_by 'status,-created'
Working with JSON/YAML Data
Many fields accept JSON or YAML input:
# Inline JSON
awx credentials create \
--name 'SSH Key' \
--credential_type 'Machine' \
--inputs '{"username": "ansible", "password": "secret"}'
# From file
awx credentials create \
--name 'SSH Key' \
--credential_type 'Machine' \
--inputs @credentials.json
File References
For fields containing file data (like SSH keys):
awx credentials create \
--credential_type 'Machine' \
--name 'My SSH Key' \
--inputs '{"username": "ansible", "ssh_key_data": "@~/.ssh/id_rsa"}'
Special Actions
Launching Jobs
Launch a job template:
# Launch by name
awx job_templates launch 'Deploy Application'
# Launch by ID
awx job_templates launch 42
# Launch with extra variables
awx job_templates launch 'Deploy Application' \
--extra_vars '{"version": "1.2.3"}'
# Launch and monitor output
awx job_templates launch 'Deploy Application' --monitor
# Launch and wait for completion (no output)
awx job_templates launch 'Deploy Application' --wait
Monitoring Jobs
Watch job output in real-time:
Get job stdout:
Updating Projects
Trigger a project update:
awx projects update 'My Project'
awx projects update 5 --monitor
Inventory Updates
Update an inventory source:
awx inventory_sources update 'AWS Dynamic Inventory'
awx inventory_sources update 10 --monitor
Working with Relationships
Associating Resources
Associate credentials with job templates:
awx job_templates associate 'My Job' --credential 'SSH Key'
Associate notification templates:
awx job_templates associate 'My Job' --start_notification 'Slack'
awx job_templates associate 'My Job' --success_notification 'Email'
Disassociating Resources
awx job_templates disassociate 'My Job' --credential 'SSH Key'
Granting and Revoking Permissions
Grant roles to users:
awx users grant alice --project 'My Project' --role admin
awx users grant bob --organization 'Engineering' --role member
Revoke roles:
awx users revoke alice --project 'My Project' --role admin
Grant roles to teams:
awx teams grant 'DevOps' --job_template 'Deploy' --role execute
Bulk Operations
Bulk Host Creation
awx bulk host_create --inventory 'Production' \
--hosts '[{"name": "web1"}, {"name": "web2"}, {"name": "web3"}]'
Bulk Host Deletion
awx bulk host_delete --hosts '[{"name": "web1"}, {"name": "web2"}]'
Bulk Job Launch
awx bulk job_launch \
--jobs '[{"unified_job_template": 1}, {"unified_job_template": 2}]' \
--monitor
Import/Export
Exporting Resources
Export all resources:
Export specific resource types:
awx export --users --organizations > config.json
Export specific resources by name:
awx export --users alice --users bob > users.json
Export by ID:
awx export --job_templates 42 > template.json
Export in YAML format:
awx export -f yaml > backup.yml
Importing Resources
Import from JSON:
Import from YAML:
awx import -f yaml < backup.yml
Configuration Commands
View Current Configuration
Output:
{
"base_url": "https://awx.example.org",
"use_sessions": true,
"credentials": {
"default": {
"username": "alice",
"password": "***"
}
}
}
View System Settings
View specific setting category:
awx settings list --slug auth
awx settings list --slug jobs
Modify Settings
awx settings modify SESSION_COOKIE_AGE 3600
awx settings modify REMOTE_HOST_HEADERS '["HTTP_X_FORWARDED_FOR"]'
Control Resources
Some resources provide metadata or system information:
Ping
Check API connectivity:
Config
View AWX configuration:
View current user information:
Metrics
View system metrics:
awx metrics list
awx metrics list -f human
Working with Ad Hoc Commands
Run ad hoc commands:
awx ad_hoc_commands create \
--inventory 'Demo Inventory' \
--credential 'Demo Credential' \
--module_name ping \
--limit 'web*' \
--monitor
awx ad_hoc_commands create \
--inventory 'Demo Inventory' \
--credential 'Demo Credential' \
--module_name shell \
--module_args 'uptime' \
--limit 'all' \
--monitor
JSON Output (Default)
Human-Readable Tables
awx jobs list -f human --filter 'id,name,status,created'
YAML Output
awx projects get 'My Project' -f yaml
JQ Filtering
# Extract specific fields
awx users list -f jq --filter '.results[] | {id, username}'
# Filter by condition
awx jobs list -f jq --filter '.results[] | select(.status == "successful")'
All Fields
awx users list -f human --filter '*'
Practical Examples
Create a Complete Job Template
# Create organization
awx organizations create --name 'Engineering'
# Create project
awx projects create --wait \
--organization 'Engineering' \
--name 'Web App' \
--scm_type git \
--scm_url 'https://github.com/example/webapp.git'
# Create inventory
awx inventories create \
--organization 'Engineering' \
--name 'Production'
# Add hosts
awx hosts create \
--inventory 'Production' \
--name 'web1.example.com'
# Create credential
awx credentials create \
--name 'SSH Key' \
--credential_type 'Machine' \
--inputs '{"username": "ansible", "ssh_key_data": "@~/.ssh/id_rsa"}'
# Create job template
awx job_templates create \
--name 'Deploy Web App' \
--project 'Web App' \
--playbook 'deploy.yml' \
--inventory 'Production'
# Associate credential
awx job_templates associate 'Deploy Web App' --credential 'SSH Key'
# Launch job
awx job_templates launch 'Deploy Web App' --monitor
Monitor Job History
# View recent jobs
awx jobs list --all --order_by '-created' \
-f human --filter 'id,name,status,created'
# View jobs for specific template
awx jobs list --job_template 'Deploy Web App' \
-f human --filter 'id,status,created'
# View failed jobs
awx jobs list --status failed \
-f human --filter 'id,name,created,started,finished'
Backup and Restore
# Backup all configuration
awx export > awx-backup-$(date +%Y%m%d).json
# Backup specific resources
awx export --users --organizations --teams > rbac-backup.json
# Restore from backup
awx import < awx-backup-20260304.json
Tips and Best Practices
- Use
--help liberally - Every resource and action has detailed help
- Use names instead of IDs - More readable and maintainable
- Use
--all for listings - Ensures you get all results, not just first page
- Use
-f human for exploration - Easier to read during development
- Use
-f json for automation - Consistent, parseable output
- Use
--monitor during development - See job output in real-time
- Use
--wait in scripts - Ensures jobs complete before continuing
- Store credentials in environment - More secure than command-line flags
- Use
@file for large data - Cleaner than inline JSON
- Enable verbose mode for debugging -
awx -v shows HTTP requests
Getting Help
# General help
awx --help
# Resource help
awx users --help
# Action help
awx users create --help
# Version information
awx --version