diff --git a/awx_collection/plugins/modules/tower_inventory_source.py b/awx_collection/plugins/modules/tower_inventory_source.py index bf52996211..eb316fd9ca 100644 --- a/awx_collection/plugins/modules/tower_inventory_source.py +++ b/awx_collection/plugins/modules/tower_inventory_source.py @@ -130,7 +130,7 @@ options: elements: str organization: description: - - Name of organization for project. + - Name of the inventory source's inventory's organization. type: str extends_documentation_fragment: awx.awx.auth ''' @@ -173,9 +173,6 @@ def main(): enabled_value=dict(), host_filter=dict(), credential=dict(), - source_regions=dict(), - instance_filters=dict(), - group_by=dict(), organization=dict(), overwrite=dict(type='bool'), overwrite_vars=dict(type='bool'), diff --git a/awx_collection/plugins/modules/tower_inventory_source_update.py b/awx_collection/plugins/modules/tower_inventory_source_update.py index f38e3b6039..c8ac301ef3 100644 --- a/awx_collection/plugins/modules/tower_inventory_source_update.py +++ b/awx_collection/plugins/modules/tower_inventory_source_update.py @@ -34,9 +34,25 @@ options: type: str organization: description: - - Name of organization for project. + - Name of the inventory source's inventory's organization. type: str required: False + wait: + description: + - Wait for the job to complete. + default: False + type: bool + interval: + description: + - The interval to request an update from Tower. + required: False + default: 1 + type: float + timeout: + description: + - If waiting for the job to complete this will abort after this + amount of seconds + type: int extends_documentation_fragment: awx.awx.auth ''' @@ -76,6 +92,9 @@ def main(): inventory=dict(required=True), inventory_source=dict(required=True), organization=dict(), + wait=dict(default=False, type='bool'), + interval=dict(default=1.0, type='float'), + timeout=dict(default=None, type='int'), ) # Create a module for ourselves @@ -84,6 +103,9 @@ def main(): # Extract our parameters inventory = module.params.get('inventory') inventory_source = module.params.get('inventory_source') + wait = module.params.get('wait') + interval = module.params.get('interval') + timeout = module.params.get('timeout') new_fields = {} organization_id = None @@ -102,6 +124,13 @@ 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}) + 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.exit_json(**{ 'changed': True, 'id': inventory_source_update_results['json']['id'], 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 7207541838..fd6cd48f2f 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 @@ -77,6 +77,7 @@ inventory: "{{ inv_name }}" inventory_source: "{{ item }}" organization: "{{ created_org.id }}" + wait: true loop: "{{ query('awx.awx.tower_api', 'inventory_sources', query_params={ 'inventory': created_inventory.id }, return_ids=True ) }}" register: result