mirror of
https://github.com/ansible/awx.git
synced 2026-02-24 14:36:00 -03:30
Merge pull request #11198 from sean-m-sullivan/name_or_id_workflow_node
update to allow use of id for unified job template
This commit is contained in:
@@ -482,20 +482,17 @@ def create_schema_nodes(module, response, schema, workflow_id):
|
|||||||
|
|
||||||
# Lookup Job Template ID
|
# Lookup Job Template ID
|
||||||
if workflow_node['unified_job_template']['name']:
|
if workflow_node['unified_job_template']['name']:
|
||||||
search_fields = {'name': workflow_node['unified_job_template']['name']}
|
|
||||||
if workflow_node['unified_job_template']['type'] is None:
|
if workflow_node['unified_job_template']['type'] is None:
|
||||||
module.fail_json(msg='Could not find unified job template type in schema {1}'.format(workflow_node))
|
module.fail_json(msg='Could not find unified job template type in schema {1}'.format(workflow_node))
|
||||||
if workflow_node['unified_job_template']['type'] == 'inventory_source':
|
if workflow_node['unified_job_template']['type'] == 'inventory_source':
|
||||||
# workflow_node['unified_job_template']['inventory']:
|
|
||||||
organization_id = module.resolve_name_to_id('organizations', workflow_node['unified_job_template']['inventory']['organization']['name'])
|
organization_id = module.resolve_name_to_id('organizations', workflow_node['unified_job_template']['inventory']['organization']['name'])
|
||||||
search_fields['organization'] = organization_id
|
search_fields['organization'] = organization_id
|
||||||
elif workflow_node['unified_job_template']['type'] == 'workflow_approval':
|
elif workflow_node['unified_job_template']['type'] == 'workflow_approval':
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# workflow_node['unified_job_template']['organization']:
|
|
||||||
organization_id = module.resolve_name_to_id('organizations', workflow_node['unified_job_template']['organization']['name'])
|
organization_id = module.resolve_name_to_id('organizations', workflow_node['unified_job_template']['organization']['name'])
|
||||||
search_fields['organization'] = organization_id
|
search_fields['organization'] = organization_id
|
||||||
unified_job_template = module.get_one('unified_job_templates', **{'data': search_fields})
|
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:
|
if unified_job_template:
|
||||||
workflow_node_fields['unified_job_template'] = unified_job_template['id']
|
workflow_node_fields['unified_job_template'] = unified_job_template['id']
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -310,9 +310,7 @@ def main():
|
|||||||
|
|
||||||
unified_job_template = module.params.get('unified_job_template')
|
unified_job_template = module.params.get('unified_job_template')
|
||||||
if unified_job_template:
|
if unified_job_template:
|
||||||
search_fields['name'] = unified_job_template
|
new_fields['unified_job_template'] = module.get_one('unified_job_templates', name_or_id=unified_job_template, **{'data': search_fields})['id']
|
||||||
new_fields['unified_job_template'] = module.get_one('unified_job_templates', **{'data': search_fields})['id']
|
|
||||||
|
|
||||||
inventory = module.params.get('inventory')
|
inventory = module.params.get('inventory')
|
||||||
if inventory:
|
if inventory:
|
||||||
new_fields['inventory'] = module.resolve_name_to_id('inventories', inventory)
|
new_fields['inventory'] = module.resolve_name_to_id('inventories', inventory)
|
||||||
|
|||||||
@@ -117,11 +117,11 @@
|
|||||||
source_path: "/inventories/inventory.ini"
|
source_path: "/inventories/inventory.ini"
|
||||||
overwrite: true
|
overwrite: true
|
||||||
source: scm
|
source: scm
|
||||||
register: result
|
register: project_inv_source_result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- "project_inv_source_result is changed"
|
||||||
|
|
||||||
- name: Create a Job Template
|
- name: Create a Job Template
|
||||||
job_template:
|
job_template:
|
||||||
@@ -159,11 +159,11 @@
|
|||||||
playbook: hello_world.yml
|
playbook: hello_world.yml
|
||||||
job_type: run
|
job_type: run
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: jt2_name_result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- "jt2_name_result is changed"
|
||||||
|
|
||||||
- name: Add a Survey to second Job Template
|
- name: Add a Survey to second Job Template
|
||||||
job_template:
|
job_template:
|
||||||
@@ -536,7 +536,7 @@
|
|||||||
schema:
|
schema:
|
||||||
- identifier: node101
|
- identifier: node101
|
||||||
unified_job_template:
|
unified_job_template:
|
||||||
name: "{{ project_inv_source }}"
|
name: "{{ project_inv_source_result.id }}"
|
||||||
inventory:
|
inventory:
|
||||||
organization:
|
organization:
|
||||||
name: Default
|
name: Default
|
||||||
|
|||||||
Reference in New Issue
Block a user