- name: Prepare hosts: all tasks: - name: Create directories become: true file: path: '{{ item }}' state: directory loop: - /mnt/data1 - /mnt/data2 - name: Create data files become: true copy: content: "{{ item.content }}\n" dest: '{{ item.path }}' loop: - path: /mnt/data1/file1.txt content: file1 - path: /mnt/data2/file2.txt content: file2 - path: /mnt/data2/file3.txt content: file3