--- - name: sudo get vars include_vars: default.yml - name: sudo get OS vars include_vars: '{{ item }}' with_first_found: - '{{ ansible_distribution }}.yml' - default.yml - debug: msg="{{ item | regex_replace('^.*\/','') }}" with_items: - '{{ sudo_files }}' - name: sudo deploy rules from files template: src: "roles/sudo/files/{{ item.file }}" dest: "{{ sudo_rules_dir }}/{{ item.file | regex_replace('^.*\/','a') }}" mode: 0440 owner: '{{ sudo_root_user }}' group: '{{ sudo_root_group }}' with_items: - '{{ sudo_files }}' when: - sudo_files is defined