Configuration¶
In Tower CLI, there are a number of configuration settings available to users. These settings are mostly used to set up connection details to Tower backend, like hostname of Tower backend and user name/password used for authentication; some are also used for other purposes, like toggle on/off colored stdout. Here is a list of all available Tower CLI settings:
Key | Value Type / Value Default | Description |
---|---|---|
color |
Boolean/’true’ | Whether to use colored output for highlighting or not. |
format |
String with options (‘human’, ‘json’, ‘yaml’)/’human’ | Output format. The “human” format is intended for humans reading output on the CLI; the “json” and “yaml” formats provide more data. [CLI use only] |
host |
String/‘127.0.0.1’ | The location of the Ansible Tower host. HTTPS is assumed as the protocol unless “http://” is explicitly provided. |
password |
String/’‘ | Password to use to authenticate to Ansible Tower. |
username |
String/’‘ | Username to use to authenticate to Ansible Tower. |
verify_ssl |
Boolean/’true’ | Whether to force verified SSL connections. |
verbose |
Boolean/’false’ | Whether to show information about requests being made. |
description_on |
Boolean/’false’ | Whether to show description in human-formatted output. [CLI use only] |
certificate |
String/’‘ | Path to a custom certificate file that will be used throughout the command. Ignored if –insecure flag if set in command or verify_ssl is set to false |
use_token |
Boolean/’false’ | Whether to use token-based authentication. No longer supported in Tower 3.3 and above |
Note: Some settings are marked as ‘CLI use only’, this means although users are free to set values to those settings, those settings only affect CLI but not API usage.
-
class
tower_cli.conf.
Settings
[source]¶ A class that understands configurations provided to tower-cli through configuration files or runtime parameters. A signleton object
tower_cli.conf.settings
will be instantiated and used.The 5 levels of precedence for settings, listing from least to greatest, are:
- defaults: Default values provided
- global: Contents parsed from .ini-formatted file
/etc/tower/tower_cli.cfg
if exists. - user: Contents parsed from .ini-formatted file
~/.tower_cli.cfg
if exists. - local: Contents parsed from .ini-formatted file
.tower_cli.cfg
if exists in the present working directory or any parent directories. - environment: Values from magic environment variables.
- runtime: keyworded arguments provided by
settings.runtime_values
context manager.
Note that .ini configuration file should follow the specified format in order to be correctly parsed:
[general] <configuration name 1> = <value 1> <configuration name 2> = <value 2> ...
-
runtime_values
(**kwds)[source]¶ Context manager that temporarily override runtime level configurations.
Parameters: kwargs (arbitrary keyword arguments) – Keyword arguments specifying runtime configuration settings. Returns: N/A Example: >>> import tower_cli >>> from tower_cli.conf import settings >>> with settings.runtime_values(username='user', password='pass'): >>> print(tower_cli.get_resource('credential').list())