A command-line interface (CLI) written in Rust to interact with the Ansible AWX API. This tool helps automate common tasks like syncing projects, launching job templates, and managing resources.
- Manage AWX Projects (List, Sync, Get Revision)
- Manage Job Templates (List, Launch, Export, Import)
- Manage Inventory Sources (List, Sync)
- View Job Output (stdout) for various job types
- Securely handles AWX credentials using environment variables.
- Tabular output for lists.
- Rust and Cargo installed (see rustup.rs)
- Access to an Ansible AWX instance.
-
Clone the repository:
git clone https://github.com/thinktankmachine/awx_rust_cli.git cd awx_rust_cli -
Configuration: This tool is configured via environment variables. Create a
.envfile in the root of the project. This file is ignored by git and should never be committed.You can copy the example file:
cp .env.example .env
Now, edit
.envwith your AWX details:# awx_rust_cli/.env # The base URL of your AWX instance AWX_HOST="https://your-awx-instance.com" # Your personal access token from AWX # Go to Users -> (your user) -> Tokens to generate one AWX_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
-
Build the project: For development:
cargo build
For a release-optimized binary:
cargo build --release
The binary will be located at
target/release/awx_rust_cli.
Here are some examples of how to use the CLI.
cargo run -- project list# By name
cargo run -- project sync --name "My Project Name"
# By ID
cargo run -- project sync --id 12cargo run -- job-template launch --name "My Deploy Job"This will launch the job, wait for it to complete, print the full stdout of the job run, and exit with an error if the job failed.
cargo run -- job-template export --name "My Deploy Job" --output-file my_deploy_job.jsonThis will create the job template if it doesn't exist by name, or update it if it does.
cargo run -- job-template import --input-file my_deploy_job.json --organization "Default"# For a regular job
cargo run -- job stdout --job-type jobs --id 12345
# For a project update
cargo run -- job stdout --job-type project_updates --id 54321This project is licensed under the GPLv3 License - see the LICENSE file for details.