本文介绍了Ansible lineinfile insertafter在文件末尾插入行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用lineinfile,如下所示:
I'm using lineinfile as follows:
lineinfile dest=./hosts_exp insertafter='\[hosts1\]' line="xxxxxxxxx" state=present我的hosts_exp如下:
[local] localhost [hosts1] [hosts2] [hosts3]lineinfile在[hosts3]之后插入文本,而不是在[hosts1]之后插入文本.
lineinfile inserts the text after [hosts3] instead of inserting it after [hosts1].
推荐答案使用:
lineinfile: dest: "./hosts_exp" line: "xxxxxxxxx" insertafter: '^\[hosts1\]' state: present更多推荐
Ansible lineinfile insertafter在文件末尾插入行
发布评论