Ansible Tower CLI (tower-cli) is a command-line interface tool for interacting with Ansible Tower and AWX instances. It allows users to manage resources like job templates, inventories, and projects directly from the terminal, and also provides a programmatic interface for Python scripts. The library is currently at version 3.3.9 and receives regular updates, typically with several minor releases focusing on bug fixes and new features throughout the year.
pip install ansible-tower-cliVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `ansible-tower-cli` programmatically within a Python script. It relies on environment variables (`TOWER_HOST`, `TOWER_TOKEN`, `TOWER_VERIFY_SSL`) for configuration, which is the recommended approach for secure and flexible scripting. It then fetches and prints the first five job templates from the configured Tower/AWX instance. Ensure you have your instance details and API token set as environment variables before running.
Explicitly set `TOWER_VERIFY_SSL=False` in your environment variables, or use `--insecure` flag on the CLI, or ensure your Python environment trusts the SSL certificate of your Tower/AWX instance.
Use `tower-cli login` to obtain an API token and then set the `TOWER_TOKEN` environment variable for your CLI or programmatic interactions. Avoid embedding `--username` and `--password` directly in scripts or command lines.
For transient or script-specific configurations, rely primarily on environment variables (`TOWER_HOST`, `TOWER_TOKEN`, etc.) which are picked up automatically by `tower_cli`. If you must modify settings in code, consider explicitly resetting or managing the config file location if persistence is not desired.