mirror of
https://github.com/ansible/awx.git
synced 2026-05-13 12:27:37 -02:30
Fix sanity tests and edit test playbook
This commit is contained in:
@@ -68,6 +68,12 @@ options:
|
|||||||
- If waiting for the workflow to complete this will abort after this
|
- If waiting for the workflow to complete this will abort after this
|
||||||
amount of seconds
|
amount of seconds
|
||||||
type: int
|
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
|
extends_documentation_fragment: awx.awx.auth
|
||||||
'''
|
'''
|
||||||
|
|
||||||
@@ -108,6 +114,7 @@ def main():
|
|||||||
organization=dict(),
|
organization=dict(),
|
||||||
inventory=dict(),
|
inventory=dict(),
|
||||||
limit=dict(),
|
limit=dict(),
|
||||||
|
scm_branch=dict(),
|
||||||
extra_vars=dict(),
|
extra_vars=dict(),
|
||||||
wait=dict(required=False, default=True, type='bool'),
|
wait=dict(required=False, default=True, type='bool'),
|
||||||
interval=dict(required=False, default=1.0, type='float'),
|
interval=dict(required=False, default=1.0, type='float'),
|
||||||
@@ -138,12 +145,11 @@ def main():
|
|||||||
if inventory:
|
if inventory:
|
||||||
post_data['inventory'] = module.resolve_name_to_id('inventories', inventory)
|
post_data['inventory'] = module.resolve_name_to_id('inventories', inventory)
|
||||||
|
|
||||||
|
|
||||||
# Attempt to look up job_template based on the provided name
|
# Attempt to look up job_template based on the provided name
|
||||||
lookup_data = { 'name': name }
|
lookup_data = {'name': name}
|
||||||
if organization:
|
if organization:
|
||||||
lookup_data['organization'] = module.resolve_name_to_id('organizations', 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:
|
if workflow_job_template is None:
|
||||||
module.fail_json(msg="Unable to find workflow job template")
|
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['id'] = result['json']['id']
|
||||||
module.json_output['status'] = result['json']['status']
|
module.json_output['status'] = result['json']['status']
|
||||||
# This is for backwards compatability
|
# 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:
|
if not wait:
|
||||||
module.exit_json(**module.json_output)
|
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 the job has failed, we want to raise an Exception for that so we get a non-zero response.
|
||||||
if result['json']['failed']:
|
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.fail_json(**module.json_output)
|
||||||
|
|
||||||
module.exit_json(**module.json_output)
|
module.exit_json(**module.json_output)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
- name: Generate a random string for test
|
- name: Generate a random string for test
|
||||||
set_fact:
|
set_fact:
|
||||||
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||||
@@ -7,6 +8,11 @@
|
|||||||
set_fact:
|
set_fact:
|
||||||
wfjt_name1: "Testing Workflow Job Launch" #"AWX-Collection-tests-tower_workflow_launch--wfjt1-{{ test_id }}"
|
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
|
- name: Create our workflow
|
||||||
tower_workflow_job_template:
|
tower_workflow_job_template:
|
||||||
name: "{{ wfjt_name1 }}"
|
name: "{{ wfjt_name1 }}"
|
||||||
@@ -68,8 +74,3 @@
|
|||||||
that:
|
that:
|
||||||
- result is failed
|
- result is failed
|
||||||
- "'Monitoring aborted due to timeout' in result.msg"
|
- "'Monitoring aborted due to timeout' in result.msg"
|
||||||
|
|
||||||
- name: Cleanup workflow
|
|
||||||
tower_workflow_job_template:
|
|
||||||
name: "{{ wfjt_name1 }}"
|
|
||||||
state: absent
|
|
||||||
|
|||||||
Reference in New Issue
Block a user