awx.awx.token module – create, update, or destroy Automation Platform Controller tokens.
Note
This module is part of the awx.awx collection (version 19.4.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install awx.awx
.
To use it in a playbook, specify: awx.awx.token
.
New in version 2.3.0: of awx.awx
Synopsis
Create or destroy Automation Platform Controller tokens. See https://www.ansible.com/tower for an overview.
In addition, the module sets an Ansible fact which can be passed into other controller modules as the parameter controller_oauthtoken. See examples for usage.
Because of the sensitive nature of tokens, the created token value is only available once through the Ansible fact. (See RETURN for details)
Due to the nature of tokens this module is not idempotent. A second will with the same parameters will create a new token.
If you are creating a temporary token for use with modules you should delete the token when you are done with it. See the example for how to do it.
Parameters
Parameter |
Comments |
---|---|
The application tied to this token. |
|
Path to the controller config file. If provided, the other locations for config files will not be considered. |
|
URL to your Automation Platform Controller instance. If value not set, will try environment variable If value not specified by any means, the value of |
|
The OAuth token to use. This value can be in one of two formats. A string which is the token itself. (i.e. bqV5txm97wqJqtkxlMkhQz0pKhRMMX) A dictionary structure as returned by the token module. If value not set, will try environment variable |
|
Password for your controller instance. If value not set, will try environment variable |
|
Username for your controller instance. If value not set, will try environment variable |
|
Optional description of this access token. Default: “” |
|
The data structure produced from token in create mode to be used with state absent. |
|
A token ID (number) which can be used to delete an arbitrary token with state absent. |
|
Allowed scopes, further restricts user’s permissions. Must be a simple space-separated string with allowed scopes [‘read’, ‘write’]. Choices:
|
|
Desired state of the resource. Choices:
|
|
Whether to allow insecure connections to AWX. If This should only be used on personally controlled sites using self-signed certificates. If value not set, will try environment variable Choices:
|
Notes
Note
If no config_file is provided we will attempt to use the tower-cli library defaults to find your host information.
config_file should be in the following format host=hostname username=username password=password
Examples
- block:
- name: Create a new token using an existing token
token:
description: '{{ token_description }}'
scope: "write"
state: present
controller_oauthtoken: "{{ my_existing_token }}"
- name: Delete this token
token:
existing_token: "{{ token }}"
state: absent
- name: Create a new token using username/password
token:
description: '{{ token_description }}'
scope: "write"
state: present
controller_username: "{{ my_username }}"
controller_password: "{{ my_password }}"
- name: Use our new token to make another call
job_list:
controller_oauthtoken: "{{ token }}"
always:
- name: Delete our Token with the token we created
token:
existing_token: "{{ token }}"
state: absent
when: token is defined
- name: Delete a token by its id
token:
existing_token_id: 4
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
An Ansible Fact variable representing a token object which can be used for auth in subsequent modules. See examples for usage. Returned: on successful create |
|
The numeric ID of the token created Returned: success |
|
The token that was generated. This token can never be accessed again, make sure this value is noted before it is lost. Returned: success |
Authors
John Westcott IV (@john-westcott-iv)