awx.awx.token – create, update, or destroy Automation Platform Controller tokens.

Note

This plugin is part of the awx.awx collection (version 19.2.2).

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 Choices/Defaults Comments
application
string
The application tied to this token.
controller_config_file
path
Path to the controller config file.
If provided, the other locations for config files will not be considered.

aliases: tower_config_file
controller_host
string
URL to your Automation Platform Controller instance.
If value not set, will try environment variable CONTROLLER_HOST and then config files
If value not specified by any means, the value of 127.0.0.1 will be used

aliases: tower_host
controller_oauthtoken
raw
added in 3.7.0 of awx.awx
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 CONTROLLER_OAUTH_TOKEN and then config files

aliases: tower_oauthtoken
controller_password
string
Password for your controller instance.
If value not set, will try environment variable CONTROLLER_PASSWORD and then config files

aliases: tower_password
controller_username
string
Username for your controller instance.
If value not set, will try environment variable CONTROLLER_USERNAME and then config files

aliases: tower_username
description
string
Default:
""
Optional description of this access token.
existing_token
dictionary
The data structure produced from token in create mode to be used with state absent.
existing_token_id
string
A token ID (number) which can be used to delete an arbitrary token with state absent.
scope
string
    Choices:
  • read
  • write ←
Allowed scopes, further restricts user's permissions. Must be a simple space-separated string with allowed scopes ['read', 'write'].
state
string
    Choices:
  • present ←
  • absent
Desired state of the resource.
validate_certs
boolean
    Choices:
  • no
  • yes
Whether to allow insecure connections to AWX.
If no, SSL certificates will not be validated.
This should only be used on personally controlled sites using self-signed certificates.
If value not set, will try environment variable CONTROLLER_VERIFY_SSL and then config files

aliases: tower_verify_ssl

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 Returned Description
controller_token
dictionary
on successful create
An Ansible Fact variable representing a token object which can be used for auth in subsequent modules. See examples for usage.

 
id
string
success
The numeric ID of the token created

 
token
string
success
The token that was generated. This token can never be accessed again, make sure this value is noted before it is lost.



Authors

  • John Westcott IV (@john-westcott-iv)