mirror of
https://github.com/ansible/awx.git
synced 2026-05-06 08:57:35 -02:30
don't pass the 'organization' or other fields to the search of the instance group or execution environments (#14223)
This commit is contained in:
committed by
GitHub
parent
8feeb5f1fa
commit
49832d6379
@@ -273,6 +273,26 @@ def main():
|
|||||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||||
module.delete_if_needed(existing_item)
|
module.delete_if_needed(existing_item)
|
||||||
|
|
||||||
|
# We need to clear out the name from the search fields so we can use name_or_id in the following searches
|
||||||
|
if 'name' in search_fields:
|
||||||
|
del search_fields['name']
|
||||||
|
|
||||||
|
# Create the data that gets sent for create and update
|
||||||
|
new_fields = {}
|
||||||
|
if execution_environment is not None:
|
||||||
|
if execution_environment == '':
|
||||||
|
new_fields['execution_environment'] = ''
|
||||||
|
else:
|
||||||
|
ee = module.get_one('execution_environments', name_or_id=execution_environment, **{'data': search_fields})
|
||||||
|
if ee is None:
|
||||||
|
ee2 = module.get_one('execution_environments', name_or_id=execution_environment)
|
||||||
|
if ee2 is None or ee2['organization'] is not None:
|
||||||
|
module.fail_json(msg='could not find execution_environment entry with name {0}'.format(execution_environment))
|
||||||
|
else:
|
||||||
|
new_fields['execution_environment'] = ee2['id']
|
||||||
|
else:
|
||||||
|
new_fields['execution_environment'] = ee['id']
|
||||||
|
|
||||||
association_fields = {}
|
association_fields = {}
|
||||||
|
|
||||||
if credentials is not None:
|
if credentials is not None:
|
||||||
@@ -280,9 +300,9 @@ def main():
|
|||||||
for item in credentials:
|
for item in credentials:
|
||||||
association_fields['credentials'].append(module.resolve_name_to_id('credentials', item))
|
association_fields['credentials'].append(module.resolve_name_to_id('credentials', item))
|
||||||
|
|
||||||
# We need to clear out the name from the search fields so we can use name_or_id in the following searches
|
# We need to clear out the organization from the search fields the searches for labels and instance_groups doesnt support it and won't be needed anymore
|
||||||
if 'name' in search_fields:
|
if 'organization' in search_fields:
|
||||||
del search_fields['name']
|
del search_fields['organization']
|
||||||
|
|
||||||
if labels is not None:
|
if labels is not None:
|
||||||
association_fields['labels'] = []
|
association_fields['labels'] = []
|
||||||
@@ -302,8 +322,6 @@ def main():
|
|||||||
else:
|
else:
|
||||||
association_fields['instance_groups'].append(instance_group_id['id'])
|
association_fields['instance_groups'].append(instance_group_id['id'])
|
||||||
|
|
||||||
# Create the data that gets sent for create and update
|
|
||||||
new_fields = {}
|
|
||||||
if rrule is not None:
|
if rrule is not None:
|
||||||
new_fields['rrule'] = rrule
|
new_fields['rrule'] = rrule
|
||||||
new_fields['name'] = new_name if new_name else (module.get_item_name(existing_item) if existing_item else name)
|
new_fields['name'] = new_name if new_name else (module.get_item_name(existing_item) if existing_item else name)
|
||||||
@@ -338,16 +356,6 @@ def main():
|
|||||||
if timeout is not None:
|
if timeout is not None:
|
||||||
new_fields['timeout'] = timeout
|
new_fields['timeout'] = timeout
|
||||||
|
|
||||||
if execution_environment is not None:
|
|
||||||
if execution_environment == '':
|
|
||||||
new_fields['execution_environment'] = ''
|
|
||||||
else:
|
|
||||||
ee = module.get_one('execution_environments', name_or_id=execution_environment, **{'data': search_fields})
|
|
||||||
if ee is None:
|
|
||||||
module.fail_json(msg='could not find execution_environment entry with name {0}'.format(execution_environment))
|
|
||||||
else:
|
|
||||||
new_fields['execution_environment'] = ee['id']
|
|
||||||
|
|
||||||
# If the state was present and we can let the module build or update the existing item, this will return on its own
|
# If the state was present and we can let the module build or update the existing item, this will return on its own
|
||||||
module.create_or_update_if_needed(
|
module.create_or_update_if_needed(
|
||||||
existing_item,
|
existing_item,
|
||||||
|
|||||||
@@ -225,6 +225,7 @@
|
|||||||
schedule:
|
schedule:
|
||||||
name: "{{ sched2 }}"
|
name: "{{ sched2 }}"
|
||||||
state: present
|
state: present
|
||||||
|
organization: Default
|
||||||
unified_job_template: "{{ jt1 }}"
|
unified_job_template: "{{ jt1 }}"
|
||||||
rrule: "DTSTART:20191219T130551Z RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1"
|
rrule: "DTSTART:20191219T130551Z RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1"
|
||||||
description: "This hopefully will work"
|
description: "This hopefully will work"
|
||||||
|
|||||||
Reference in New Issue
Block a user