From: Ralf Jung Date: Mon, 21 May 2018 08:48:47 +0000 (+0200) Subject: also create newmail settings.py X-Git-Url: https://git.ralfj.de/ansible.git/commitdiff_plain/fd3d0087259ed6991fe6ac44a1ced8507c0457e1?ds=sidebyside also create newmail settings.py --- diff --git a/host_vars/template.yml b/host_vars/template.yml index 199180e..f990cba 100644 --- a/host_vars/template.yml +++ b/host_vars/template.yml @@ -61,6 +61,9 @@ postfix: quota: general: 1G trash: +10M + # Hostname used for both web access (to changepw) and SMTP/IMAP servers in emails + # sent by newmail script. + host: mail.example.org # optional: Where to generate a CGI script that users can use to change their password changepw_cgi: /srv/mail.example.org/cgi/changepw diff --git a/roles/email/tasks/dovecot.yml b/roles/email/tasks/dovecot.yml index aa59821..6e1b12a 100644 --- a/roles/email/tasks/dovecot.yml +++ b/roles/email/tasks/dovecot.yml @@ -44,14 +44,17 @@ - name: create newmail dir file: path=/root/newmail state=directory - name: install newmail script - copy: + template: dest: /root/newmail/newmail - src: files/newmail/newmail + src: templates/newmail/newmail mode: u=rwx,g=rx,o=rx -- name: install newmail templates - copy: - dest: /root/newmail/templates.py - src: files/newmail/templates.py +- name: install newmail config + template: + dest: /root/newmail/{{ item }} + src: templates/newmail/{{ item }} + loop: + - templates.py + - settings.py - name: install changepw script when: postfix.dovecot.changepw_cgi is defined template: diff --git a/roles/email/files/newmail/newmail b/roles/email/templates/newmail/newmail similarity index 100% rename from roles/email/files/newmail/newmail rename to roles/email/templates/newmail/newmail diff --git a/roles/email/templates/newmail/settings.py b/roles/email/templates/newmail/settings.py new file mode 100644 index 0000000..6637877 --- /dev/null +++ b/roles/email/templates/newmail/settings.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +DB_NAME = 'vmail' +DB_USER = 'vmail' +DB_PW = '{{postfix.dovecot.mysql_password}}' +MAIL_ADDR = '{{postfix.postmaster}}' +HOST = '{{postfix.dovecot.host}}' +DOMAINS = [ +{% if postfix.mailman is defined %} +{% for item in postfix.mailman.domains %} + '{{item}}', +{% endfor %} +{% endif %} +{% if postfix.dovecot is defined %} +{% for item in postfix.dovecot.domains %} + '{{item}}', +{% endfor %} +{% endif %} +] diff --git a/roles/email/files/newmail/templates.py b/roles/email/templates/newmail/templates.py similarity index 97% rename from roles/email/files/newmail/templates.py rename to roles/email/templates/newmail/templates.py index 7be7108..7b821c5 100644 --- a/roles/email/files/newmail/templates.py +++ b/roles/email/templates/newmail/templates.py @@ -16,11 +16,10 @@ Versenden kannst du Mails via SMTP: Bitte prüfe, ob das alles funktioniert. Bei Problemen kannst du dich gerne an mich wenden. Viele Grüße, -Ralf""" +{host} Postmaster""" INCOMING_FORWARD = "Eingehende Mails werden an deine Adresse {forward} weitergeleitet." INCOMING_IMAP = '''Der Zugriff auf das Postfach erfolgt via IMAP: Server: {host} Port: 143 Verschlüsselung: STARTTLS Benutzername: {user}''' -