From 9ddd020348d425739c91ba18d5138ef1bd8b4d7c Mon Sep 17 00:00:00 2001 From: beeankha Date: Tue, 7 Apr 2020 17:22:50 -0400 Subject: [PATCH] Fix sanity tests and edit test playbook --- .../plugins/modules/tower_workflow_launch.py | 16 +++++++++++----- .../targets/tower_workflow_launch/tasks/main.yml | 11 ++++++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/awx_collection/plugins/modules/tower_workflow_launch.py b/awx_collection/plugins/modules/tower_workflow_launch.py index 7d0a962ee5..31535fd52c 100644 --- a/awx_collection/plugins/modules/tower_workflow_launch.py +++ b/awx_collection/plugins/modules/tower_workflow_launch.py @@ -68,6 +68,12 @@ options: - If waiting for the workflow to complete this will abort after this amount of seconds type: int + tower_oauthtoken: + description: + - The Tower OAuth token to use. + required: False + type: str + version_added: "3.7" extends_documentation_fragment: awx.awx.auth ''' @@ -108,6 +114,7 @@ def main(): organization=dict(), inventory=dict(), limit=dict(), + scm_branch=dict(), extra_vars=dict(), wait=dict(required=False, default=True, type='bool'), interval=dict(required=False, default=1.0, type='float'), @@ -138,12 +145,11 @@ def main(): if inventory: post_data['inventory'] = module.resolve_name_to_id('inventories', inventory) - # Attempt to look up job_template based on the provided name - lookup_data = { 'name': name } + lookup_data = {'name': name} if organization: lookup_data['organization'] = module.resolve_name_to_id('organizations', organization) - workflow_job_template = module.get_one('workflow_job_templates', **{ 'data': lookup_data }) + workflow_job_template = module.get_one('workflow_job_templates', **{'data': lookup_data}) if workflow_job_template is None: module.fail_json(msg="Unable to find workflow job template") @@ -174,7 +180,7 @@ def main(): module.json_output['id'] = result['json']['id'] module.json_output['status'] = result['json']['status'] # This is for backwards compatability - module.json_output['job_info'] = { 'id': result['json']['id'] } + module.json_output['job_info'] = {'id': result['json']['id']} if not wait: module.exit_json(**module.json_output) @@ -197,7 +203,7 @@ def main(): # If the job has failed, we want to raise an Exception for that so we get a non-zero response. if result['json']['failed']: - module.json_output['msg'] = 'Job with id {0} failed'.format(job_id) + module.json_output['msg'] = 'The workflow "{0}" failed'.format(name) module.fail_json(**module.json_output) module.exit_json(**module.json_output) 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 9debcf7537..e32c406fe5 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 @@ -1,3 +1,4 @@ +--- - name: Generate a random string for test set_fact: test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" @@ -7,6 +8,11 @@ set_fact: wfjt_name1: "Testing Workflow Job Launch" #"AWX-Collection-tests-tower_workflow_launch--wfjt1-{{ test_id }}" +- name: Clean up test workflow from any previous runs + tower_workflow_job_template: + name: "{{ wfjt_name1 }}" + state: absent + - name: Create our workflow tower_workflow_job_template: name: "{{ wfjt_name1 }}" @@ -68,8 +74,3 @@ that: - result is failed - "'Monitoring aborted due to timeout' in result.msg" - -- name: Cleanup workflow - tower_workflow_job_template: - name: "{{ wfjt_name1 }}" - state: absent