mirror of
https://github.com/ansible/awx.git
synced 2026-02-19 04:00:06 -03:30
Adding EE/IG/labels/forks/timeout/job_slice_count to schedules
Modifying schedules to work with related fields Updating awx.awx.workflow_job_template_node
This commit is contained in:
committed by
Alan Rominger
parent
2e217ed466
commit
809df74050
@@ -42,17 +42,37 @@ options:
|
||||
- Optional description of this schedule.
|
||||
required: False
|
||||
type: str
|
||||
execution_environment:
|
||||
description:
|
||||
- Execution Environment applied as a prompt, assuming jot template prompts for execution environment
|
||||
type: str
|
||||
extra_data:
|
||||
description:
|
||||
- Specify C(extra_vars) for the template.
|
||||
required: False
|
||||
type: dict
|
||||
default: {}
|
||||
forks:
|
||||
description:
|
||||
- Forks applied as a prompt, assuming job template prompts for forks
|
||||
type: int
|
||||
instance_groups:
|
||||
description:
|
||||
- List of Instance Groups applied as a prompt, assuming job template prompts for instance groups
|
||||
type: list
|
||||
elements: str
|
||||
inventory:
|
||||
description:
|
||||
- Inventory applied as a prompt, assuming job template prompts for inventory
|
||||
required: False
|
||||
type: str
|
||||
job_slice_count:
|
||||
description:
|
||||
- Job Slice Count applied as a prompt, assuming job template prompts for job slice count
|
||||
type: int
|
||||
labels:
|
||||
description:
|
||||
- List of labels applied as a prompt, assuming job template prompts for labels
|
||||
credentials:
|
||||
description:
|
||||
- List of credentials applied as a prompt, assuming job template prompts for credentials
|
||||
@@ -63,6 +83,10 @@ options:
|
||||
- Branch to use in job run. Project default used if blank. Only allowed if project allow_override field is set to true.
|
||||
required: False
|
||||
type: str
|
||||
timeout:
|
||||
description:
|
||||
- Timeout applied as a prompt, assuming job template prompts for timeout
|
||||
type: int
|
||||
job_type:
|
||||
description:
|
||||
- The job type to use for the job template.
|
||||
@@ -176,8 +200,14 @@ def main():
|
||||
name=dict(required=True),
|
||||
new_name=dict(),
|
||||
description=dict(),
|
||||
execution_environment=dict(type='str'),
|
||||
extra_data=dict(type='dict'),
|
||||
forks=dict(type='int'),
|
||||
instance_groups=dict(type='list', elements='str'),
|
||||
inventory=dict(),
|
||||
job_slice_count=dict(type='int'),
|
||||
labels=dict(type='list', elements='str'),
|
||||
timeout=dict(type='int'),
|
||||
credentials=dict(type='list', elements='str'),
|
||||
scm_branch=dict(),
|
||||
job_type=dict(choices=['run', 'check']),
|
||||
@@ -200,8 +230,14 @@ def main():
|
||||
name = module.params.get('name')
|
||||
new_name = module.params.get("new_name")
|
||||
description = module.params.get('description')
|
||||
execution_environment = module.params.get('execution_environment')
|
||||
extra_data = module.params.get('extra_data')
|
||||
forks = module.params.get('forks')
|
||||
instance_groups = module.params.get('instance_groups')
|
||||
inventory = module.params.get('inventory')
|
||||
job_slice_count = module.params.get('job_slice_count')
|
||||
labels = module.params.get('labels')
|
||||
timeout = module.params.get('timeout')
|
||||
credentials = module.params.get('credentials')
|
||||
scm_branch = module.params.get('scm_branch')
|
||||
job_type = module.params.get('job_type')
|
||||
@@ -238,6 +274,28 @@ def main():
|
||||
for item in credentials:
|
||||
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
|
||||
if 'name' in search_fields:
|
||||
del search_fields['name']
|
||||
|
||||
if labels is not None:
|
||||
association_fields['labels'] = []
|
||||
for item in labels:
|
||||
label_id = module.get_one('labels', name_or_id=item, **{'data': search_fields})
|
||||
if label_id is None:
|
||||
module.fail_json(msg='Could not find label entry with name {0}'.format(item))
|
||||
else:
|
||||
association_fields['labels'].append(label_id['id'])
|
||||
|
||||
if instance_groups is not None:
|
||||
association_fields['instance_groups'] = []
|
||||
for item in instance_groups:
|
||||
instance_group_id = module.get_one('instance_groups', name_or_id=item, **{'data': search_fields})
|
||||
if instance_group_id is None:
|
||||
module.fail_json(msg='Could not find instance_group entry with name {0}'.format(item))
|
||||
else:
|
||||
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:
|
||||
@@ -267,6 +325,22 @@ def main():
|
||||
new_fields['unified_job_template'] = unified_job_template_id
|
||||
if enabled is not None:
|
||||
new_fields['enabled'] = enabled
|
||||
if forks is not None:
|
||||
new_fields['forks'] = forks
|
||||
if job_slice_count is not None:
|
||||
new_fields['job_slice_count'] = job_slice_count
|
||||
if timeout is not None:
|
||||
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 state == 'absent':
|
||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||
|
||||
@@ -152,6 +152,30 @@ options:
|
||||
- Uniqueness is not handled rigorously.
|
||||
type: list
|
||||
elements: str
|
||||
execution_environment:
|
||||
description:
|
||||
- Execution Environment applied as a prompt, assuming jot template prompts for execution environment
|
||||
type: str
|
||||
forks:
|
||||
description:
|
||||
- Forks applied as a prompt, assuming job template prompts for forks
|
||||
type: int
|
||||
instance_groups:
|
||||
description:
|
||||
- List of Instance Groups applied as a prompt, assuming job template prompts for instance groups
|
||||
type: list
|
||||
elements: str
|
||||
job_slice_count:
|
||||
description:
|
||||
- Job Slice Count applied as a prompt, assuming job template prompts for job slice count
|
||||
type: int
|
||||
labels:
|
||||
description:
|
||||
- List of labels applied as a prompt, assuming job template prompts for labels
|
||||
timeout:
|
||||
description:
|
||||
- Timeout applied as a prompt, assuming job template prompts for timeout
|
||||
type: int
|
||||
state:
|
||||
description:
|
||||
- Desired state of the resource.
|
||||
@@ -255,6 +279,12 @@ def main():
|
||||
always_nodes=dict(type='list', elements='str'),
|
||||
failure_nodes=dict(type='list', elements='str'),
|
||||
credentials=dict(type='list', elements='str'),
|
||||
execution_environment=dict(type='str'),
|
||||
forks=dict(type='int'),
|
||||
instance_groups=dict(type='list', elements='str'),
|
||||
job_slice_count=dict(type='int'),
|
||||
labels=dict(type='list', elements='str'),
|
||||
timeout=dict(type='int'),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
)
|
||||
mutually_exclusive = [("unified_job_template", "approval_node")]
|
||||
@@ -327,32 +357,44 @@ def main():
|
||||
'diff_mode',
|
||||
'verbosity',
|
||||
'all_parents_must_converge',
|
||||
'forks',
|
||||
'job_slice_count',
|
||||
'timeout',
|
||||
):
|
||||
field_val = module.params.get(field_name)
|
||||
if field_val:
|
||||
new_fields[field_name] = field_val
|
||||
|
||||
association_fields = {}
|
||||
for association in ('always_nodes', 'success_nodes', 'failure_nodes', 'credentials'):
|
||||
for association in ('always_nodes', 'success_nodes', 'failure_nodes', 'credentials', 'instance_groups', 'labels'):
|
||||
name_list = module.params.get(association)
|
||||
if name_list is None:
|
||||
continue
|
||||
id_list = []
|
||||
for sub_name in name_list:
|
||||
if association == 'credentials':
|
||||
endpoint = 'credentials'
|
||||
lookup_data = {'name': sub_name}
|
||||
if association in ['credentials', 'instance_groups', 'labels']:
|
||||
sub_obj = module.get_one(association, name_or_id=sub_name)
|
||||
else:
|
||||
endpoint = 'workflow_job_template_nodes'
|
||||
lookup_data = {'identifier': sub_name}
|
||||
if workflow_job_template_id:
|
||||
lookup_data['workflow_job_template'] = workflow_job_template_id
|
||||
sub_obj = module.get_one(endpoint, **{'data': lookup_data})
|
||||
sub_obj = module.get_one(endpoint, **{'data': lookup_data})
|
||||
if sub_obj is None:
|
||||
module.fail_json(msg='Could not find {0} entry with name {1}'.format(association, sub_name))
|
||||
id_list.append(sub_obj['id'])
|
||||
if id_list:
|
||||
association_fields[association] = id_list
|
||||
association_fields[association] = id_list
|
||||
|
||||
execution_environment = module.params.get('execution_environment')
|
||||
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)
|
||||
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']
|
||||
|
||||
# In the case of a new object, the utils need to know it is a node
|
||||
new_fields['type'] = 'workflow_job_template_node'
|
||||
|
||||
Reference in New Issue
Block a user