From bb3fc3caa86f56103be583900a5f6db57c53f6cb Mon Sep 17 00:00:00 2001 From: Seth Foster Date: Fri, 18 Jun 2021 17:24:16 -0400 Subject: [PATCH] controller_token, alias tower_token --- awx_collection/plugins/modules/token.py | 5 ++++- .../integration/targets/token/tasks/main.yml | 16 ++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/awx_collection/plugins/modules/token.py b/awx_collection/plugins/modules/token.py index 0df08e0c65..1de8fd088f 100644 --- a/awx_collection/plugins/modules/token.py +++ b/awx_collection/plugins/modules/token.py @@ -103,7 +103,7 @@ EXAMPLES = ''' ''' RETURN = ''' -tower_token: +controller_token: type: dict description: An Ansible Fact variable representing a token object which can be used for auth in subsequent modules. See examples for usage. contains: @@ -114,6 +114,8 @@ tower_token: description: The numeric ID of the token created type: str returned: on successful create + aliases: + - tower_token ''' 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 module.json_output['ansible_facts'] = { + 'controller_token': last_response, 'tower_token': last_response, } module.exit_json(**module.json_output) diff --git a/awx_collection/tests/integration/targets/token/tasks/main.yml b/awx_collection/tests/integration/targets/token/tasks/main.yml index 5efa9e37b3..f13bc6bc66 100644 --- a/awx_collection/tests/integration/targets/token/tasks/main.yml +++ b/awx_collection/tests/integration/targets/token/tasks/main.yml @@ -63,21 +63,21 @@ - name: Validate our token works by token job_list: - controller_oauthtoken: "{{ tower_token.token }}" + controller_oauthtoken: "{{ controller_token.token }}" register: job_list - name: Validate our token works by object job_list: - controller_oauthtoken: "{{ tower_token }}" + controller_oauthtoken: "{{ controller_token }}" register: job_list always: - name: Delete our Token with our own token token: - existing_token: "{{ tower_token }}" - controller_oauthtoken: "{{ tower_token }}" + existing_token: "{{ controller_token }}" + controller_oauthtoken: "{{ controller_token }}" state: absent - when: tower_token is defined + when: controller_token is defined register: results - assert: @@ -99,10 +99,10 @@ always: - name: Delete the second Token with our own token token: - existing_token_id: "{{ tower_token['id'] }}" - controller_oauthtoken: "{{ tower_token }}" + existing_token_id: "{{ controller_token['id'] }}" + controller_oauthtoken: "{{ controller_token }}" state: absent - when: tower_token is defined + when: controller_token is defined register: results - assert: