1
0
mirror of https://github.com/golderweb/ansible-dotqmail.git synced 2026-04-18 04:16:31 +02:00

Improve file generation task and add template

This commit is contained in:
2016-09-09 22:06:52 +02:00
parent 8c3b50b5b3
commit ad1cdc016c
2 changed files with 19 additions and 7 deletions

View File

@@ -1,12 +1,5 @@
--- ---
# tasks file for dotqmail # tasks file for dotqmail
- name: generate dotqmail-files
template:
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 # To decide wether a dotqmail file is still needed we need to get all files
- name: Fetch all present dotqmail files - name: Fetch all present dotqmail files
@@ -32,3 +25,16 @@
with_items: "{{present_files.files}}" with_items: "{{present_files.files}}"
when: dotqmail_files[current_ext] is not defined 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
template:
src: templates/dotqmail.j2
dest: "{{ansible_env.HOME}}/{{file}}"
mode: 0600
vars:
file: "{{dotqmail_prefix}}{{item.key}}"
file_lines: "{{item.value}}"
with_dict: "{{dotqmail_files}}"

6
templates/dotqmail.j2 Normal file
View File

@@ -0,0 +1,6 @@
{# Gets the file name as var file and the redirect lines as list var file_names #}
# ~/{{file}}
# {{ansible_managed}}
{% for line in file_lines %}
{{line}}
{% endfor %}