我试图在比赛后使用 lineinfile 将多行添加到配置文件中,但我发现生成的行是相反的。这是我的剧本:
- name: Line test
lineinfile:
path: /home/vagrant/abcd
insertafter: '### AFTER THIS LINE'
line: "{{ item }}"
state: present
with_items:
- '# This is line 1'
- '# This is line 2'
- '# This is line 3'
Run Code Online (Sandbox Code Playgroud)
这是结果:
### AFTER THIS LINE
# This is line 3
# This is line 2
# This is line 1
Run Code Online (Sandbox Code Playgroud)
我想要的结果应该是:
### AFTER THIS LINE
# This is line 1
# This is line 2
# This is line 3 …Run Code Online (Sandbox Code Playgroud) ansible ×1