【发布时间】:2020-02-27 13:34:24
【问题描述】:
我想在特定的行间多次添加一行。我尝试使用我的剧本,但只添加到最后一个,它应该与 From Earth 添加相同的行。
我的剧本
- name: Update the file
lineinfile:
dest: /sample/config.file
insertafter: ' Earth .* '
line: ' This is template'
我的初始文件
Hello World
[From Earth]
Hello World
[From Earth]
Hello World
[From Earth]
Hello World
[From Earth]
我的愿望输出
Hello World
[From Earth]
This is template
Hello World
[From Earth]
This is template
Hello World
[From Earth]
This is template
Hello World
[From Earth]
This is template
【问题讨论】: