You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.1 KiB

# tasks file for dotqmail
- name: generate dotqmail-files
src: templates/dotqmail.j2
dest: "{{ansible_env.HOME}}/.qmail-{{item.key}}"
mode: 0644
with_dict: "{{dotqmail_files}}"
# To decide wether a dotqmail file is still needed we need to get all files
- name: Fetch all present dotqmail files
paths: "{{ansible_env.HOME}}/"
patterns: "{{dotqmail_prefix}}*"
hidden: True
register: present_files
# To decide which file could be deleted we extract first the file name of
# current file with basename(path) and then replace the dotqmail_prefix in it
# with the empty string via replace(dotqmail_prefix,'') to get the dotqmail
# extention
# Then we check up if a member with this extenion is defined in our
# dotqmail_files dict. If not, we can finaly delete the file (current item) via
# item.path
- name: Delete unconfigured (old) files
path: "{{item.path}}"
state: absent
current_ext: "{{item.path|basename|replace(dotqmail_prefix,'')}}"
with_items: "{{present_files.files}}"
when: dotqmail_files[current_ext] is not defined