ansible with_items - predefined list


Example

You can also loop over a variable list.

From vars:

favorite_snacks:
  - hotdog
  - ice cream
  - chips

and then the loop:

- name: create directories for storing my snacks
  file: path=/etc/snacks/{{ item }} state=directory
  with_items: '{{ favorite_snacks }}'

If you are using Ansible 2.0+ you must use quotes around the call to the variable.