ansible: lineinfile for several lines?


The same way there is a module lineinfile to add one line in a file, is there a way to add several lines?

I do not want to use a template because you have to provide the whole file.
I just want to add something to an existing file without necessarily knowing what the file already contains so a template is not an option.


You can use the lineinfile built-in in a loop. Here’s an example:

Leave a Reply