【发布时间】:2016-05-19 11:41:54
【问题描述】:
我正在使用Ansible replace module 替换一个字符串,该字符串是我的正则表达式的第一组。
- name: Replace my_address
replace:
dest=/etc/mydata/info.yaml
regexp="^my_address\W\s(localhost)$"
replace="{{ ansible_eth0.ipv4.address }}"
在我的文件中,我多次提及localhost,我只想在以下行替换localhost:my_address: localhost。
到目前为止,上面的代码将整行替换为 IP 地址。有没有办法只替换第一组正则表达式?
【问题讨论】:
标签: regex ansible ansible-playbook