11. The awx-manage Utility
The awx-manage
utility is used to access detailed internal information of AWX. Commands for awx-manage
should run as the awx
user only.
Warning
Running awx-manage commands via playbook is not recommended or supported.
11.1. Inventory Import
awx-manage
is a mechanism by which an AWX administrator can import inventory directly into AWX, for those who cannot use Custom Inventory Scripts.
To use awx-manage
properly, you must first create an inventory in AWX to use as the destination for the import.
For help with awx-manage
, run the following command: awx-manage inventory_import [--help]
The inventory_import
command synchronizes an AWX inventory object with a text-based inventory file, dynamic inventory script, or a directory of one or more of the above as supported by core Ansible.
When running this command, specify either an --inventory-id
or --inventory-name
, and the path to the Ansible inventory source (--source
).
awx-manage inventory_import --source=/ansible/inventory/ --inventory-id=1
By default, inventory data already stored in AWX blends with data from the external source. To use only the external data, specify --overwrite
. To specify that any existing hosts get variable data exclusively from the --source
, specify --overwrite_vars
. The default behavior adds any new variables from the external source, overwriting keys that already exist, but preserves any variables that were not sourced from the external data source.
awx-manage inventory_import --source=/ansible/inventory/ --inventory-id=1 --overwrite
Note
Edits and additions to Inventory host variables persist beyond an inventory sync as long as --overwrite_vars
is not set.
11.2. Cleanup of old data
awx-manage
has a variety of commands used to clean old data from AWX. The AWX administrators can use the Management Jobs interface for access or use the command line.
awx-manage cleanup_jobs [--help]
This permanently deletes the job details and job output for jobs older than a specified number of days.
awx-manage cleanup_activitystream [--help]
11.3. Cluster management
Note
Do not run other awx-manage
commands unless instructed by Red Hat Ansible personnel.
11.4. Session management
11.4.1. expire_sessions
Use this command to terminate all sessions or all sessions for a specific user. Consider using this command when a user changes role in an organization, is removed from assorted groups in AD, or the administrator wants to ensure the user can no longer execute jobs due to membership in these groups.
$ awx-manage expire_sessions
This command terminates all sessions by default. The users associated with those sessions will be consequently logged out. To only expire the sessions of a specific user, you can pass their username using the --user
flag (specify actual username for example_user
below):
$ awx-manage expire_sessions --user example_user
11.4.2. clearsessions
Use this command to delete all sessions that have expired. Refer to Django’s documentation on clearsessions for more detail.
11.5. Analytics gathering
Use this command to gather analytics on-demand outside of the predefined window (default is 4 hours):
$ awx-manage gather_analytics --ship
For customers with disconnected environments who want to collect usage information about unique hosts automated across a time period, use this command:
awx-manage host_metric --since YYYY-MM-DD --until YYYY-MM-DD --json
The parameters --since
and --until
specify date ranges and are optional, but one of them has to be present. The --json
flag specifies the output format and is optional.