Updated docs and added block on tests

This commit is contained in:
John Westcott IV
2020-05-21 14:10:14 -04:00
parent e6416d770b
commit e50c8fc9c9
2 changed files with 38 additions and 32 deletions

View File

@@ -20,8 +20,9 @@ author: "John Westcott IV (@john-westcott-iv)"
version_added: "2.3" version_added: "2.3"
short_description: create, update, or destroy Ansible Tower tokens. short_description: create, update, or destroy Ansible Tower tokens.
description: description:
- Create, update, or destroy Ansible Tower tokens. See - Create or destroy Ansible Tower tokens. See
U(https://www.ansible.com/tower) for an overview. U(https://www.ansible.com/tower) for an overview.
- If you create a token it is your responsibility to delete the token.
options: options:
description: description:
description: description:
@@ -60,22 +61,24 @@ extends_documentation_fragment: awx.awx.auth
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: Create a new token using an existing token - block:
tower_token: - name: Create a new token using an existing token
description: '{{ token_description }}' tower_token:
scope: "write" description: '{{ token_description }}'
state: present scope: "write"
tower_oauthtoken: "{{ ny_existing_token }}" state: present
register: new_token tower_oauthtoken: "{{ ny_existing_token }}"
- name: Use our new token to make another call - name: Use our new token to make another call
tower_job_list: tower_job_list:
tower_oauthtoken: "{{ tower_token }}" tower_oauthtoken: "{{ tower_token }}"
- name: Delete our Token with the token we created always:
tower_token: - name: Delete our Token with the token we created
existing_token: "{{ tower_token }}" tower_token:
state: absent existing_token: "{{ tower_token }}"
state: absent
when: tower_token is defined
''' '''
RETURNS = ''' RETURNS = '''

View File

@@ -3,23 +3,26 @@
set_fact: set_fact:
token_description: "AWX-Collection-tests-tower_token-description-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" token_description: "AWX-Collection-tests-tower_token-description-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
- name: Create a Token - block:
tower_token: - name: Create a Token
description: '{{ token_description }}' tower_token:
scope: "write" description: '{{ token_description }}'
state: present scope: "write"
register: new_token state: present
register: new_token
- name: Validate our token works by token - name: Validate our token works by token
tower_job_list: tower_job_list:
tower_oauthtoken: "{{ tower_token.token }}" tower_oauthtoken: "{{ tower_token.token }}"
- name: Validate out token works by object - name: Validate out token works by object
tower_job_list: tower_job_list:
tower_oauthtoken: "{{ tower_token }}" tower_oauthtoken: "{{ tower_token }}"
- name: Delete our Token with our own token always:
tower_token: - name: Delete our Token with our own token
existing_token: "{{ tower_token }}" tower_token:
tower_oauthtoken: "{{ tower_token }}" existing_token: "{{ tower_token }}"
state: absent tower_oauthtoken: "{{ tower_token }}"
state: absent
when: tower_token is defined