fix another encrypted survey password bug

properly encrypt extra_vars that overlap with survey passwords when
`ask_variables_on_launch=true`

see: https://github.com/ansible/ansible-tower/issues/7796
This commit is contained in:
Ryan Petrello
2017-11-28 16:52:47 -05:00
parent 7b42316366
commit 1425021106
3 changed files with 16 additions and 8 deletions

View File

@@ -136,7 +136,7 @@ class SurveyJobTemplateMixin(models.Model):
else:
runtime_extra_vars = {}
# Overwrite with job template extra vars with survey default vars
# Overwrite job template extra vars with survey default vars
if self.survey_enabled and 'spec' in self.survey_spec:
for survey_element in self.survey_spec.get("spec", []):
default = survey_element.get('default')
@@ -145,7 +145,7 @@ class SurveyJobTemplateMixin(models.Model):
if survey_element.get('type') == 'password':
if variable_key in runtime_extra_vars and default:
kw_value = runtime_extra_vars[variable_key]
if kw_value.startswith('$encrypted$') and kw_value != default:
if kw_value == '$encrypted$' and kw_value != default:
runtime_extra_vars[variable_key] = default
if default is not None: