当使用ansible的blockinfile模块时,如果我们使用regex_replace过滤器,过滤器的参数必须更改才能使其工作。这违反了过滤器的文档。转义是由模板引擎完成的吗?
https://github.com/ansible/ansible-modules-extras/issues/3105在提供重要信息的外部网站的链接上提问通常是一个不好的做法。
至于你的问题,你使用或不使用转义取决于外部字符串引号:
# don't escape
block: |
RewriteCond %{HTTP_HOST} ={{ url | regex_replace('(?:https?://)?([^/:]+)?.*', '1') }}
# escape
block: "RewriteCond %{HTTP_HOST} ={{ url | regex_replace('(?:https?://)?([^/:]+)?.*', '\1') }}"