Think before you speak, read before you think.

ansible lineinfile 改文件某一行

添加

ansible all -i jpuyy-com-lan -m lineinfile -a "dest=/etc/hosts line='115.239.28.20 api.jpuyy.com'" -s

删除

ansible all -i jpuyy-com-lan -m lineinfile -a "dest=/etc/hosts line='115.239.28.20 api.jpuyy.com' state=absent" -s 

更改某一行

ansible all -i jpuyy-com-lan -m lineinfile -a "dest=/etc/env.yaml line='idc: sh' regexp='idc: qcloud'" -s

Comments

2 responses to “ansible lineinfile 改文件某一行”

  1. 更改某一行的时候,这个是在文件末尾追加了,并没有更改,求指教

  2. 没有匹配成功

Leave a Reply

Your email address will not be published. Required fields are marked *