mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 01:17:37 -02:30
fix error processing survey vars
This commit is contained in:
@@ -446,11 +446,21 @@ class JobTemplate(UnifiedJobTemplate, JobOptions, ResourceMixin):
|
|||||||
if field == 'extra_vars' and self.survey_enabled and self.survey_spec:
|
if field == 'extra_vars' and self.survey_enabled and self.survey_spec:
|
||||||
# Accept vars defined in the survey and no others
|
# Accept vars defined in the survey and no others
|
||||||
survey_vars = [question['variable'] for question in self.survey_spec.get('spec', [])]
|
survey_vars = [question['variable'] for question in self.survey_spec.get('spec', [])]
|
||||||
for key in kwargs[field]:
|
extra_vars = kwargs[field]
|
||||||
|
if isinstance(extra_vars, basestring):
|
||||||
|
try:
|
||||||
|
extra_vars = json.loads(extra_vars)
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
try:
|
||||||
|
extra_vars = yaml.safe_load(extra_vars)
|
||||||
|
assert isinstance(extra_vars, dict)
|
||||||
|
except (yaml.YAMLError, TypeError, AttributeError, AssertionError):
|
||||||
|
extra_vars = {}
|
||||||
|
for key in extra_vars:
|
||||||
if key in survey_vars:
|
if key in survey_vars:
|
||||||
prompted_fields[field][key] = kwargs[field][key]
|
prompted_fields[field][key] = extra_vars[key]
|
||||||
else:
|
else:
|
||||||
ignored_fields[field][key] = kwargs[field][key]
|
ignored_fields[field][key] = extra_vars[key]
|
||||||
else:
|
else:
|
||||||
ignored_fields[field] = kwargs[field]
|
ignored_fields[field] = kwargs[field]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user