Browse Source

Improve file generation task and add template

master
Jonathan Golder 6 years ago
parent
commit
ad1cdc016c
  1. 20
      tasks/main.yml
  2. 6
      templates/dotqmail.j2

20
tasks/main.yml

@ -1,12 +1,5 @@
---
# 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
- name: Fetch all present dotqmail files
@ -32,3 +25,16 @@
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
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

@ -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 %}
Loading…
Cancel
Save