mirror of
https://github.com/ansible/awx.git
synced 2026-03-06 11:11:07 -03:30
Add wait ability to the module
This commit is contained in:
@@ -130,7 +130,7 @@ options:
|
|||||||
elements: str
|
elements: str
|
||||||
organization:
|
organization:
|
||||||
description:
|
description:
|
||||||
- Name of organization for project.
|
- Name of the inventory source's inventory's organization.
|
||||||
type: str
|
type: str
|
||||||
extends_documentation_fragment: awx.awx.auth
|
extends_documentation_fragment: awx.awx.auth
|
||||||
'''
|
'''
|
||||||
@@ -173,9 +173,6 @@ def main():
|
|||||||
enabled_value=dict(),
|
enabled_value=dict(),
|
||||||
host_filter=dict(),
|
host_filter=dict(),
|
||||||
credential=dict(),
|
credential=dict(),
|
||||||
source_regions=dict(),
|
|
||||||
instance_filters=dict(),
|
|
||||||
group_by=dict(),
|
|
||||||
organization=dict(),
|
organization=dict(),
|
||||||
overwrite=dict(type='bool'),
|
overwrite=dict(type='bool'),
|
||||||
overwrite_vars=dict(type='bool'),
|
overwrite_vars=dict(type='bool'),
|
||||||
|
|||||||
@@ -34,9 +34,25 @@ options:
|
|||||||
type: str
|
type: str
|
||||||
organization:
|
organization:
|
||||||
description:
|
description:
|
||||||
- Name of organization for project.
|
- Name of the inventory source's inventory's organization.
|
||||||
type: str
|
type: str
|
||||||
required: False
|
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
|
extends_documentation_fragment: awx.awx.auth
|
||||||
'''
|
'''
|
||||||
|
|
||||||
@@ -76,6 +92,9 @@ def main():
|
|||||||
inventory=dict(required=True),
|
inventory=dict(required=True),
|
||||||
inventory_source=dict(required=True),
|
inventory_source=dict(required=True),
|
||||||
organization=dict(),
|
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
|
# Create a module for ourselves
|
||||||
@@ -84,6 +103,9 @@ def main():
|
|||||||
# Extract our parameters
|
# Extract our parameters
|
||||||
inventory = module.params.get('inventory')
|
inventory = module.params.get('inventory')
|
||||||
inventory_source = module.params.get('inventory_source')
|
inventory_source = module.params.get('inventory_source')
|
||||||
|
wait = module.params.get('wait')
|
||||||
|
interval = module.params.get('interval')
|
||||||
|
timeout = module.params.get('timeout')
|
||||||
|
|
||||||
new_fields = {}
|
new_fields = {}
|
||||||
organization_id = None
|
organization_id = None
|
||||||
@@ -102,6 +124,13 @@ def main():
|
|||||||
if inventory_source_update_results['status_code'] != 202:
|
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})
|
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(**{
|
module.exit_json(**{
|
||||||
'changed': True,
|
'changed': True,
|
||||||
'id': inventory_source_update_results['json']['id'],
|
'id': inventory_source_update_results['json']['id'],
|
||||||
|
|||||||
@@ -77,6 +77,7 @@
|
|||||||
inventory: "{{ inv_name }}"
|
inventory: "{{ inv_name }}"
|
||||||
inventory_source: "{{ item }}"
|
inventory_source: "{{ item }}"
|
||||||
organization: "{{ created_org.id }}"
|
organization: "{{ created_org.id }}"
|
||||||
|
wait: true
|
||||||
loop: "{{ query('awx.awx.tower_api', 'inventory_sources', query_params={ 'inventory': created_inventory.id }, return_ids=True ) }}"
|
loop: "{{ query('awx.awx.tower_api', 'inventory_sources', query_params={ 'inventory': created_inventory.id }, return_ids=True ) }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user