mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 18:07:36 -02:30
fix chicken egg issue with workflow nodes and inventory sources for parents that do not exist (#15982)
fix chicken egg issue with workflow nodes and inventory sources for parents that do not exist
This commit is contained in:
@@ -230,7 +230,11 @@ def main():
|
|||||||
inventory_object = module.get_one('inventories', name_or_id=inventory, data=lookup_data)
|
inventory_object = module.get_one('inventories', name_or_id=inventory, data=lookup_data)
|
||||||
|
|
||||||
if not inventory_object:
|
if not inventory_object:
|
||||||
module.fail_json(msg='The specified inventory, {0}, was not found.'.format(lookup_data))
|
# if the inventory does not exist, then it can't have sources.
|
||||||
|
if state == 'absent':
|
||||||
|
module.exit_json(**module.json_output)
|
||||||
|
else:
|
||||||
|
module.fail_json(msg='The specified inventory, {0}, was not found.'.format(lookup_data))
|
||||||
|
|
||||||
inventory_source_object = module.get_one(
|
inventory_source_object = module.get_one(
|
||||||
'inventory_sources',
|
'inventory_sources',
|
||||||
|
|||||||
@@ -320,9 +320,13 @@ def main():
|
|||||||
wfjt_search_fields['organization'] = organization_id
|
wfjt_search_fields['organization'] = organization_id
|
||||||
wfjt_data = module.get_one('workflow_job_templates', name_or_id=workflow_job_template, **{'data': wfjt_search_fields})
|
wfjt_data = module.get_one('workflow_job_templates', name_or_id=workflow_job_template, **{'data': wfjt_search_fields})
|
||||||
if wfjt_data is None:
|
if wfjt_data is None:
|
||||||
module.fail_json(
|
if state == 'absent':
|
||||||
msg="The workflow {0} in organization {1} was not found on the controller instance server".format(workflow_job_template, organization)
|
# if the workflow doesn't exist, it can't have workflow nodes.
|
||||||
)
|
module.exit_json(**module.json_output)
|
||||||
|
else:
|
||||||
|
module.fail_json(
|
||||||
|
msg="The workflow {0} in organization {1} was not found on the controller instance server".format(workflow_job_template, organization)
|
||||||
|
)
|
||||||
workflow_job_template_id = wfjt_data['id']
|
workflow_job_template_id = wfjt_data['id']
|
||||||
search_fields['workflow_job_template'] = new_fields['workflow_job_template'] = workflow_job_template_id
|
search_fields['workflow_job_template'] = new_fields['workflow_job_template'] = workflow_job_template_id
|
||||||
|
|
||||||
|
|||||||
@@ -121,6 +121,22 @@
|
|||||||
that:
|
that:
|
||||||
- "result is changed"
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Attempt to delete an inventory source from an inventory that does not exist
|
||||||
|
inventory_source:
|
||||||
|
name: "{{ inv_source3 }}"
|
||||||
|
source: scm
|
||||||
|
state: absent
|
||||||
|
source_project: "{{ project_name }}"
|
||||||
|
source_path: inventories/create_100_hosts.ini
|
||||||
|
description: Source for Test inventory
|
||||||
|
organization: Default
|
||||||
|
inventory: Does not exist
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is not changed"
|
||||||
|
|
||||||
always:
|
always:
|
||||||
- name: Delete Inventory
|
- name: Delete Inventory
|
||||||
inventory:
|
inventory:
|
||||||
|
|||||||
@@ -428,6 +428,18 @@
|
|||||||
that:
|
that:
|
||||||
- "results is changed"
|
- "results is changed"
|
||||||
|
|
||||||
|
- name: Remove a node from a workflow that does not exist.
|
||||||
|
workflow_job_template_node:
|
||||||
|
identifier: root
|
||||||
|
unified_job_template: "{{ jt1_name }}"
|
||||||
|
workflow: Does not exist
|
||||||
|
state: absent
|
||||||
|
register: results
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "results is not changed"
|
||||||
|
|
||||||
- name: Create root node
|
- name: Create root node
|
||||||
workflow_job_template_node:
|
workflow_job_template_node:
|
||||||
identifier: root
|
identifier: root
|
||||||
|
|||||||
Reference in New Issue
Block a user