Goal:
Current playbook:
- name:
Starting from Ansible 2.5, loop
should be used to iterate over a list, see https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html#standard-loops
As the Ansible file
module is idempotent, you do not have to check if the folders already exist.
For example:
- name: create backup directories
file:
path: "{{ item }}"
state: directory
owner: backup
group: backup
mode: 0775
loop:
- /backupdisk/certificates
- /backupdisk/mysql
- /backupdisk/wordpress