我正在尝试用包含反斜杠
的字符串替换模式- name: Replace test
replace: dest=/tmp/test
regexp="test"
replace="test, \"
我在ansible中收到以下错误:
The error appears to have been in '/home/deployer/ansible/roles/test/tasks/configuration.yml': line 11, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Replace test
^ here
答案 0 :(得分:1)
尽管您已经省略了以单词ERROR!
开头的实际错误消息,但这是您问题的解决方法:
- name: Replace test
replace:
dest: /tmp/test
regexp: test
replace: 'test, \\'
param=value
简写)答案 1 :(得分:0)
另一个简单的解决方案是将转义的反斜杠留给ansible本身。这就是我要做的。
- set_fact:
replacer: '\'
- name: Replace test
replace:
dest: /tmp/test
regexp: test
replace: 'test, replacer'