Ansible Regex(Python)排除操作

2024-06-24 13:25:29 发布

您现在位置:Python中文网/ 问答频道 /正文

Ansible使用python正则表达式搜索模式并替换字符串。 文档链接:http://docs.ansible.com/ansible/lineinfile_module.html

下面一行是文件中的一行“文件.txt". 在

JAVA_OPT=“firststring=value”

我想用字符串'secondstring=value'连接它,如果有字符串,就避免连接操作。在

lineinfile:dest=“/home/abc”/文件.txt“regexp='^JAVA\u OPT=”(.*)“line='JAVA'u OPT=“\1 secondstring=value”'backrefs=“是”

我要下面的字符串不管多个运行。目前,它在每次运行时都连接字符串。 JAVA_OPT=“firststring=value secondstring=value”


Tags: 文件字符串文档txthttpvalue链接模式