Initial fixes from github comments

This commit is contained in:
John Westcott IV 2020-06-10 14:54:19 -04:00
parent 3c02265986
commit 44a3057d16
3 changed files with 9 additions and 18 deletions

View File

@ -30,13 +30,13 @@ options:
EXAMPLES = """
- name: Lookup a users ID
debug:
msg: "{{ query('awx.awx.tower_api', 'users', query_params={ 'username': 'admin' }) }}"
msg: "{{ query('awx.awx.tower_get_id', 'users', query_params={ 'username': 'admin' }) }}"
"""
RETURN = """
_raw:
description:
- The ID found for the filter criteria
- The ID found for the filter criteria returned as a string (i.e. "42" instead of 42).
type: str
"""

View File

@ -50,31 +50,22 @@
that:
- users['results'] | length() == 1
- users['count'] == 1
- name: Get the id of the admin users
set_fact:
user_id: "{{ (query('awx.awx.tower_api', 'users', query_params=query_params) | json_query(jmes_query))[0] }}"
vars:
query_params:
username: "{{ user_creation_results['results'][0]['item'] }}"
jmes_query: 'results[*].id'
- assert:
that: "{{ user_id }} == {{ user_creation_results['results'][0]['id'] }}"
- users['results'][0]['id'] == user_creation_results['results'][0]['id']
- name: Get a page of users
set_fact:
users: "{{ query('awx.awx.tower_api', 'users', query_params={ 'page_size': 2 } ) }}"
users: "{{ query('awx.awx.tower_api', 'users', query_params={ 'username__endswith': test_id, 'page_size': 2 } ) }}"
- assert:
that: users['results'] | length() == 2
- name: Get all users of a system through next attribute
set_fact:
users: "{{ query('awx.awx.tower_api', 'users', query_params={ 'page_size': 1, }, get_all=true ) }}"
users: "{{ query('awx.awx.tower_api', 'users', query_params={ 'username__endswith': test_id, 'page_size': 1 }, get_all=true ) }}"
- assert:
that: users['results'] | length() >= 3
that:
- users['results'] | length() >= 3
always:
- name: Cleanup users

View File

@ -42,7 +42,7 @@
- result is failed
- "'The requested object could not be found at' in result.msg"
- name: Get the ID of the admin user
- name: Get the ID of the first user created
set_fact:
user_id: "{{ query('awx.awx.tower_get_id', 'users', query_params={ 'username' : user_creation_results['results'][0]['item'] }) }}"
@ -62,7 +62,7 @@
- name: Lookup too many users
set_fact:
too_many_user_ids: " {{ query('awx.awx.tower_get_id', 'users', query_params={ 'username__startswith': 'AWX-Collection-tests-tower_get_id-' }) }}"
too_many_user_ids: " {{ query('awx.awx.tower_get_id', 'users', query_params={ 'username__endswith': test_id }) }}"
register: results
ignore_errors: true