### Get AWX CLI Help for Creating a Resource Source: https://github.com/ansible/awx/blob/devel/awxkit/awxkit/cli/docs/source/usage.rst This command shows the specific arguments and options required to create a new instance of a resource, using 'users create' as an example. ```bash awx --conf.host https://awx.example.org users create --help ``` -------------------------------- ### Install Setuptools Source: https://github.com/ansible/awx/blob/devel/docs/docsite/rst/contributor/setting_up.rst Install the setuptools package, which is essential for building and distributing Python packages. This command installs it using pip3. ```bash pip3 install setuptools ``` -------------------------------- ### Start Minikube with Volume Mount Source: https://github.com/ansible/awx/blob/devel/docs/development/minikube.md Starts Minikube with a specified volume mount for AWX development code and enables the ingress addon. Ensure Minikube is installed and tested on Linux. ```bash minikube start \ --mount \ --mount-string="/path/to/awx:/awx_devel" \ --cpus=4 \ --memory=8g \ --addons=ingress ``` -------------------------------- ### Install Requirements Source: https://github.com/ansible/awx/blob/devel/tools/community-bugscrub/README.md Install the necessary Python packages for the script by running this command. ```bash pip install -r requirements.txt ``` -------------------------------- ### Install AWX CLI using pip Source: https://github.com/ansible/awx/blob/devel/INSTALL.md Install the AWX command-line client directly from PyPI. This is the preferred method for installation. ```bash pip3 install awxkit awx --help ``` -------------------------------- ### Verify Setuptools Installation Source: https://github.com/ansible/awx/blob/devel/docs/docsite/rst/contributor/setting_up.rst Confirm that the setuptools package has been installed successfully. Running this Python command will not produce any output if the installation was successful. ```python python3 -c 'import setuptools' ``` -------------------------------- ### Example Query for vmware_guest Module Source: https://github.com/ansible/awx/blob/devel/docs/indirect_node_counting/external_query_files.md An example of a query file entry for the community.vmware.vmware_guest module, extracting instance name, UUID, and guest ID. ```yaml --- community.vmware.vmware_guest: query: >- {name: .instance.hw_name, canonical_facts: {host_name: .instance.hw_name, uuid: .instance.hw_product_uuid}, facts: {guest_id: .instance.hw_guest_id}} ``` -------------------------------- ### Job Temporary Directory Structure Source: https://github.com/ansible/awx/blob/devel/docs/collections.md Example structure of the job's temporary directory, showing installed collections and roles. ```tree ├── requirements_collections │ └── ansible_collections │ └── namespace │ └── collection_name │ ├── FILES.json │ ├── MANIFEST.json │ ├── README.md │ ├── roles │ │ ├── role_in_collection_name │ │ │ ├── defaults │ │ │ │ └── main.yml │ │ │ ├── tasks │ │ │ │ └── main.yml │ │ │ └── templates │ │ │ └── stuff.j2 │ └── tests │ └── main.yml └── requirements_roles └── namespace.role_name ├── defaults │ └── main.yml ├── meta │ └── main.yml ├── README.md ├── tasks │ ├── main.yml │ └── some_role.yml ├── templates │ └── stuff.j2 └── vars └── Archlinux.yml ``` -------------------------------- ### Install and Configure Sosreport Controller Plugin Source: https://github.com/ansible/awx/blob/devel/tools/sosreport/TESTING.md Follow these steps to install the controller plugin for sosreport. This involves creating directories, installing sos, copying the plugin file, setting permissions, and creating a symbolic link. ```bash sudo mkdir -p /usr/share/sosreport/sos/plugins sudo yum install sos cp controller.py /usr/share/sosreport/sos/plugins sudo chmod 644 /usr/share/sosreport/sos/plugins/controller.py ln -s /usr/share/sosreport/sos/plugins/controller.py `find `find /usr/lib -name sos` -name plugins` ``` -------------------------------- ### Start AWX with Minikube (Default) Source: https://github.com/ansible/awx/blob/devel/tools/docker-compose/README.md Launches a 1-node AWX instance integrated with Minikube, accessible from AWX. This command requires Minikube to be started separately with specified resources and the ingress addon. ```bash (host)$minikube start --cpus=4 --memory=8g --addons=ingress ``` ```bash (host)$ make docker-compose-container-group ``` -------------------------------- ### External Query File Naming Examples Source: https://github.com/ansible/awx/blob/devel/docs/indirect_node_counting/external_query_files.md Provides concrete examples of valid external query file names. ```text community.vmware.4.5.0.yml ``` ```text cisco.ios.8.0.0.yml ``` ```text amazon.aws.7.2.1.yml ``` -------------------------------- ### Set up Virtual Environment for AWX Collection Tests Source: https://github.com/ansible/awx/blob/devel/awx_collection/README.md Instructions for setting up a Python virtual environment and installing dependencies to run AWX collection unit tests. This includes installing from requirements files and the AWX collection itself. ```bash mkvirtualenv my_new_venv # may need to replace psycopg3 with psycopg3-binary in requirements/requirements.txt pip install -r requirements/requirements.txt -r requirements/requirements_dev.txt -r requirements/requirements_git.txt make clean-api pip install -e pip install -e . pip install -e awxkit py.test awx_collection/test/awx/ ``` -------------------------------- ### Start AWX Docker Compose Source: https://github.com/ansible/awx/blob/devel/tools/docker-compose/README.md Use this command to start the AWX, postgres, and redis containers. It utilizes the built image and automatically starts all required services. Your session will be attached to the AWX container for real-time log monitoring. ```bash make docker-compose ``` -------------------------------- ### Start AWX with Minikube (Environment Variable) Source: https://github.com/ansible/awx/blob/devel/tools/docker-compose/README.md Starts AWX with Minikube using an environment variable for configuration. This method allows for additional environment flags, such as cluster node count, to be applied. ```bash (host)$ MINIKUBE_CONTAINER_GROUP=true make docker-compose ``` -------------------------------- ### Histogram Metric Data Example Source: https://github.com/ansible/awx/blob/devel/docs/subsystem_metrics.md Example output showing cumulative bucket counts for batch-inserted database events. ```text callback_receiver_batch_events_insert_db_bucket{le="10",node="awx_1"} 1 callback_receiver_batch_events_insert_db_bucket{le="50",node="awx_1"} 5 callback_receiver_batch_events_insert_db_bucket{le="150",node="awx_1"} 5 callback_receiver_batch_events_insert_db_bucket{le="350",node="awx_1"} 5 callback_receiver_batch_events_insert_db_bucket{le="650",node="awx_1"} 5 callback_receiver_batch_events_insert_db_bucket{le="2000",node="awx_1"} 5 callback_receiver_batch_events_insert_db_bucket{le="+Inf",node="awx_1"} 5 callback_receiver_batch_events_insert_db_count{node="awx_1"} 5 callback_receiver_batch_events_insert_db_sum{node="awx_1"} 5 ``` -------------------------------- ### Start HashiVault Instance with Docker Compose Source: https://github.com/ansible/awx/blob/devel/tools/docker-compose/README.md Run this command to start a HashiVault container alongside AWX. Ensure the VAULT environment variable is set to true. ```bash VAULT=true make docker-compose ``` -------------------------------- ### Complete External Query File Example Source: https://github.com/ansible/awx/blob/devel/docs/indirect_node_counting/external_query_files.md A complete example of an external query file for the community.vmware.vmware_guest module, version 4.5.0, extracting VM information including CPU count. ```yaml --- # Query for vmware_guest module - extracts VM information community.vmware.vmware_guest: query: >- {name: .instance.hw_name, canonical_facts: {host_name: .instance.hw_name, uuid: .instance.hw_product_uuid}, facts: {guest_id: .instance.hw_guest_id, num_cpus: .instance.hw_processor_count}} ``` -------------------------------- ### Install Tox Source: https://github.com/ansible/awx/blob/devel/docs/docsite/rst/contributor/setting_up.rst Install the tox package, a generic virtual environment management and test command line tool. It is required for building AWX documentation locally. ```bash pip3 install tox ``` -------------------------------- ### Build and start AWX development environment containers Source: https://github.com/ansible/awx/blob/devel/tools/docker-compose/docs/data_migration.md After migrating data, build the Docker images and start the AWX development environment containers. This step ensures the new environment is ready to use the migrated data. ```bash $ make docker-compose-build $ make docker-compose $ make ui ``` -------------------------------- ### Start Docker Compose for ELK Stack Source: https://github.com/ansible/awx/blob/devel/docs/logging_integration.md Use these Makefile targets to start the Logstash, Elastic Search, and Kibana services for development. These commands also establish connections to the `tower_tools` containers. ```bash make docker-compose-elk ``` ```bash make docker-compose-cluster-elk ``` -------------------------------- ### Install Pre-commit Hook Source: https://github.com/ansible/awx/blob/devel/CONTRIBUTING.md Run this command to install the pre-commit hook. This hook will automatically run code formatting and other checks before allowing a git commit. ```bash make pre-commit ``` -------------------------------- ### Execute Integration Tests Source: https://github.com/ansible/awx/blob/devel/awx_collection/README.md Navigate to the collection installation directory and run the integration test suite. ```bash # ansible-test must be run from the directory in which the collection is installed cd ~/.ansible/collections/ansible_collections/awx/awx/ ansible-test integration ``` -------------------------------- ### Start Splunk Instance with Docker Compose Source: https://github.com/ansible/awx/blob/devel/tools/docker-compose/README.md Use this command to start a Splunk instance alongside AWX using Docker Compose. Ensure the SPLUNK environment variable is set to true. ```bash SPLUNK=true make docker-compose ``` -------------------------------- ### Get Script Usage Source: https://github.com/ansible/awx/blob/devel/tools/community-bugscrub/README.md Display the command-line arguments and options available for the script. ```bash python generate-sheet.py -h ``` -------------------------------- ### Create and Launch Job Template Source: https://github.com/ansible/awx/blob/devel/awxkit/awxkit/cli/docs/source/examples.rst Sets up a project from a Git repository, creates a job template, and launches it with monitoring. ```bash awx projects create --wait \ --organization 1 --name='Example Project' \ --scm_type git --scm_url 'https://github.com/ansible/ansible-tower-samples' \ -f human awx job_templates create \ --name='Example Job Template' --project 'Example Project' \ --playbook hello_world.yml --inventory 'Demo Inventory' \ -f human awx job_templates launch 'Example Job Template' --monitor -f human ``` -------------------------------- ### Configure ASGI and WSGI Application Servers Source: https://github.com/ansible/awx/blob/devel/docs/docsite/rst/contributor/DJANGO_REQUIREMENTS.rst Standard entry point configurations for production application servers. Both require calling prepare_env() before initializing the application. ```python # asgi.py import os import django from channels.routing import get_default_application from awx import prepare_env prepare_env() django.setup() application = get_default_application() # wsgi.py import os from django.core.wsgi import get_wsgi_application from awx import prepare_env prepare_env() application = get_wsgi_application() ``` -------------------------------- ### Load Demo Data Source: https://github.com/ansible/awx/blob/devel/tools/docker-compose/README.md Populate the database with a sample project, inventory, and job template. ```bash $ docker exec tools_awx_1 awx-manage create_preload_data ``` -------------------------------- ### Start a 3-Node AWX Cluster Source: https://github.com/ansible/awx/blob/devel/tools/docker-compose/README.md Initiates a 3-node AWX cluster development environment. The `CONTROL_PLANE_NODE_COUNT` variable can be adjusted to configure the number of nodes, defaulting to 1 for a non-clustered setup. ```bash (host)$ CONTROL_PLANE_NODE_COUNT=3 make docker-compose ``` -------------------------------- ### Create Organization Example Source: https://github.com/ansible/awx/blob/devel/awx/main/tests/factories/README.md Demonstrates creating an organization with a specified name. The organization object is returned. ```python objects = create_organization('test-org') assert objects.organization.name == 'test-org' ``` -------------------------------- ### Install Collections from Requirements File Source: https://github.com/ansible/awx/blob/devel/docs/collections.md Command to install Ansible collections specified in a requirements file. Use the `-p` flag to specify the installation path within the project's cache. ```bash ansible-galaxy collection install -r requirements.yml -p /___/stage/requirements_collections ``` -------------------------------- ### Bootstrap AWX Development Environment Source: https://github.com/ansible/awx/blob/devel/tools/docker-compose/README.md Run this command inside the AWX container to perform initial setup tasks, including database migrations. This may take a few minutes to complete. ```bash (container)# /usr/bin/bootstrap_development.sh ``` -------------------------------- ### Build and Serve AWX Documentation Source: https://github.com/ansible/awx/blob/devel/awxkit/awxkit/cli/docs/README.md Commands to clean, build, and serve the documentation locally using a running AWX server. ```bash CONTROLLER_HOST=https://awx.example.org CONTROLLER_USERNAME=example CONTROLLER_PASSWORD=secret make clean html ``` ```bash cd build/html/ && python -m http.server ``` -------------------------------- ### Create Organization with Projects Example Source: https://github.com/ansible/awx/blob/devel/awx/main/tests/factories/README.md Shows how to create an organization and associate it with projects. The returned object contains the organization and its projects. ```python objects = create_organization('test-org', projects=['test-proj']) assert objects.projects.test-proj.organization == objects.organization ``` -------------------------------- ### Install openshift Python Package Source: https://github.com/ansible/awx/blob/devel/docs/development/kind.md Installs the necessary openshift Python package required for AWX operator deployment. ```bash pip install openshift ``` -------------------------------- ### Install Docker Compose Source: https://github.com/ansible/awx/blob/devel/CONTRIBUTING.md Use this command to install the docker-compose Python module if you are not using Docker for Mac or Windows. ```bash (host)$ pip3 install docker-compose ``` -------------------------------- ### Verify Host Matching via GET Source: https://github.com/ansible/awx/blob/devel/awx/api/templates/api/job_template_callback.md Perform an authenticated GET request to identify which hosts will be selected by the callback. ```bash curl http://user:password@server/api/v2/job_templates/N/callback/ ``` -------------------------------- ### Modular API Structure Example Source: https://github.com/ansible/awx/blob/devel/docs/docsite/rst/contributor/API_REQUIREMENTS.rst Illustrates a recommended directory structure for organizing API components, promoting separation of concerns and maintainability. ```text api/ ├── __init__.py ├── authentication.py # Custom authentication classes ├── permissions.py # Permission and access control ├── serializers.py # Base serializer patterns ├── generics.py # Custom view classes ├── pagination.py # Pagination strategies ├── renderers.py # Response formatters ├── fields.py # Custom field types ├── exceptions.py # Custom exception classes ├── metadata.py # Field metadata for clients ├── urls/ # Resource-specific URL modules │ ├── __init__.py │ ├── organization.py │ ├── user.py │ ├── project.py │ └── job_template.py └── views/ # Resource-specific view modules ├── __init__.py ├── organization.py └── user.py ``` -------------------------------- ### Requesting Specific Page and Size Source: https://github.com/ansible/awx/blob/devel/docs/docsite/rst/rest_api/pagination.rst Example URL demonstrating the use of page_size and page query parameters. ```text http:///api/v2/model_verbose_name?page_size=100&page=2 ``` -------------------------------- ### GET /api/v2/jobs/{id}/cancelable Source: https://github.com/ansible/awx/blob/devel/awx/api/templates/api/job_cancel.md Determine if a Job can be canceled. Make a GET request to this resource to determine if the job can be canceled. ```APIDOC ## GET /api/v2/jobs/{id}/cancelable ### Description Determine if a Job can be canceled. ### Method GET ### Endpoint /api/v2/jobs/{id}/cancelable ### Response #### Success Response (200) - **can_cancel** (boolean) - Indicates whether this job can be canceled (read-only) #### Response Example { "can_cancel": true } ``` -------------------------------- ### Start Kind Cluster Source: https://github.com/ansible/awx/blob/devel/docs/development/kind.md Command to create a Kind Kubernetes cluster using a specified configuration file. ```bash kind create cluster --config kind-cluster.yaml ``` -------------------------------- ### Check Python and Pip Versions Source: https://github.com/ansible/awx/blob/devel/docs/docsite/rst/contributor/setting_up.rst Verify that Python 3 and pip 3 are correctly installed on your system. This is a prerequisite for installing other development tools. ```bash python3 --version pip3 --version ``` -------------------------------- ### Verify Sosreport Controller Plugin Installation Source: https://github.com/ansible/awx/blob/devel/tools/sosreport/TESTING.md After installation, verify that the controller plugin is recognized by sosreport. This command lists available plugins and filters for the controller. ```bash # sosreport -l | grep controller ``` ```bash controller Ansible Automation Platform controller information ``` -------------------------------- ### Build UI Source: https://github.com/ansible/awx/blob/devel/awx/ui/README.md Execute the 'make ui' command to build the user interface. ```bash make ui ``` -------------------------------- ### Install AWX CLI via pip Source: https://github.com/ansible/awx/blob/devel/awxkit/awxkit/cli/docs/source/install.rst Use this command to install the AWX CLI. Replace $VERSION with the specific release tag corresponding to your AWX instance. ```bash pip install "git+https://github.com/ansible/awx.git@$VERSION#egg=awxkit&subdirectory=awxkit" ``` -------------------------------- ### Basic AWX CLI Authentication and Listing Users Source: https://github.com/ansible/awx/blob/devel/awxkit/awxkit/cli/docs/source/usage.rst Example of connecting to an AWX server using host, username, password, and insecure flag, then listing users. Ensure to replace placeholders with your actual server details. ```bash awx --conf.host https://awx.example.org \ --conf.username joe --conf.password secret \ --conf.insecure \ users list ``` -------------------------------- ### Start AWX Docker Compose in Detached Mode Source: https://github.com/ansible/awx/blob/devel/tools/docker-compose/README.md Run docker-compose in detached mode by passing the -d option via COMPOSE_UP_OPTS. This starts containers in the background. ```bash make docker-compose COMPOSE_UP_OPTS=-d ``` -------------------------------- ### Exact Module Match Example Source: https://github.com/ansible/awx/blob/devel/docs/indirect_node_counting/external_query_files.md Demonstrates how to specify an exact match for a fully-qualified module name in a query file. ```yaml community.vmware.vmware_guest: query: >- ... ``` -------------------------------- ### Install gprof2dot for Profiling Source: https://github.com/ansible/awx/blob/devel/docs/debugging/debugging_misc.md To enable dot graph generation for profiling data, install the `gprof2dot` package using pip. If this package is not found, profiling will run with `dot_enabled=False`. ```bash /var/lib/awx/venv/awx/bin/pip3 install gprof2dot ``` -------------------------------- ### Start AWX Container Shell Source: https://github.com/ansible/awx/blob/devel/tools/docker-compose/README.md Use this command to access the AWX container's shell without starting all services. This is useful for manual command execution within the container. ```bash (host)$ make docker-compose-test ``` -------------------------------- ### Build AWX Documentation Locally Source: https://github.com/ansible/awx/blob/devel/docs/docsite/rst/contributor/setting_up.rst Use the tox utility to build the AWX documentation on your local machine. Ensure you are in your forked branch of the AWX repository before running this command. ```bash tox -e docs ``` -------------------------------- ### Start AWX with OpenTelemetry Enabled Source: https://github.com/ansible/awx/blob/devel/tools/docker-compose/README.md Use this command to start the docker-compose environment with OpenTelemetry, Grafana, Loki, and Prometheus enabled. This configures AWX to send logs to the OpenTelemetry Collector sidecar. ```bash OTEL=true GRAFANA=true LOKI=true PROMETHEUS=true make docker-compose ``` -------------------------------- ### Wildcard Module Match Example Source: https://github.com/ansible/awx/blob/devel/docs/indirect_node_counting/external_query_files.md Shows how to use a wildcard to match all modules within a specific collection in a query file. ```yaml community.vmware.*: query: >- ... ``` -------------------------------- ### Register default execution environments Source: https://github.com/ansible/awx/blob/devel/docs/execution_environments.md Run this command during installation to populate the system with required global execution environments. ```bash awx-manage register_default_execution_environments ``` -------------------------------- ### Implement Custom Authentication Classes Source: https://github.com/ansible/awx/blob/devel/docs/docsite/rst/contributor/API_REQUIREMENTS.rst Provides examples for logging Basic Auth and handling session authentication. ```python # api/authentication.py class LoggedBasicAuthentication(authentication.BasicAuthentication): """Basic authentication with comprehensive logging""" def authenticate(self, request): if not settings.AUTH_BASIC_ENABLED: return ret = super().authenticate(request) if ret: username = ret[0].username if ret[0] else '' logger.info( f"User {username} performed {request.method} " f"to {request.path} through the API using Basic Auth" ) return ret class SessionAuthentication(authentication.SessionAuthentication): """Enhanced session authentication with CSRF handling""" def authenticate(self, request): # Custom session validation logic return super().authenticate(request) ``` -------------------------------- ### Build AWX CLI Documentation Source: https://github.com/ansible/awx/blob/devel/INSTALL.md Steps to build the AWX CLI documentation. Requires a running AWX server and specific Python packages. Set environment variables for host, username, and password. ```bash ~ cd awxkit/awxkit/cli/docs ~ TOWER_HOST=https://awx.example.org TOWER_USERNAME=example TOWER_PASSWORD=secret make clean html ~ cd build/html/ && python -m http.server ``` ```bash Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) .. ``` -------------------------------- ### POST /api/v2/job_templates/N/launch/ Source: https://github.com/ansible/awx/blob/devel/docs/credentials/multi_credential_assignment.md Launches a Job Template, providing necessary Vault passwords for credentials marked as 'Prompt on launch'. ```APIDOC ## POST /api/v2/job_templates/N/launch/ ### Description Launches a Job Template and provides the required passwords for Vault credentials. ### Method POST ### Endpoint /api/v2/job_templates/N/launch/ ### Request Body - **credential_passwords** (object) - Required - A mapping of Vault credential IDs to their respective passwords. ``` -------------------------------- ### POST /api/v2/config Source: https://github.com/ansible/awx/blob/devel/awx/api/templates/api/api_v2_config_view.md Installs or updates an existing license. ```APIDOC ## POST /api/v2/config ### Description Install or update an existing license. Make a POST request to this resource as a super user to install or update the existing license. The license data itself can be POSTed as a normal json data structure. The POST must include a `eula_accepted` boolean element indicating acceptance of the End-User License Agreement. ### Method POST ### Endpoint /api/v2/config ### Parameters #### Request Body - **license_data** (object) - Required - The license data structure. - **eula_accepted** (boolean) - Required - Indicates acceptance of the End-User License Agreement. ### Request Example ```json { "license_data": { "license_key": "YOUR_LICENSE_KEY_HERE" }, "eula_accepted": true } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "License installed successfully." } ``` ``` -------------------------------- ### GET /api/v2/credentials/N Source: https://github.com/ansible/awx/blob/devel/docs/credentials/custom_credential_types.md Retrieve details of a specific credential. ```APIDOC ## GET /api/v2/credentials/{id} ### Description Retrieve the details of a specific credential by its ID. ### Method GET ### Endpoint /api/v2/credentials/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The ID of the credential ### Response #### Success Response (200) - **name** (string) - Name of the credential - **inputs** (object) - The input values (secrets are masked) #### Response Example { "name": "Joe's Third Party Cloud API Token", "description": "", "organization": 1, "user": null, "team": null, "credential_type": 5, "inputs": { "api_token": "$encrypted$" } } ``` -------------------------------- ### GET /api/v2/me/ Source: https://github.com/ansible/awx/blob/devel/awx/api/templates/api/user_me_list.md Retrieves information about the currently authenticated user. ```APIDOC ## GET /api/v2/me/ ### Description Retrieves information about the current user. ### Method GET ### Endpoint /api/v2/me/ ### Response #### Success Response (200) - **result** (object) - Contains the user information fields. ``` -------------------------------- ### GET /stdout Source: https://github.com/ansible/awx/blob/devel/awx/api/templates/api/unified_job_stdout.md Retrieve the stdout from a running job or task. ```APIDOC ## GET /stdout ### Description Make a GET request to this resource to retrieve the stdout from running jobs. ### Method GET ### Endpoint /stdout ### Parameters #### Query Parameters - **format** (string) - Optional - Specifies output format: api, html, txt, ansi, json, txt_download, ansi_download. - **start_line** (integer) - Optional - Starting line number for the output range (Browsable API, HTML, and JSON only). - **end_line** (integer) - Optional - Ending line number for the output range (Browsable API, HTML, and JSON only). - **dark** (boolean) - Optional - Force (1) or disable (0) dark background. ### Response #### Success Response (200) - **stdout** (string) - The requested standard output content. ```