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"
short_description: create, update, or destroy Ansible Tower tokens.
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.
- If you create a token it is your responsibility to delete the token.
options:
description:
description:
@ -60,22 +61,24 @@ extends_documentation_fragment: awx.awx.auth
'''
EXAMPLES = '''
- name: Create a new token using an existing token
tower_token:
description: '{{ token_description }}'
scope: "write"
state: present
tower_oauthtoken: "{{ ny_existing_token }}"
register: new_token
- block:
- name: Create a new token using an existing token
tower_token:
description: '{{ token_description }}'
scope: "write"
state: present
tower_oauthtoken: "{{ ny_existing_token }}"
- name: Use our new token to make another call
tower_job_list:
tower_oauthtoken: "{{ tower_token }}"
- name: Use our new token to make another call
tower_job_list:
tower_oauthtoken: "{{ tower_token }}"
- name: Delete our Token with the token we created
tower_token:
existing_token: "{{ tower_token }}"
state: absent
always:
- name: Delete our Token with the token we created
tower_token:
existing_token: "{{ tower_token }}"
state: absent
when: tower_token is defined
'''
RETURNS = '''

View File

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