- set_fact: group_identifier: "{{ item }}" group_items: "{{ combined_rules[item] }}" - block: - find: paths: "/etc/nftables/ansible-managed/{{ group_identifier }}/" file_type: 'any' excludes: '{% for item in group_items %}{{ item }}.nft,{% endfor %}' register: removeFiles - file: path: "{{ fileItem.path }}" state: absent loop: "{{ removeFiles.files }}" loop_control: label: "{{ fileItem.path }}" loop_var: fileItem when: group_items is mapping