controller_token, alias tower_token

This commit is contained in:
Seth Foster 2021-06-18 17:24:16 -04:00 committed by Shane McDonald
parent ab40006535
commit bb3fc3caa8
No known key found for this signature in database
GPG Key ID: 6F374AF6E9EB9374
2 changed files with 12 additions and 9 deletions

View File

@ -103,7 +103,7 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
tower_token: controller_token:
type: dict type: dict
description: An Ansible Fact variable representing a token object which can be used for auth in subsequent modules. See examples for usage. description: An Ansible Fact variable representing a token object which can be used for auth in subsequent modules. See examples for usage.
contains: contains:
@ -114,6 +114,8 @@ tower_token:
description: The numeric ID of the token created description: The numeric ID of the token created
type: str type: str
returned: on successful create returned: on successful create
aliases:
- tower_token
''' '''
from ..module_utils.controller_api import ControllerAPIModule from ..module_utils.controller_api import ControllerAPIModule
@ -125,6 +127,7 @@ def return_token(module, last_response):
# This method will return the entire token object we got back so that a user has access to the token # This method will return the entire token object we got back so that a user has access to the token
module.json_output['ansible_facts'] = { module.json_output['ansible_facts'] = {
'controller_token': last_response,
'tower_token': last_response, 'tower_token': last_response,
} }
module.exit_json(**module.json_output) module.exit_json(**module.json_output)

View File

@ -63,21 +63,21 @@
- name: Validate our token works by token - name: Validate our token works by token
job_list: job_list:
controller_oauthtoken: "{{ tower_token.token }}" controller_oauthtoken: "{{ controller_token.token }}"
register: job_list register: job_list
- name: Validate our token works by object - name: Validate our token works by object
job_list: job_list:
controller_oauthtoken: "{{ tower_token }}" controller_oauthtoken: "{{ controller_token }}"
register: job_list register: job_list
always: always:
- name: Delete our Token with our own token - name: Delete our Token with our own token
token: token:
existing_token: "{{ tower_token }}" existing_token: "{{ controller_token }}"
controller_oauthtoken: "{{ tower_token }}" controller_oauthtoken: "{{ controller_token }}"
state: absent state: absent
when: tower_token is defined when: controller_token is defined
register: results register: results
- assert: - assert:
@ -99,10 +99,10 @@
always: always:
- name: Delete the second Token with our own token - name: Delete the second Token with our own token
token: token:
existing_token_id: "{{ tower_token['id'] }}" existing_token_id: "{{ controller_token['id'] }}"
controller_oauthtoken: "{{ tower_token }}" controller_oauthtoken: "{{ controller_token }}"
state: absent state: absent
when: tower_token is defined when: controller_token is defined
register: results register: results
- assert: - assert: