I would like to understand semantics of `with_items` in ansible and compare this approach to `map` for example.
For example, let consider:
`{{ ["1","2", "3"] | map('regex_replace', '^(.*)$', \1'some tail') tail }}`
How to reach the same effect using `with_items` ?
And in general how does it work ? Where is the body of this loop ?
For example (got from some stack overflow thread):
---
- hosts: localhost
tasks:
- name: set fact 1
set_fact: foo="[ 'zero' ]"
- name: set fact 2
set_fact: foo="{{ foo }} + [ 'one' ]"
- name: set fact 3
set_fact: foo="{{ foo }} + [ 'two', 'three' ]"
- name: set fact 4
set_fact: foo="{{ foo }} + [ '{{ item }}' ]"
with_items:
- four
- five
- six
- debug: var=foo
To sum up, the question is about which approach is better (`map` vs `with_items`) and possible details of working (e.g. where is body of this loop)
Each detail of working ansible is welcome!