From 0c1858785100c930c095649805a359541334db0f Mon Sep 17 00:00:00 2001 From: sean-m-sullivan Date: Wed, 26 Aug 2020 23:30:18 -0500 Subject: [PATCH 01/11] update to use time function --- .../plugins/module_utils/tower_api.py | 24 ++++++++++ .../plugins/modules/tower_job_launch.py | 22 ++++++++- .../plugins/modules/tower_job_wait.py | 48 ++++--------------- .../plugins/modules/tower_workflow_launch.py | 30 ++++-------- 4 files changed, 61 insertions(+), 63 deletions(-) diff --git a/awx_collection/plugins/module_utils/tower_api.py b/awx_collection/plugins/module_utils/tower_api.py index 36e3d045f0..138f523515 100644 --- a/awx_collection/plugins/module_utils/tower_api.py +++ b/awx_collection/plugins/module_utils/tower_api.py @@ -7,6 +7,7 @@ from ansible.module_utils.six import PY2 from ansible.module_utils.six.moves.urllib.parse import urlencode from ansible.module_utils.six.moves.urllib.error import HTTPError from ansible.module_utils.six.moves.http_cookiejar import CookieJar +import time import re from json import loads, dumps @@ -588,3 +589,26 @@ class TowerAPIModule(TowerModule): return False else: return True + + def wait_on_url(self, object_name=None, object_type=None, url=None, timeout=None, interval=None): + # Grab our start time to compare against for the timeout + start = time.time() + result = self.get_endpoint(url) + while not result['json']['finished']: + # If we are past our time out fail with a message + if timeout and timeout < time.time() - start: + self.json_output['msg'] = 'Monitoring of {0} "{1}" aborted due to timeout'.format(object_type, object_name) + self.fail_json(**self.json_output) + + # Put the process to sleep for our interval + time.sleep(interval) + + result = self.get_endpoint(url) + self.json_output['status'] = result['json']['status'] + + # If the job has failed, we want to raise a task failure for that so we get a non-zero response. + if result['json']['failed']: + self.json_output['msg'] = 'The {0} "{1}" failed'.format(object_type, object_name) + self.fail_json(**self.json_output) + + return result diff --git a/awx_collection/plugins/modules/tower_job_launch.py b/awx_collection/plugins/modules/tower_job_launch.py index 25a1c52fdf..9179c416e7 100644 --- a/awx_collection/plugins/modules/tower_job_launch.py +++ b/awx_collection/plugins/modules/tower_job_launch.py @@ -143,6 +143,9 @@ def main(): verbosity=dict(type='int', choices=[0, 1, 2, 3, 4, 5]), diff_mode=dict(type='bool'), credential_passwords=dict(type='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 @@ -162,6 +165,9 @@ def main(): optional_args['verbosity'] = module.params.get('verbosity') optional_args['diff_mode'] = module.params.get('diff_mode') optional_args['credential_passwords'] = module.params.get('credential_passwords') + wait = module.params.get('wait') + interval = module.params.get('interval') + timeout = module.params.get('timeout') # Create a datastructure to pass into our job launch post_data = {} @@ -216,12 +222,26 @@ def main(): if results['status_code'] != 201: module.fail_json(msg="Failed to launch job, see response for details", **{'response': results}) + if not wait: + module.exit_json(**{ + 'changed': True, + 'id': results['json']['id'], + 'status': results['json']['status'], + }) + + # Invoke wait function + results = module.wait_on_url( + object_name=name, + object_type='job', + url=results['json']['url'], + timeout=timeout, interval=interval + ) + module.exit_json(**{ 'changed': True, 'id': results['json']['id'], 'status': results['json']['status'], }) - if __name__ == '__main__': main() diff --git a/awx_collection/plugins/modules/tower_job_wait.py b/awx_collection/plugins/modules/tower_job_wait.py index 5e5801b25f..edb9b718dc 100644 --- a/awx_collection/plugins/modules/tower_job_wait.py +++ b/awx_collection/plugins/modules/tower_job_wait.py @@ -55,7 +55,7 @@ EXAMPLES = ''' - name: Launch a job tower_job_launch: job_template: "My Job Template" - register: job + register: job - name: Wait for job max 120s tower_job_wait: @@ -93,20 +93,6 @@ status: from ..module_utils.tower_api import TowerAPIModule -import time - - -def check_job(module, job_url): - response = module.get_endpoint(job_url) - if response['status_code'] != 200: - module.fail_json(msg="Unable to read job from Tower {0}: {1}".format(response['status_code'], module.extract_errors_from_response(response))) - - # Since we were successful, extract the fields we want to return - for k in ('id', 'status', 'elapsed', 'started', 'finished'): - module.json_output[k] = response['json'].get(k) - - # And finally return the payload - return response['json'] def main(): @@ -153,31 +139,13 @@ def main(): if job is None: module.fail_json(msg='Unable to wait on job {0}; that ID does not exist in Tower.'.format(job_id)) - job_url = job['url'] - - # Grab our start time to compare against for the timeout - start = time.time() - - # Get the initial job status from Tower, this will exit if there are any issues with the HTTP call - result = check_job(module, job_url) - - # Loop while the job is not yet completed - while not result['finished']: - # If we are past our time out fail with a message - if timeout and timeout < time.time() - start: - module.json_output['msg'] = "Monitoring aborted due to timeout" - module.fail_json(**module.json_output) - - # Put the process to sleep for our interval - time.sleep(interval) - - # Check the job again - result = check_job(module, job_url) - - # If the job has failed, we want to raise an Exception for that so we get a non-zero response. - if result['failed']: - module.json_output['msg'] = 'Job with id {0} failed'.format(job_id) - module.fail_json(**module.json_output) + # Invoke wait function + result = module.wait_on_url( + object_name=job_id, + object_type='job', + url=job['url'], + timeout=timeout, interval=interval + ) module.exit_json(**module.json_output) diff --git a/awx_collection/plugins/modules/tower_workflow_launch.py b/awx_collection/plugins/modules/tower_workflow_launch.py index 249feeed35..70377fd207 100644 --- a/awx_collection/plugins/modules/tower_workflow_launch.py +++ b/awx_collection/plugins/modules/tower_workflow_launch.py @@ -93,7 +93,6 @@ EXAMPLES = ''' from ..module_utils.tower_api import TowerAPIModule import json -import time def main(): @@ -177,27 +176,14 @@ def main(): if not wait: module.exit_json(**module.json_output) - - # Grab our start time to compare against for the timeout - start = time.time() - - job_url = result['json']['url'] - while not result['json']['finished']: - # If we are past our time out fail with a message - if timeout and timeout < time.time() - start: - module.json_output['msg'] = "Monitoring aborted due to timeout" - module.fail_json(**module.json_output) - - # Put the process to sleep for our interval - time.sleep(interval) - - result = module.get_endpoint(job_url) - module.json_output['status'] = result['json']['status'] - - # If the job has failed, we want to raise a task failure for that so we get a non-zero response. - if result['json']['failed']: - module.json_output['msg'] = 'The workflow "{0}" failed'.format(name) - module.fail_json(**module.json_output) + + # Invoke wait function + module.wait_on_url( + object_name=name, + object_type='workflow_job', + url=result['json']['url'], + timeout=timeout, interval=interval + ) module.exit_json(**module.json_output) From 49e2a3fa5a89ff4d0722de494f0eb01ef5c73bc5 Mon Sep 17 00:00:00 2001 From: sean-m-sullivan Date: Wed, 26 Aug 2020 23:44:31 -0500 Subject: [PATCH 02/11] update documentation --- .../plugins/modules/tower_job_launch.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/awx_collection/plugins/modules/tower_job_launch.py b/awx_collection/plugins/modules/tower_job_launch.py index 9179c416e7..a016d1d30b 100644 --- a/awx_collection/plugins/modules/tower_job_launch.py +++ b/awx_collection/plugins/modules/tower_job_launch.py @@ -81,6 +81,22 @@ options: description: - Passwords for credentials which are set to prompt on launch type: dict + wait: + description: + - Wait for the job to complete. + default: True + 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 ''' @@ -145,7 +161,7 @@ def main(): credential_passwords=dict(type='dict'), wait=dict(default=False, type='bool'), interval=dict(default=1.0, type='float'), - timeout=dict(default=None, type='int'), + timeout=dict(default=None, type='int'), ) # Create a module for ourselves From 007b0d841e34972e5928d8689477017e4a830ce5 Mon Sep 17 00:00:00 2001 From: sean-m-sullivan Date: Fri, 28 Aug 2020 07:19:39 -0500 Subject: [PATCH 03/11] updated parameters and errors --- awx_collection/plugins/module_utils/tower_api.py | 2 +- awx_collection/plugins/modules/tower_job_launch.py | 2 +- awx_collection/plugins/modules/tower_job_wait.py | 7 +++++-- awx_collection/plugins/modules/tower_workflow_launch.py | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/awx_collection/plugins/module_utils/tower_api.py b/awx_collection/plugins/module_utils/tower_api.py index 138f523515..dfab8ad9ab 100644 --- a/awx_collection/plugins/module_utils/tower_api.py +++ b/awx_collection/plugins/module_utils/tower_api.py @@ -590,7 +590,7 @@ class TowerAPIModule(TowerModule): else: return True - def wait_on_url(self, object_name=None, object_type=None, url=None, timeout=None, interval=None): + def wait_on_url(self, url, object_name, object_type, timeout=30, interval=10): # Grab our start time to compare against for the timeout start = time.time() result = self.get_endpoint(url) diff --git a/awx_collection/plugins/modules/tower_job_launch.py b/awx_collection/plugins/modules/tower_job_launch.py index a016d1d30b..8345b55b66 100644 --- a/awx_collection/plugins/modules/tower_job_launch.py +++ b/awx_collection/plugins/modules/tower_job_launch.py @@ -247,9 +247,9 @@ def main(): # Invoke wait function results = module.wait_on_url( + url=results['json']['url'], object_name=name, object_type='job', - url=results['json']['url'], timeout=timeout, interval=interval ) diff --git a/awx_collection/plugins/modules/tower_job_wait.py b/awx_collection/plugins/modules/tower_job_wait.py index edb9b718dc..888cce8381 100644 --- a/awx_collection/plugins/modules/tower_job_wait.py +++ b/awx_collection/plugins/modules/tower_job_wait.py @@ -141,14 +141,17 @@ def main(): # Invoke wait function result = module.wait_on_url( + url=job['url'], object_name=job_id, object_type='job', - url=job['url'], timeout=timeout, interval=interval ) - module.exit_json(**module.json_output) + # Format data to keep legacy compatability. + for k in ('id', 'status', 'elapsed', 'started', 'finished'): + module.json_output[k] = result['json'].get(k) + module.exit_json(**module.json_output) if __name__ == '__main__': main() diff --git a/awx_collection/plugins/modules/tower_workflow_launch.py b/awx_collection/plugins/modules/tower_workflow_launch.py index 70377fd207..b665adbf15 100644 --- a/awx_collection/plugins/modules/tower_workflow_launch.py +++ b/awx_collection/plugins/modules/tower_workflow_launch.py @@ -179,9 +179,9 @@ def main(): # Invoke wait function module.wait_on_url( + url=result['json']['url'], object_name=name, object_type='workflow_job', - url=result['json']['url'], timeout=timeout, interval=interval ) From d9713759070b2cc3db2c3bf453086409399b52f4 Mon Sep 17 00:00:00 2001 From: sean-m-sullivan Date: Fri, 28 Aug 2020 07:35:13 -0500 Subject: [PATCH 04/11] updated to error if finished not in result --- .../plugins/module_utils/tower_api.py | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/awx_collection/plugins/module_utils/tower_api.py b/awx_collection/plugins/module_utils/tower_api.py index dfab8ad9ab..28a4355574 100644 --- a/awx_collection/plugins/module_utils/tower_api.py +++ b/awx_collection/plugins/module_utils/tower_api.py @@ -594,17 +594,21 @@ class TowerAPIModule(TowerModule): # Grab our start time to compare against for the timeout start = time.time() result = self.get_endpoint(url) - while not result['json']['finished']: - # If we are past our time out fail with a message - if timeout and timeout < time.time() - start: - self.json_output['msg'] = 'Monitoring of {0} "{1}" aborted due to timeout'.format(object_type, object_name) - self.fail_json(**self.json_output) + if result['json']['finished'] is None: + self.json_output['msg'] = 'Monitoring of {0} "{1}" aborted due to timeout'.format(object_type, object_name) + self.fail_json(**self.json_output) + else: + while not result['json']['finished']: + # If we are past our time out fail with a message + if timeout and timeout < time.time() - start: + self.json_output['msg'] = 'Monitoring of {0} "{1}" aborted due to timeout'.format(object_type, object_name) + self.fail_json(**self.json_output) - # Put the process to sleep for our interval - time.sleep(interval) + # Put the process to sleep for our interval + time.sleep(interval) - result = self.get_endpoint(url) - self.json_output['status'] = result['json']['status'] + result = self.get_endpoint(url) + self.json_output['status'] = result['json']['status'] # If the job has failed, we want to raise a task failure for that so we get a non-zero response. if result['json']['failed']: From 7bd3f9d63c753d09dea131c94b58471b85e7aa83 Mon Sep 17 00:00:00 2001 From: sean-m-sullivan Date: Fri, 28 Aug 2020 07:37:29 -0500 Subject: [PATCH 05/11] updated to error if finished not in result --- awx_collection/plugins/module_utils/tower_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx_collection/plugins/module_utils/tower_api.py b/awx_collection/plugins/module_utils/tower_api.py index 28a4355574..e003b76591 100644 --- a/awx_collection/plugins/module_utils/tower_api.py +++ b/awx_collection/plugins/module_utils/tower_api.py @@ -595,7 +595,7 @@ class TowerAPIModule(TowerModule): start = time.time() result = self.get_endpoint(url) if result['json']['finished'] is None: - self.json_output['msg'] = 'Monitoring of {0} "{1}" aborted due to timeout'.format(object_type, object_name) + self.json_output['msg'] = 'Finished was not returned in the request of {0}'.format(url) self.fail_json(**self.json_output) else: while not result['json']['finished']: From fd77a8aca5643d11e1f35520060f60aba3346e74 Mon Sep 17 00:00:00 2001 From: sean-m-sullivan Date: Fri, 28 Aug 2020 08:22:44 -0500 Subject: [PATCH 06/11] updated output --- .../plugins/module_utils/tower_api.py | 33 +++++++++++-------- .../plugins/modules/tower_job_wait.py | 4 --- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/awx_collection/plugins/module_utils/tower_api.py b/awx_collection/plugins/module_utils/tower_api.py index e003b76591..f6750ac3be 100644 --- a/awx_collection/plugins/module_utils/tower_api.py +++ b/awx_collection/plugins/module_utils/tower_api.py @@ -594,25 +594,32 @@ class TowerAPIModule(TowerModule): # Grab our start time to compare against for the timeout start = time.time() result = self.get_endpoint(url) - if result['json']['finished'] is None: - self.json_output['msg'] = 'Finished was not returned in the request of {0}'.format(url) - self.fail_json(**self.json_output) - else: - while not result['json']['finished']: - # If we are past our time out fail with a message - if timeout and timeout < time.time() - start: - self.json_output['msg'] = 'Monitoring of {0} "{1}" aborted due to timeout'.format(object_type, object_name) - self.fail_json(**self.json_output) + while not result['json']['finished']: + # If we are past our time out fail with a message + if timeout and timeout < time.time() - start: + self.json_output['msg'] = 'Monitoring of {0} "{1}" aborted due to timeout'.format(object_type, object_name) + # Format data to keep legacy compatability. + self.wait_output(result) + self.fail_json(**self.json_output) - # Put the process to sleep for our interval - time.sleep(interval) + # Put the process to sleep for our interval + time.sleep(interval) - result = self.get_endpoint(url) - self.json_output['status'] = result['json']['status'] + result = self.get_endpoint(url) + self.json_output['status'] = result['json']['status'] # If the job has failed, we want to raise a task failure for that so we get a non-zero response. if result['json']['failed']: self.json_output['msg'] = 'The {0} "{1}" failed'.format(object_type, object_name) + # Format data to keep legacy compatability. + self.wait_output(result) self.fail_json(**self.json_output) + self.wait_output(result) + return result + + def wait_output(self, response): + # Format data to keep legacy compatability. + for k in ('id', 'status', 'elapsed', 'started', 'finished'): + self.json_output[k] = response['json'].get(k) diff --git a/awx_collection/plugins/modules/tower_job_wait.py b/awx_collection/plugins/modules/tower_job_wait.py index 888cce8381..1c65e141dc 100644 --- a/awx_collection/plugins/modules/tower_job_wait.py +++ b/awx_collection/plugins/modules/tower_job_wait.py @@ -147,10 +147,6 @@ def main(): timeout=timeout, interval=interval ) - # Format data to keep legacy compatability. - for k in ('id', 'status', 'elapsed', 'started', 'finished'): - module.json_output[k] = result['json'].get(k) - module.exit_json(**module.json_output) if __name__ == '__main__': From b3ec080e087123c874e1683394ceb92abc8b52a1 Mon Sep 17 00:00:00 2001 From: sean-m-sullivan Date: Fri, 28 Aug 2020 08:25:21 -0500 Subject: [PATCH 07/11] updated output --- awx_collection/plugins/module_utils/tower_api.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/awx_collection/plugins/module_utils/tower_api.py b/awx_collection/plugins/module_utils/tower_api.py index f6750ac3be..8b619dd36e 100644 --- a/awx_collection/plugins/module_utils/tower_api.py +++ b/awx_collection/plugins/module_utils/tower_api.py @@ -598,7 +598,6 @@ class TowerAPIModule(TowerModule): # If we are past our time out fail with a message if timeout and timeout < time.time() - start: self.json_output['msg'] = 'Monitoring of {0} "{1}" aborted due to timeout'.format(object_type, object_name) - # Format data to keep legacy compatability. self.wait_output(result) self.fail_json(**self.json_output) @@ -611,7 +610,6 @@ class TowerAPIModule(TowerModule): # If the job has failed, we want to raise a task failure for that so we get a non-zero response. if result['json']['failed']: self.json_output['msg'] = 'The {0} "{1}" failed'.format(object_type, object_name) - # Format data to keep legacy compatability. self.wait_output(result) self.fail_json(**self.json_output) @@ -620,6 +618,5 @@ class TowerAPIModule(TowerModule): return result def wait_output(self, response): - # Format data to keep legacy compatability. for k in ('id', 'status', 'elapsed', 'started', 'finished'): self.json_output[k] = response['json'].get(k) From 0bc927820bc57e6862ce7befed995d4e7df69e80 Mon Sep 17 00:00:00 2001 From: sean-m-sullivan Date: Mon, 31 Aug 2020 15:24:32 -0500 Subject: [PATCH 08/11] updated legacy messages --- awx_collection/plugins/module_utils/tower_api.py | 12 ++++++++++-- awx_collection/plugins/modules/tower_job_launch.py | 2 +- awx_collection/plugins/modules/tower_job_wait.py | 2 +- .../plugins/modules/tower_workflow_launch.py | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/awx_collection/plugins/module_utils/tower_api.py b/awx_collection/plugins/module_utils/tower_api.py index 8b619dd36e..3e3f668401 100644 --- a/awx_collection/plugins/module_utils/tower_api.py +++ b/awx_collection/plugins/module_utils/tower_api.py @@ -597,7 +597,11 @@ class TowerAPIModule(TowerModule): while not result['json']['finished']: # If we are past our time out fail with a message if timeout and timeout < time.time() - start: - self.json_output['msg'] = 'Monitoring of {0} "{1}" aborted due to timeout'.format(object_type, object_name) + # Account for Legacy messages + if object_type is 'legacy_job_wait': + self.json_output['msg'] = 'Monitoring of Job - {1} aborted due to timeout'.format(object_name) + else: + self.json_output['msg'] = 'Monitoring of {0} - {1} aborted due to timeout'.format(object_type, object_name) self.wait_output(result) self.fail_json(**self.json_output) @@ -609,7 +613,11 @@ class TowerAPIModule(TowerModule): # If the job has failed, we want to raise a task failure for that so we get a non-zero response. if result['json']['failed']: - self.json_output['msg'] = 'The {0} "{1}" failed'.format(object_type, object_name) + # Account for Legacy messages + if object_type is 'legacy_job_wait': + self.json_output['msg'] = 'Job with id {0} failed'.format(object_name) + else: + self.json_output['msg'] = 'The {0} - {1}, failed'.format(object_type, object_name) self.wait_output(result) self.fail_json(**self.json_output) diff --git a/awx_collection/plugins/modules/tower_job_launch.py b/awx_collection/plugins/modules/tower_job_launch.py index 8345b55b66..11ebb14110 100644 --- a/awx_collection/plugins/modules/tower_job_launch.py +++ b/awx_collection/plugins/modules/tower_job_launch.py @@ -249,7 +249,7 @@ def main(): results = module.wait_on_url( url=results['json']['url'], object_name=name, - object_type='job', + object_type='Job', timeout=timeout, interval=interval ) diff --git a/awx_collection/plugins/modules/tower_job_wait.py b/awx_collection/plugins/modules/tower_job_wait.py index 1c65e141dc..46bb80d007 100644 --- a/awx_collection/plugins/modules/tower_job_wait.py +++ b/awx_collection/plugins/modules/tower_job_wait.py @@ -143,7 +143,7 @@ def main(): result = module.wait_on_url( url=job['url'], object_name=job_id, - object_type='job', + object_type='legacy_job_wait', timeout=timeout, interval=interval ) diff --git a/awx_collection/plugins/modules/tower_workflow_launch.py b/awx_collection/plugins/modules/tower_workflow_launch.py index b665adbf15..8267e9352c 100644 --- a/awx_collection/plugins/modules/tower_workflow_launch.py +++ b/awx_collection/plugins/modules/tower_workflow_launch.py @@ -181,7 +181,7 @@ def main(): module.wait_on_url( url=result['json']['url'], object_name=name, - object_type='workflow_job', + object_type='Workflow Job', timeout=timeout, interval=interval ) From cd45cfec309c2c0ac7a4abadc92b17c87b01e3e5 Mon Sep 17 00:00:00 2001 From: sean-m-sullivan Date: Mon, 31 Aug 2020 15:53:54 -0500 Subject: [PATCH 09/11] updated doc and pep8 --- awx_collection/plugins/modules/tower_job_launch.py | 5 +++-- awx_collection/plugins/modules/tower_job_wait.py | 1 + awx_collection/plugins/modules/tower_workflow_launch.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/awx_collection/plugins/modules/tower_job_launch.py b/awx_collection/plugins/modules/tower_job_launch.py index 11ebb14110..7e2dca0e38 100644 --- a/awx_collection/plugins/modules/tower_job_launch.py +++ b/awx_collection/plugins/modules/tower_job_launch.py @@ -84,7 +84,7 @@ options: wait: description: - Wait for the job to complete. - default: True + default: False type: bool interval: description: @@ -183,7 +183,7 @@ def main(): optional_args['credential_passwords'] = module.params.get('credential_passwords') wait = module.params.get('wait') interval = module.params.get('interval') - timeout = module.params.get('timeout') + timeout = module.params.get('timeout') # Create a datastructure to pass into our job launch post_data = {} @@ -259,5 +259,6 @@ def main(): 'status': results['json']['status'], }) + if __name__ == '__main__': main() diff --git a/awx_collection/plugins/modules/tower_job_wait.py b/awx_collection/plugins/modules/tower_job_wait.py index 46bb80d007..6f71a1be5b 100644 --- a/awx_collection/plugins/modules/tower_job_wait.py +++ b/awx_collection/plugins/modules/tower_job_wait.py @@ -149,5 +149,6 @@ def main(): module.exit_json(**module.json_output) + if __name__ == '__main__': main() diff --git a/awx_collection/plugins/modules/tower_workflow_launch.py b/awx_collection/plugins/modules/tower_workflow_launch.py index 8267e9352c..f8ab793bad 100644 --- a/awx_collection/plugins/modules/tower_workflow_launch.py +++ b/awx_collection/plugins/modules/tower_workflow_launch.py @@ -176,7 +176,7 @@ def main(): if not wait: module.exit_json(**module.json_output) - + # Invoke wait function module.wait_on_url( url=result['json']['url'], From 50637807fcb78c30497376339fc3f6445a0f85cc Mon Sep 17 00:00:00 2001 From: sean-m-sullivan Date: Tue, 1 Sep 2020 10:38:15 -0500 Subject: [PATCH 10/11] fixed typo --- awx_collection/plugins/module_utils/tower_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx_collection/plugins/module_utils/tower_api.py b/awx_collection/plugins/module_utils/tower_api.py index 78df3e7337..1bc76a84b1 100644 --- a/awx_collection/plugins/module_utils/tower_api.py +++ b/awx_collection/plugins/module_utils/tower_api.py @@ -599,7 +599,7 @@ class TowerAPIModule(TowerModule): if timeout and timeout < time.time() - start: # Account for Legacy messages if object_type is 'legacy_job_wait': - self.json_output['msg'] = 'Monitoring of Job - {1} aborted due to timeout'.format(object_name) + self.json_output['msg'] = 'Monitoring of Job - {0} aborted due to timeout'.format(object_name) else: self.json_output['msg'] = 'Monitoring of {0} - {1} aborted due to timeout'.format(object_type, object_name) self.wait_output(result) From 9f3635be07a81dd4730a113d01e8a43e374f01a2 Mon Sep 17 00:00:00 2001 From: sean-m-sullivan Date: Tue, 1 Sep 2020 10:45:41 -0500 Subject: [PATCH 11/11] update test to timeout message change --- .../integration/targets/tower_workflow_launch/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx_collection/tests/integration/targets/tower_workflow_launch/tasks/main.yml b/awx_collection/tests/integration/targets/tower_workflow_launch/tasks/main.yml index bf88aecf7d..680b629473 100644 --- a/awx_collection/tests/integration/targets/tower_workflow_launch/tasks/main.yml +++ b/awx_collection/tests/integration/targets/tower_workflow_launch/tasks/main.yml @@ -53,7 +53,7 @@ - assert: that: - result is failed - - "'Monitoring aborted due to timeout' in result.msg" + - "'Monitoring of Workflow Job - {{ wfjt_name1 }} aborted due to timeout' in result.msg" - name: Kick off a workflow and wait for it tower_workflow_launch: