diff --git a/awx_collection/plugins/modules/workflow_job_template.py b/awx_collection/plugins/modules/workflow_job_template.py index d957d07f63..95ca933fdb 100644 --- a/awx_collection/plugins/modules/workflow_job_template.py +++ b/awx_collection/plugins/modules/workflow_job_template.py @@ -261,7 +261,7 @@ options: type: description: - Name of unified job template type to run in the workflow. - - Can be a job_template, project, inventory_source, workflow_approval. + - Can be a job_template, project, inventory_source, system_job, workflow_approval, workflow_job_template. type: str timeout: description: @@ -490,13 +490,17 @@ def create_workflow_nodes(module, response, workflow_nodes, workflow_id): if workflow_node['unified_job_template']['type'] is None: module.fail_json(msg='Could not find unified job template type in workflow_nodes {1}'.format(workflow_node)) if workflow_node['unified_job_template']['type'] == 'inventory_source': - organization_id = module.resolve_name_to_id('organizations', workflow_node['unified_job_template']['inventory']['organization']['name']) - search_fields['organization'] = organization_id - elif workflow_node['unified_job_template']['type'] == 'workflow_approval': - pass - else: + if 'inventory' in workflow_node['unified_job_template']: + if 'organization' in workflow_node['unified_job_template']['inventory']: + organization_id = module.resolve_name_to_id('organizations', workflow_node['unified_job_template']['inventory']['organization']['name']) + search_fields['organization'] = organization_id + else: + pass + elif 'organization' in workflow_node['unified_job_template']: organization_id = module.resolve_name_to_id('organizations', workflow_node['unified_job_template']['organization']['name']) search_fields['organization'] = organization_id + else: + pass unified_job_template = module.get_one('unified_job_templates', name_or_id=workflow_node['unified_job_template']['name'], **{'data': search_fields}) if unified_job_template: workflow_node_fields['unified_job_template'] = unified_job_template['id'] diff --git a/awx_collection/tests/integration/targets/workflow_job_template/tasks/main.yml b/awx_collection/tests/integration/targets/workflow_job_template/tasks/main.yml index e5cb958f54..3d9c147487 100644 --- a/awx_collection/tests/integration/targets/workflow_job_template/tasks/main.yml +++ b/awx_collection/tests/integration/targets/workflow_job_template/tasks/main.yml @@ -585,6 +585,10 @@ name: Default name: "{{ jt2_name }}" type: job_template + - identifier: Cleanup Job + unified_job_template: + name: Cleanup Activity Stream + type: system_job register: result - assert: @@ -624,6 +628,12 @@ organization: name: Default type: inventory_source + - identifier: Workflow inception + unified_job_template: + name: "{{ wfjt_name }}" + organization: + name: Default + type: workflow_job_template register: result - name: Kick off a workflow and wait for it