I am surprised that no one mentioned the search , I think this is exactly what you want.
It reads the content that you want to use in your game book, but do not want to include in the game book from files, channel , csv , redis , etc. from your local host computer (not from a remote computer, this is important since in most cases this content is next to your playbook on the local computer) and it works with ANSIBLE LOOP.
--- - hosts: localhost gather_facts: no tasks: - name: Loop over lines in a file debug: var: item with_lines: cat "./files/lines"
with_lines here is actually a loop with searching for strings, to see how the search for lines works, look at the code here , it just runs any commands that you give it (so that you can give it any such as echo, cat, etc. ), then split the output into lines and return them.
There are many powerful searches to get a complete list; check the search plugins folder .
source share