November 2017
Intermediate to advanced
266 pages
5h 34m
English
We can loop for repetitive operations using with_items. Let us see an example where we parse the list and print the values:
---- hosts : all vars: - test: Servertasks: - debug: msg: "{{ test }} {{ item }}" with_items: [ 0, 2, 4, 6, 8, 10 ]
The output of the playbook execution using the preceding code:

As we can see in the preceding screenshot, the iteration prints the value of Server plus the item value in the list for each item in the list. Similarly, for an integer iteration we can perform a loop using the with_sequence command:
---- hosts : all vars: - test: Servertasks: - debug: msg: "{{ test }} {{ item }}" with_sequence: ...Read now
Unlock full access