summaryrefslogtreecommitdiffstats
path: root/roles/webmail
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2016-05-11 18:07:09 +0200
committerGuilhem Moulin <guilhem@fripost.org>2016-05-12 11:33:55 +0200
commit90d498034b891123350785a134402172de477f4f (patch)
treea6e3c924054c3f689cdaffffe3a479e88fb97282 /roles/webmail
parente370313ad5895871479fffc922e3c72c0375dbf2 (diff)
Use systemd unit files for stunnel4.
Diffstat (limited to 'roles/webmail')
-rw-r--r--roles/webmail/handlers/main.yml4
-rw-r--r--roles/webmail/tasks/mail.yml27
-rw-r--r--roles/webmail/templates/etc/stunnel/smtp.conf.j2 (renamed from roles/webmail/templates/etc/stunnel/postfix.conf.j2)5
3 files changed, 15 insertions, 21 deletions
diff --git a/roles/webmail/handlers/main.yml b/roles/webmail/handlers/main.yml
index f7e403e..6009de0 100644
--- a/roles/webmail/handlers/main.yml
+++ b/roles/webmail/handlers/main.yml
@@ -1,6 +1,6 @@
---
-- name: Restart stunnel
- service: name=stunnel4 pattern=/usr/bin/stunnel4 state=restarted
+- name: Restart stunnel@smtp
+ service: name=stunnel4@smtp state=restarted
- name: Restart Nginx
service: name=nginx state=restarted
diff --git a/roles/webmail/tasks/mail.yml b/roles/webmail/tasks/mail.yml
index 7603a56..78eee38 100644
--- a/roles/webmail/tasks/mail.yml
+++ b/roles/webmail/tasks/mail.yml
@@ -1,13 +1,3 @@
-- name: Install stunnel
- apt: pkg=stunnel4
-
-- name: Auto-enable stunnel
- lineinfile: dest=/etc/default/stunnel4
- regexp='^(\s*#)?\s*ENABLED='
- line='ENABLED=1'
- owner=root group=root
- mode=0644
-
- name: Create /etc/stunnel/certs
file: path=/etc/stunnel/certs
state=directory
@@ -16,24 +6,27 @@
- name: Copy the SMTP outgoing proxy's X.509 certificate
assemble: src=certs/postfix regexp="{{ groups.out | difference([inventory_hostname]) | join('|') }}\.pem$" remote_src=no
- dest=/etc/stunnel/certs/postfix.pem
+ dest=/etc/stunnel/certs/smtp.pem
owner=root group=root
mode=0644
register: r1
notify:
- - Restart stunnel
+ - Restart stunnel@smtp
- name: Configure stunnel
- template: src=etc/stunnel/postfix.conf.j2
- dest=/etc/stunnel/postfix.conf
+ template: src=etc/stunnel/smtp.conf.j2
+ dest=/etc/stunnel/smtp.conf
owner=root group=root
mode=0644
register: r2
notify:
- - Restart stunnel
+ - Restart stunnel@smtp
+
+- name: Enable stunnel@smtp
+ service: name=stunnel4@smtp enabled=yes
-- name: Start stunnel
- service: name=stunnel4 pattern=/usr/bin/stunnel4 state=started
+- name: Start stunnel@smtp
+ service: name=stunnel4@smtp state=started
when: not (r1.changed or r2.changed)
- meta: flush_handlers
diff --git a/roles/webmail/templates/etc/stunnel/postfix.conf.j2 b/roles/webmail/templates/etc/stunnel/smtp.conf.j2
index 9003686..ba38bfa 100644
--- a/roles/webmail/templates/etc/stunnel/postfix.conf.j2
+++ b/roles/webmail/templates/etc/stunnel/smtp.conf.j2
@@ -7,7 +7,8 @@ setuid = stunnel4
setgid = stunnel4
; PID is created inside the chroot jail
-pid = /var/run/stunnel4/postfix.pid
+pid =
+foreground = yes
; Only log messages at severity warning (4) and higher
debug = 4
@@ -51,7 +52,7 @@ ciphers = EECDH+AESGCM:!MEDIUM:!LOW:!EXP:!aNULL:!eNULL
[smtp]
accept = localhost:2525
connect = outgoing.fripost.org:{{ postfix_instance.out.port }}
-CAfile = /etc/stunnel/certs/postfix.pem
+CAfile = /etc/stunnel/certs/smtp.pem
protocol = smtp
; vim:ft=dosini