mirror of
https://github.com/ansible/awx.git
synced 2026-01-20 06:01:25 -03:30
Add wait ability to the module
This commit is contained in:
parent
1ce5d7d539
commit
b78dea3e4b
@ -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'),
|
||||
|
||||
@ -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'],
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user