Looping over Parallel Sets of Data
Suppose you have the following variable data was loaded in via somewhere:
alpha: [ 'a', 'b', 'c', 'd' ]
numbers: [ 1, 2, 3, 4 ]
And you want the set of ‘(a, 1)’ and ‘(b, 2)’ and so on. Use ‘with_together’ to get this:
tasks:
- debug: msg="{{ item.0 }} and {{ item.1 }}"
with_together:
- "{{alpha}}"
- "{{numbers}}"
We can use the above loop to fulfill our requirement where to create/use multiple nodes in respective of LB or where to use multiple items.
Reference - http://ansible-docs.readthedocs.io/zh/stable-2.0/rst/playbooks_loops.html