mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 07:26:03 -03:30
Merge pull request #787 from AlanCoding/workflow_system_jobs
allow using SystemJobTemplates in workflows
This commit is contained in:
@@ -3109,7 +3109,7 @@ class WorkflowJobTemplateNodeSerializer(LaunchConfigurationBaseSerializer):
|
|||||||
ujt_obj = None
|
ujt_obj = None
|
||||||
if self.instance:
|
if self.instance:
|
||||||
ujt_obj = self.instance.unified_job_template
|
ujt_obj = self.instance.unified_job_template
|
||||||
if isinstance(ujt_obj, (WorkflowJobTemplate, SystemJobTemplate)):
|
if isinstance(ujt_obj, (WorkflowJobTemplate)):
|
||||||
raise serializers.ValidationError({
|
raise serializers.ValidationError({
|
||||||
"unified_job_template": _("Cannot nest a %s inside a WorkflowJobTemplate") % ujt_obj.__class__.__name__})
|
"unified_job_template": _("Cannot nest a %s inside a WorkflowJobTemplate") % ujt_obj.__class__.__name__})
|
||||||
attrs = super(WorkflowJobTemplateNodeSerializer, self).validate(attrs)
|
attrs = super(WorkflowJobTemplateNodeSerializer, self).validate(attrs)
|
||||||
|
|||||||
@@ -2196,7 +2196,11 @@ class RunSystemJob(BaseTask):
|
|||||||
def build_args(self, system_job, **kwargs):
|
def build_args(self, system_job, **kwargs):
|
||||||
args = ['awx-manage', system_job.job_type]
|
args = ['awx-manage', system_job.job_type]
|
||||||
try:
|
try:
|
||||||
json_vars = json.loads(system_job.extra_vars)
|
# System Job extra_vars can be blank, must be JSON if not blank
|
||||||
|
if system_job.extra_vars == '':
|
||||||
|
json_vars = {}
|
||||||
|
else:
|
||||||
|
json_vars = json.loads(system_job.extra_vars)
|
||||||
if 'days' in json_vars and system_job.job_type != 'cleanup_facts':
|
if 'days' in json_vars and system_job.job_type != 'cleanup_facts':
|
||||||
args.extend(['--days', str(json_vars.get('days', 60))])
|
args.extend(['--days', str(json_vars.get('days', 60))])
|
||||||
if 'dry_run' in json_vars and json_vars['dry_run'] and system_job.job_type != 'cleanup_facts':
|
if 'dry_run' in json_vars and json_vars['dry_run'] and system_job.job_type != 'cleanup_facts':
|
||||||
@@ -2211,7 +2215,7 @@ class RunSystemJob(BaseTask):
|
|||||||
if 'granularity' in json_vars:
|
if 'granularity' in json_vars:
|
||||||
args.extend(['--granularity', str(json_vars['granularity'])])
|
args.extend(['--granularity', str(json_vars['granularity'])])
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("%s Failed to parse system job", instance.log_format)
|
logger.exception("%s Failed to parse system job", system_job.log_format)
|
||||||
return args
|
return args
|
||||||
|
|
||||||
def get_stdout_handle(self, instance):
|
def get_stdout_handle(self, instance):
|
||||||
|
|||||||
Reference in New Issue
Block a user