mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 16:51:11 +03:00
upgrade survey encryption migration to work around an old survey bug
see: https://github.com/ansible/ansible-tower/issues/7800
This commit is contained in:
parent
fc4b02b79f
commit
8c6a1e348d
@ -92,7 +92,18 @@ def _encrypt_survey_passwords(Job, JobTemplate, WorkflowJob, WorkflowJobTemplate
|
|||||||
if jt.survey_spec.get('spec', []):
|
if jt.survey_spec.get('spec', []):
|
||||||
for field in jt.survey_spec['spec']:
|
for field in jt.survey_spec['spec']:
|
||||||
if field.get('type') == 'password' and field.get('default', ''):
|
if field.get('type') == 'password' and field.get('default', ''):
|
||||||
if field['default'].startswith('$encrypted$'):
|
default = field['default']
|
||||||
|
if default.startswith('$encrypted$'):
|
||||||
|
if default == '$encrypted$':
|
||||||
|
# If you have a survey_spec with a literal
|
||||||
|
# '$encrypted$' as the default, you have
|
||||||
|
# encountered a known bug in awx/Tower
|
||||||
|
# https://github.com/ansible/ansible-tower/issues/7800
|
||||||
|
logger.error(
|
||||||
|
'{}.pk={} survey_spec has ambiguous $encrypted$ default for {}, needs attention...'.format(jt, jt.pk, field['variable'])
|
||||||
|
)
|
||||||
|
field['default'] = ''
|
||||||
|
changed = True
|
||||||
continue
|
continue
|
||||||
field['default'] = encrypt_value(field['default'], pk=None)
|
field['default'] = encrypt_value(field['default'], pk=None)
|
||||||
changed = True
|
changed = True
|
||||||
|
Loading…
Reference in New Issue
Block a user