From 4133ec974bc793c8b769542c68b13ff6a2dfed42 Mon Sep 17 00:00:00 2001 From: beeankha Date: Fri, 4 Sep 2020 10:39:25 -0400 Subject: [PATCH] Follow same pattern as project update module, add task to integration test --- .../modules/tower_inventory_source_update.py | 27 ++++++++++--------- .../tasks/main.yml | 11 ++++++++ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/awx_collection/plugins/modules/tower_inventory_source_update.py b/awx_collection/plugins/modules/tower_inventory_source_update.py index 6f9cdf6de1..8579126dd3 100644 --- a/awx_collection/plugins/modules/tower_inventory_source_update.py +++ b/awx_collection/plugins/modules/tower_inventory_source_update.py @@ -135,19 +135,22 @@ def main(): if inventory_source_update_results['status_code'] != 202: module.fail_json(msg="Failed to update inventory source, see response for details", **{'response': inventory_source_update_results}) - if wait: - inventory_source_update_results = module.wait_on_url( - url=inventory_source_update_results['json']['url'], - object_name=inventory_object, - object_type='inventory_update', - timeout=timeout, interval=interval - ) + module.json_output['changed'] = True + module.json_output['id'] = inventory_source_update_results['json']['id'] + module.json_output['status'] = inventory_source_update_results['json']['status'] - module.exit_json(**{ - 'changed': True, - 'id': inventory_source_update_results['json']['id'], - 'status': inventory_source_update_results['json']['status'], - }) + if not wait: + module.exit_json(**module.json_output) + + # Invoke wait function + module.wait_on_url( + url=inventory_source_update_results['json']['url'], + object_name=inventory_object, + object_type='inventory_update', + timeout=timeout, interval=interval + ) + + module.exit_json(**module.json_output) if __name__ == '__main__': diff --git a/awx_collection/tests/integration/targets/tower_inventory_source_update/tasks/main.yml b/awx_collection/tests/integration/targets/tower_inventory_source_update/tasks/main.yml index 01b29a0cf0..b151db90ba 100644 --- a/awx_collection/tests/integration/targets/tower_inventory_source_update/tasks/main.yml +++ b/awx_collection/tests/integration/targets/tower_inventory_source_update/tasks/main.yml @@ -9,6 +9,7 @@ inv_name: "AWX-Collection-tests-tower_inventory_source_update-inv-{{ test_id }}" inv_source1: "AWX-Collection-tests-tower_inventory_source_update-source1-{{ test_id }}" inv_source2: "AWX-Collection-tests-tower_inventory_source_update-source2-{{ test_id }}" + inv_source3: "AWX-Collection-tests-tower_inventory_source_update-source3-{{ test_id }}" org_name: "AWX-Collection-tests-tower_inventory_source_update-org-{{ test_id }}" @@ -60,6 +61,16 @@ organization: Default inventory: "{{ inv_name }}" + - name: Create Yet Another Inventory Source (one more to make lookup plugin find multiple inventory sources) + tower_inventory_source: + name: "{{ inv_source3 }}" + source: scm + source_project: "{{ project_name }}" + source_path: inventories/create_100_hosts.ini + description: Source for Test inventory + organization: Default + inventory: "{{ inv_name }}" + - name: Test Inventory Source Update tower_inventory_source_update: inventory: "{{ inv_name }}"