Trying to create files based on sourcefile, and of course when this construction works… i will use it on lots of things.
Version: ansible 2.4.2.0
I am trying to go through a source file ( in this case a list with users) and use every line i return in the file with the with_items loop to create files based on the each line.
As you can see the return is “user1\nuser2\nuser3\nuser4”
i want to split the lines, so i can use the value/string of each individual line.
I am still fairly new with Ansible, so I am probably missing something fundamental.
What am i missing? Why can’t i use stdout_lines on a lookup return?
“When is returned, Ansible always provides a list of strings, each containing one item per line from the original output.”
and as there is no attribute in the list, i removed that well and just itereate of the list:
with_items: ‘{{users}}’
and not
with_items: “{{ users.stdout_lines }}”
So the final result
TASK [testing : debug] **********************************************************************************************************************************************************************
ok: [minion2] => {
“msg”: “the value of foo.txt is [u’user1’, u’user2’, u’user3’, u’user4’]”
}