ansible - 如何用ansible playbook替换具有多个特殊字符的行
问题描述
尝试替换具有多个特殊字符的行,这些特殊字符被 ansible 解释为转义字符。
尝试使用“\”和“。” 对于每个角色,并尝试使用!不安全。
- name: Update file
replace:
path: /some/file
regexp: "*[0-9a-zA-Z._-]* )" #<<=== This is line to be replaced
replace: "*[0-9a-z._-]* )" #<<== With this
backup: yes
收到如下错误:
raise error, v # invalid expression\r\nsre_constants.error: nothing to repeat\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
解决方案
试过这个,它工作:
regexp: '\*\[0-9a-zA-Z\._-\]\* \)'
replace: '*[0-9a-z._-]* )'
推荐阅读
- python - 在 macos for python 上的 vscode 中安装 selenium 库
- opencv - Open CV capture read() 不读取特定视频帧 fps 59.9
- javascript - 我想加载一个已经使用flask发布请求的in vue,响应是它的路径
- reactjs - 为什么在循环内设置 useState 执行不同?
- devise - Rails:来自上下文的门卫自定义响应
- sql - 两个实体之间的多个多对多关系
- polyline - 如何在 api 4.15 中获得折线的范围?
- react-native - 不推荐使用 CameraRoll.saveToCameraRoll(tag,type) 使用保存功能
- ios - 当以编程方式约束时,如何在向下滚动时隐藏导航栏?
- reactjs - 状态在钩子返回的函数中没有改变