Skip to content

thinktankmachine/awx_rust_cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWX Rust CLI

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.

Features

  • 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.

Prerequisites

  • Rust and Cargo installed (see rustup.rs)
  • Access to an Ansible AWX instance.

Installation & Configuration

  1. Clone the repository:

    git clone https://github.com/thinktankmachine/awx_rust_cli.git
    cd awx_rust_cli
  2. Configuration: This tool is configured via environment variables. Create a .env file 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 .env with 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"
  3. 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.

Usage

Here are some examples of how to use the CLI.

List all Projects

cargo run -- project list

Sync a Specific Project (and wait for completion)

# By name
cargo run -- project sync --name "My Project Name"

# By ID
cargo run -- project sync --id 12

Launch a Job Template

cargo 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.

Export a Job Template to a file

cargo run -- job-template export --name "My Deploy Job" --output-file my_deploy_job.json

Import a Job Template from a file

This 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"

Get the stdout for a specific job run

# 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 54321

License

This project is licensed under the GPLv3 License - see the LICENSE file for details.

About

A Rust-based CLI for interacting with the Ansible AWX API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages