diff --git a/awx_collection/plugins/lookup/tower_get_id.py b/awx_collection/plugins/lookup/tower_get_id.py index 69b4575c8e..7712f53e89 100644 --- a/awx_collection/plugins/lookup/tower_get_id.py +++ b/awx_collection/plugins/lookup/tower_get_id.py @@ -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 """ diff --git a/awx_collection/tests/integration/targets/tower_lookup_api_plugin/tasks/main.yml b/awx_collection/tests/integration/targets/tower_lookup_api_plugin/tasks/main.yml index 1056c02d3f..60e679ee35 100644 --- a/awx_collection/tests/integration/targets/tower_lookup_api_plugin/tasks/main.yml +++ b/awx_collection/tests/integration/targets/tower_lookup_api_plugin/tasks/main.yml @@ -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 diff --git a/awx_collection/tests/integration/targets/tower_lookup_get_id_plugin/tasks/main.yml b/awx_collection/tests/integration/targets/tower_lookup_get_id_plugin/tasks/main.yml index 8d19f836c6..78961be0b5 100644 --- a/awx_collection/tests/integration/targets/tower_lookup_get_id_plugin/tasks/main.yml +++ b/awx_collection/tests/integration/targets/tower_lookup_get_id_plugin/tasks/main.yml @@ -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