I have many lines need to add, like
- today
- is
- a
- good
- day
if just one dest, will be
- name: add line
lineinfile:
dest: "/tmp/aaa.txt"
line: "{{ item }}"
with_items:
- "toady"
- "is"
- "a"
- "good"
- "day"
and then, also have many files need to add, like
- aaa.txt
- bbb.txt
- ccc.txt
if just one line, will be
- name: add line
lineinfile:
dest: "{{ item }}"
line: "today"
with_items:
- "/tmp/aaa.txt"
- "/tmp/bbb.txt"
- "/tmp/ccc.txt"
Now I need mix them, both have all dest and all line, but I can't try it success.
Both of them are an array or object, I try many method still fail.
Helppppppp please :(
Thanks everyone
question from:
https://stackoverflow.com/questions/65934597/ansible-lineinfile-how-add-multiple-lines-with-multiple-dest 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…