Authentication
The AWX CLI requires authentication to interact with AWX or Ansible Automation Platform instances. There are several methods to provide credentials.Command-Line Authentication
Provide credentials directly with each command:Environment Variables
Set environment variables for persistent authentication:For backward compatibility,
TOWER_HOST, TOWER_USERNAME, and TOWER_PASSWORD are also supported but deprecated.Credential Files
The CLI can load credentials from a configuration file. Create a credentials file:Authentication Methods
Session-Based Authentication (Default)
By default, the CLI uses session-based authentication, which is more efficient for multiple commands:~/.awx/sessions/ and automatically managed.
Basic Authentication
For environments like AAP Gateway where session login is restricted, force Basic authentication:Connection Settings
Host Configuration
Specify the AWX/AAP host URL:https://127.0.0.1:443
SSL Certificate Verification
By default, SSL certificates are verified. For self-signed certificates or testing:API Base Path
For Red Hat Ansible Automation Platform 2.5+, set the API base path:/api/
Output Formatting
Format Options
The CLI supports multiple output formats: JSON (default)Filter Output
Use the--filter flag to select specific fields:
Color Output
Control colored output:Verbose Output
Enable debug logging to see HTTP requests:Configuration Priority
When multiple configuration sources are present, they are evaluated in this order (highest to lowest priority):- Command-line flags (
--conf.*) - Environment variables (
CONTROLLER_*) - Credential files (
AWXKIT_CREDENTIAL_FILE) - Default values
Complete Configuration Example
Create a comprehensive shell configuration:Verify Configuration
To verify your current configuration:- Base URL
- Session authentication status
- Current credentials (username only, not password)
Environment Variable Reference
Command-Line Flag Reference
Troubleshooting
Connection Errors
Error: Connection refusedAuthentication Errors
Error: Unauthorized (401)AAP 2.5+ Path Issues
Error: Unable to fetch /api/v2/Security Best Practices
- Never commit credentials to version control
- Use environment variables instead of command-line flags in scripts (flags may appear in process lists)
- Restrict credential file permissions:
chmod 600 ~/.awx/credentials.yml - Use separate credentials for automation vs. interactive use
- Enable SSL verification in production environments
- Rotate passwords regularly
- Use RBAC to limit CLI user permissions to only what’s needed