also create newmail settings.py
authorRalf Jung <post@ralfj.de>
Mon, 21 May 2018 08:48:47 +0000 (10:48 +0200)
committerRalf Jung <post@ralfj.de>
Mon, 21 May 2018 08:50:18 +0000 (10:50 +0200)
host_vars/template.yml
roles/email/tasks/dovecot.yml
roles/email/templates/newmail/newmail [moved from roles/email/files/newmail/newmail with 100% similarity]
roles/email/templates/newmail/settings.py [new file with mode: 0644]
roles/email/templates/newmail/templates.py [moved from roles/email/files/newmail/templates.py with 97% similarity]

index 199180ebc22fff708af8ecd4c03538e07dc89bb2..f990cba5ad08db4f06f2d293481a501a6e4b3470 100644 (file)
@@ -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
 
index aa59821b216685d42f803982587f70241c469acc..6e1b12a3a7c2236426afd9fadf3575ef2afd1c88 100644 (file)
 - 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/templates/newmail/settings.py b/roles/email/templates/newmail/settings.py
new file mode 100644 (file)
index 0000000..6637877
--- /dev/null
@@ -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 %}
+]
similarity index 97%
rename from roles/email/files/newmail/templates.py
rename to roles/email/templates/newmail/templates.py
index 7be7108c4ca3baac4993b213cdcb6736a7364fbb..7b821c55b30634fa0ff406891ad09d1b42516e32 100644 (file)
@@ -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}'''
-