- name: Install rules for {{ item }} ansible.builtin.file: path: '/{{ item.path }}' state: directory mode: '{{ item.mode }}' with_community.general.filetree: '../templates/{{ item }}/' when: item.state == 'directory' - name: Create and copy rules files ansible.builtin.template: src: '{{ item.src }}' dest: '/{{ item.path }}' with_community.general.filetree: '../templates/{{ item }}/' when: item.state == 'file'