--- - name: "[Files] Create defined directorys" file: state: "directory" dest: "{{ item.key }}" mode: "{{ item.value.mode }}" owner: "{{ item.value.owner }}" group: "{{ item.value.group }}" loop: "{{ lookup('dict', files, wantlist=True) }}" when: - files is defined - item.value.state == "directory" - name: "[Files] Create defined files (with content)" copy: dest: "{{ item.key }}" mode: "{{ item.value.mode }}" owner: "{{ item.value.owner }}" group: "{{ item.value.group }}" content: "{{ item.value.content }}" loop: "{{ lookup('dict', files, wantlist=True) }}" when: - files is defined - item.value.state == "file" - item.value.content is defined - name: "[Files] Create defined files" copy: dest: "{{ item.key }}" mode: "{{ item.value.mode }}" owner: "{{ item.value.owner }}" group: "{{ item.value.group }}" src: "{{ item.value.src }}" loop: "{{ lookup('dict', files, wantlist=True) }}" when: - files is defined - item.value.state == "file" - item.value.src is defined