fix: 修复ansible 任务 {{123}} 这样的密码失败问题

pull/12365/head
feng 2023-12-19 14:57:51 +08:00
parent 1afad40dd3
commit da8d78f384
1 changed files with 11 additions and 5 deletions

View File

@ -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():