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.

40 lines
1.4 KiB

# tasks file for dotqmail
# 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
# Gooing forward to create/update files with config
# For the other files the we get a key-value pair with the dotqmail extention
# as key and the list of lines as value while looping over dotqmail_files
- name: generate/update other dotqmail-files
src: templates/dotqmail.j2
dest: "{{ansible_env.HOME}}/{{file}}"
mode: 0600
file: "{{dotqmail_prefix}}{{item.key}}"
file_lines: "{{item.value}}"
with_dict: "{{dotqmail_files}}"