Core Concepts
AWX abstracts and extends Ansible’s functionality to provide a web-based automation platform. Understanding these core concepts is essential for working with AWX.Projects
Projects represent a collection of Ansible playbooks. Most AWX users create Projects that import periodically from source control systems (such as git or subversion repositories). Key Features:- Import from SCM (Git, SVN, etc.)
- Update on launch capability
- Caching mechanism
- Integration with Ansible playbooks
Inventories
AWX manages Inventories, Groups, and Hosts, and provides a RESTful interface that maps to static and dynamic Ansible inventories. Inventory Types:- Static Inventories: Manually entered or imported
- Dynamic Inventories: Synced from external sources
- Smart Inventories: Host filter-based dynamic inventories
Job Templates
A Job Template is a definition and set of parameters for runningansible-playbook. It defines metadata about a given playbook run:
- A named identifier
- An associated inventory to run against
- The project and
.ymlplaybook to run - Various options mapping directly to
ansible-playbookarguments:extra_vars- Verbosity level
- Forks
- Limit
- Tags
- And more…
Credentials
AWX stores sensitive credential data which can be attached toansible-playbook processes that it runs.
Credential Types:
- SSH credentials: Usernames, passwords, SSH keys and passphrases
- Vault passwords: Ansible Vault decryption
- Cloud credentials: AWS, Azure, GCP authentication
- SCM credentials: Git, SVN authentication
- Custom credentials: User-defined credential types
Canonical Workflow
A typical “Getting Started with AWX” workflow involves:- Create a Project that imports playbooks from a remote git repository
- Create or import an Inventory which defines where the playbook(s) will run
- Save Credentials (optional) containing SSH authentication details
- Create a Job Template that specifies:
- Which Project and playbook to run
- Where to run it (Inventory)
- Any necessary Credentials
- Launch the Job Template and view the results
System Architecture
High-Level Components
Component Details
Web Layer
Technology Stack:- Backend: Django + Django REST Framework
- Frontend: React (ansible-ui)
- WebSockets: For real-time job output streaming
- User authentication and authorization
- RESTful API endpoints
- Real-time event streaming
- Static file serving
Database
PostgreSQL stores all AWX data:- User accounts and teams
- Inventories, hosts, and groups
- Projects and job templates
- Job history and results
- Credentials (encrypted)
- System configuration
Redis Cache
Redis provides:- Session storage
- Settings cache (for fast access)
- Distributed locking
- Callback event processing
Task Manager System
The Task Manager is responsible for:- Determining when tasks should run
- Managing task dependencies
- Checking capacity constraints
- Scheduling tasks to appropriate nodes
Dispatcher
The Dispatcher manages background task execution:- Runs on every AWX node
- Maintains a pool of worker processes
- Consumes tasks from queues
- Executes Python code for tasks
Receptor Mesh
Receptor provides mesh networking capabilities:- Connects AWX nodes in a cluster
- Routes work to execution nodes
- Provides secure, scalable communication
- Supports hybrid and hop nodes
AWX’s Interaction with Ansible
AWX interacts with Ansible primarily when executing automation:Job Execution Events
- Job Template Launch
- Project Update
- Inventory Sync
- Ad Hoc Command
Spawning Ansible Processes
When a Job Template or Project Update runs:- An actual
ansible-playbookcommand is composed - The process is spawned in a container/pod
- The process runs until completion or timeout
- Return code,
stdout, andstderrare recorded
- CLI arguments for
ansible-playbookandansible-inventory - Task execution behavior
- Prompts (password, become, Vault)
Capturing Event Data
AWX applies an Ansible callback plugin to all spawned processes:- Captures and persists events to the database
- Drives the “streaming” web UI
- Relies on stability in plugin interface and event structure
Fact Caching
AWX provides custom fact caching:- Uses the
jsonfilefact cache plugin - After
ansible-playbookexits, AWX consumes the cache - Facts are persisted in the AWX database
- On subsequent runs, caches are restored to the filesystem
Environment-Based Configuration
AWX injects credentials and configuration via environment variables: Examples:ANSIBLE_NET_*- Network device authenticationAWS_ACCESS_KEY_ID- AWS credentialsGCE_EMAIL- Google Cloud credentialsANSIBLE_SSH_CONTROL_PATH- SSH configuration
Node Types
AWX supports different node types in a cluster:Hybrid Nodes
- Run both control and execution tasks
- Handle web requests and run jobs
- Default node type
Control Nodes
- Run only control plane tasks
- Handle web requests, API, task management
- Do not execute jobs directly
Execution Nodes
- Run only job execution tasks
- Execute playbooks and ad hoc commands
- Connected via Receptor mesh
Hop Nodes
- Route traffic between nodes
- Do not run control or execution tasks
- Enable complex network topologies
Job Lifecycle
Understanding the job lifecycle is crucial for debugging:| Status | Description |
|---|---|
| pending | Job has been launched but: 1. Hasn’t been seen by scheduler 2. Is blocked by another task 3. Not enough capacity |
| waiting | Job submitted to dispatcher via pg_notify |
| running | Job is running on an AWX node |
| successful | Job finished with ansible-playbook return code 0 |
| failed | Job finished with ansible-playbook return code ≠ 0 |
| error | System failure (not playbook failure) |
| canceled | Job was manually canceled |
Clustering Architecture
Horizontal Scaling
AWX supports clustering for:- High availability: No single point of failure
- Load distribution: Spread work across nodes
- Capacity scaling: Add nodes to increase capacity
Cluster Communication
Database: Shared state and coordination- All nodes connect to same PostgreSQL
- Distributed locking via database
- Each node runs local Redis
- Used for callback events and settings cache
- Secure node-to-node communication
- Work routing to execution nodes
- Resilient to network partitions
Heartbeat and Capacity
Each node periodically:- Updates its heartbeat timestamp
- Calculates and reports capacity
- Checks health of peer nodes
- Reaps orphaned jobs from dead nodes
Security Architecture
Credential Encryption
Credentials are encrypted at rest:- Field-level encryption in database
- Encryption keys managed securely
- Credentials injected at job runtime
Role-Based Access Control (RBAC)
AWX implements comprehensive RBAC:- Users, Teams, and Organizations
- Resource-level permissions
- Role inheritance
- Audit logging via Activity Stream
Network Security
- HTTPS for web traffic
- TLS for Receptor mesh
- SSH key-based authentication for hosts
- Support for credential vaults (HashiCorp, CyberArk)
Data Flow Example
Here’s what happens when you launch a Job Template:-
User clicks “Launch” in UI
- API receives POST request
- Creates Job record in database (status: pending)
-
Dependency Manager runs
- Checks if project update needed
- Creates project update job if needed
- Links dependencies
-
Task Manager runs
- Finds pending jobs
- Checks dependencies satisfied
- Checks capacity available
- Selects execution node
- Changes job status to waiting
- Publishes task to dispatcher
-
Dispatcher receives task
- Worker process picks up task
- Imports task code (RunJob)
- Executes run() method
-
Job execution (via Ansible Runner)
- Prepares ansible-playbook command
- Injects credentials and configuration
- Spawns ansible-playbook process
- Callback plugin streams events
-
Event processing
- Events published to Redis
- Callback receiver consumes events
- Events saved to database
- WebSocket broadcasts to UI
-
Job completion
- Process exits
- Final status recorded
- Cleanup tasks run
- Dependent jobs may start
Performance Considerations
Capacity Management
- Each node has configurable capacity
- Jobs consume capacity based on forks
- Task manager respects capacity limits
- One job always allowed per instance group
Database Optimization
- Indexes on frequently queried fields
- Periodic cleanup of old job data
- Connection pooling (optional pgbouncer)
Caching Strategy
- Settings cached in Redis
- Fact caching for playbook runs
- Project SCM caching