Merge pull request #12365 from jumpserver/pr@dev@ansible

fix: 修复ansible 任务 {{123}} 这样的密码失败问题
pull/12366/head
huailei 12 months ago committed by GitHub
commit c441e5bb92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -128,13 +128,19 @@ class Account(AbsConnectivity, LabeledMixin, BaseAccount):
if not isinstance(value, str):
return value
value = value.replace('{{', '__TEMP_OPEN_BRACES__') \
.replace('}}', '__TEMP_CLOSE_BRACES__')
def escape(v):
v = v.replace('{{', '__TEMP_OPEN_BRACES__') \
.replace('}}', '__TEMP_CLOSE_BRACES__')
value = value.replace('__TEMP_OPEN_BRACES__', '{{ "{{" }}') \
.replace('__TEMP_CLOSE_BRACES__', '{{ "}}" }}')
v = v.replace('__TEMP_OPEN_BRACES__', '{{ "{{" }}') \
.replace('__TEMP_CLOSE_BRACES__', '{{ "}}" }}')
return value.replace('{%', '{{ "{%" }}').replace('%}', '{{ "%}" }}')
return v.replace('{%', '{{ "{%" }}').replace('%}', '{{ "%}" }}')
if value.startswith('{{') and value.endswith('}}'):
return '{{' + escape(value[2:-2]) + '}}'
else:
return escape(value)
def replace_history_model_with_mixin():

Loading…
Cancel
Save