init mailu-deploy-letsencrypt

This commit is contained in:
Kevin Veen-Birkenbach 2021-04-05 12:32:55 +02:00
parent ff527e326b
commit dfc737dfc8
6 changed files with 34 additions and 2 deletions

View File

@ -3,3 +3,9 @@
command:
cmd: docker-compose -p mailu up -d --force-recreate
chdir: /usr/local/bin/mailu/
- name: "restart deploy-letsencrypt-mailu.service"
systemd:
name: deploy-letsencrypt-mailu.service
state: restarted
enabled: yes
daemon_reload: yes

View File

@ -1,2 +1,3 @@
dependencies:
- native-docker-reverse-proxy
- native-systemd-email

View File

@ -15,6 +15,12 @@
state: directory
mode: 0755
- name: "create /etc/mailu/certs"
file:
path: "/etc/mailu/certs"
state: directory
mode: 0755
- name: "create /usr/local/bin/mailu/"
file:
path: "/usr/local/bin/mailu"
@ -28,3 +34,10 @@
- name: add mailu.env
template: src=mailu.env.j2 dest=/usr/local/bin/mailu/mailu.env
notify: recreate mailu
- name: add deploy-letsencrypt-mailu.sh
template: src=deploy-letsencrypt-mailu.sh.j2 dest=/usr/local/bin/mailu/deploy-letsencrypt-mailu.sh
- name: configure deploy-letsencrypt-mailu.service
template: src=deploy-letsencrypt-mailu.service.j2 dest=/etc/systemd/system/deploy-letsencrypt-mailu.service
notify: restart deploy-letsencrypt-mailu.service

View File

@ -0,0 +1,8 @@
[Unit]
Description=Let's Encrypt Mailu Deploy
OnFailure=systemd-email@%n.service
After=nginx.service
[Service]
Type=oneshot
ExecStart=/usr/bin/bash /usr/local/bin/mailu/deploy-letsencrypt-mailu.sh

View File

@ -0,0 +1,5 @@
#!/bin/sh
cp /etc/letsencrypt/live/{{domain}}/privkey.pem /etc/mailu/certs/key.pem || exit 1
cp /etc/letsencrypt/live/{{domain}}/fullchain.pem /etc/mailu/certs/cert.pem || exit 1
sudo cp /etc/letsencrypt/live/{{domain}} /etc/mailu/letsencrypt/ || exit 1
docker exec mailu_front_1 nginx -s reload

View File

@ -37,9 +37,8 @@ services:
- "{{ ip4_address }}:143:143"
- "{{ ip4_address }}:993:993"
volumes:
- "/etc/letsencrypt:/certs/letsencrypt:ro"
- "/etc/mailu/overrides/nginx:/overrides"
- "front_certs:/certs"
- "/etc/mailu/certs:/certs"
admin:
image: ${DOCKER_ORG:-mailu}/${DOCKER_PREFIX:-}admin:${MAILU_VERSION:-1.8}
restart: always