ansible/roles/docker/tasks/services/mailu.yml

250 lines
7.6 KiB
YAML
Raw Permalink Normal View History

2019-03-02 22:05:00 +00:00
---
- name: "[Mailu] create mailu volume folders"
2019-03-02 22:05:00 +00:00
file:
name: "{{ mailu.volume_folder }}/{{ volume }}"
state: directory
loop:
- redis
- certs
- overrides
- data
- dkim
- mail
- filter
- dav
- webmail
loop_control:
loop_var: volume
- name: "[Mailu] upload mailu.env file"
2019-03-02 22:05:00 +00:00
template:
src: mailu.env.j2
dest: "{{ mailu.volume_folder}}/mailu.env"
- name: "[Mailu] hard link to Let's Encrypt TLS certificate"
2019-03-05 14:10:15 +00:00
file:
src: "{{ nginx.volume_folder }}/certs/{{ mailu.domain }}/fullchain.pem"
dest: "{{ mailu.volume_folder }}/certs/cert.pem"
state: hard
force: yes
- name: "[Mailu] hard link to Let's Encrypt TLS key"
2019-03-05 14:10:15 +00:00
file:
src: "{{ nginx.volume_folder }}/certs/{{ mailu.domain }}/key.pem"
dest: "{{ mailu.volume_folder }}/certs/key.pem"
state: hard
force: yes
- name: "[Mailman] copy nginx configuration to link static files"
template:
src: mailman/nginx_vhost.j2
dest: "{{ nginx.volume_folder }}/vhost/{{ mailman.domain }}"
mode: "0644"
- name: "[Mailman] copy postfix override"
copy:
src: mailman/postfix.cf
dest: "{{ mailu.volume_folder }}/overrides/postfix.cf"
mode: "0644"
2021-04-06 20:37:29 +00:00
- name: "[Mailman] copy mailman config"
copy:
src: mailman/mailman-extra.cfg
dest: "{{ mailman.volume_folder }}/core/mailman-extra.cfg"
mode: "0644"
- name: Start containers
docker_compose:
project_name: mail_server
pull: yes
definition:
version: '3.6'
services:
### Mailu containers ###
redis:
image: redis:alpine
restart: always
volumes:
- "{{ mailu.volume_folder }}/redis:/data"
2019-03-05 14:10:15 +00:00
database:
2019-03-05 12:19:41 +00:00
image: mailu/postgresql:{{ mailu.version }}
restart: always
env_file: "{{ mailu.volume_folder}}/mailu.env"
volumes:
- "{{ mailu.volume_folder }}/data/psql_db:/data"
- "{{ mailu.volume_folder }}/data/psql_backup:/backup"
networks:
- default
- external_services
2019-03-02 22:05:00 +00:00
front:
2019-03-05 12:19:41 +00:00
image: mailu/nginx:{{ mailu.version }}
restart: always
env_file: "{{ mailu.volume_folder}}/mailu.env"
environment:
VIRTUAL_HOST: "{{ mailu.domain }}"
LETSENCRYPT_HOST: "{{ mailu.domain }}"
LETSENCRYPT_EMAIL: "{{ letsencrypt_email }}"
volumes:
- "{{ mailu.volume_folder }}/certs:/certs"
- "{{ mailu.volume_folder }}/overrides/nginx:/overrides"
expose:
- "80"
ports:
- "993:993"
- "25:25"
- "587:587"
2019-11-19 10:10:05 +00:00
- "465:465"
networks:
- default
- external_services
2019-03-02 22:05:00 +00:00
resolver:
2019-03-05 12:19:41 +00:00
image: mailu/unbound:{{ mailu.version }}
restart: always
env_file: "{{ mailu.volume_folder}}/mailu.env"
networks:
default:
ipv4_address: "{{ mailu.dns }}"
2019-03-02 22:05:00 +00:00
admin:
2019-03-05 12:19:41 +00:00
image: mailu/admin:{{ mailu.version }}
restart: always
env_file: "{{ mailu.volume_folder}}/mailu.env"
volumes:
- "{{ mailu.volume_folder }}/data:/data"
- "{{ mailu.volume_folder }}/dkim:/dkim"
depends_on:
- redis
2019-03-02 22:05:00 +00:00
imap:
2019-03-05 12:19:41 +00:00
image: mailu/dovecot:{{ mailu.version }}
restart: always
env_file: "{{ mailu.volume_folder}}/mailu.env"
volumes:
- "{{ mailu.volume_folder }}/mail:/mail"
- "{{ mailu.volume_folder }}/overrides:/overrides"
depends_on:
- front
2019-03-02 22:05:00 +00:00
smtp:
2019-03-05 12:19:41 +00:00
image: mailu/postfix:{{ mailu.version }}
restart: always
env_file: "{{ mailu.volume_folder}}/mailu.env"
volumes:
- "{{ mailu.volume_folder }}/overrides:/overrides"
- "{{ mailman.volume_folder }}/core/var/data:/opt/mailman-core-data/"
depends_on:
- front
- resolver
dns:
- "{{ mailu.dns }}"
2019-03-02 22:05:00 +00:00
antispam:
2019-03-05 12:19:41 +00:00
image: mailu/rspamd:{{ mailu.version }}
restart: always
env_file: "{{ mailu.volume_folder}}/mailu.env"
volumes:
- "{{ mailu.volume_folder }}/filter:/var/lib/rspamd"
- "{{ mailu.volume_folder }}/dkim:/dkim"
- "{{ mailu.volume_folder }}/overrides/rspamd:/etc/rspamd/override.d"
depends_on:
- front
- resolver
dns:
- "{{ mailu.dns }}"
2019-03-02 22:05:00 +00:00
webmail:
image: mailu/rainloop:1.6
restart: always
env_file: "{{ mailu.volume_folder}}/mailu.env"
volumes:
- "{{ mailu.volume_folder }}/webmail:/data"
depends_on:
- front
- resolver
dns:
- "{{ mailu.dns }}"
2019-03-02 22:05:00 +00:00
### Mailman containers ###
mailman-core:
2022-05-08 19:54:40 +00:00
image: maxking/mailman-core:0.4
volumes:
- "{{ mailman.volume_folder }}/core:/opt/mailman"
stop_grace_period: 30s
links:
- mailman-web:mailmain-web
- database:database
depends_on:
- database
environment:
DATABASE_URL: "postgres://mailman:{{ mailman_secrets.postgres_password }}@{{ mailman.database_ip }}/mailmandb"
DATABASE_TYPE: "postgres"
DATABASE_CLASS: "mailman.database.postgresql.PostgreSQLDatabase"
HYPERKITTY_API_KEY: "{{ mailman_secrets.hyperkitty_api_key }}"
HYPERKITTY_URL: "http://{{ mailman.web_ip }}:8000/hyperkitty"
MTA: "postfix"
SMTP_HOST: smtp
MM_HOSTNAME: "{{ mailman.core_ip }}"
networks:
default:
ipv4_address: "{{ mailman.core_ip }}"
external_services:
mailman-web:
2022-05-08 19:54:40 +00:00
image: maxking/mailman-web:0.4
depends_on:
- database
links:
- database:database
volumes:
- "{{ mailman.volume_folder }}/web:/opt/mailman-web-data"
environment:
DATABASE_TYPE: "postgres"
DATABASE_URL: "postgres://mailman:{{ mailman_secrets.postgres_password }}@{{ mailman.database_ip }}/mailmandb"
HYPERKITTY_API_KEY: "{{ mailman_secrets.hyperkitty_api_key }}"
DJANGO_ALLOWED_HOSTS: "{{ mailman.domain }}"
SERVE_FROM_DOMAIN: "{{ mailman.domain }}"
MAILMAN_ADMIN_USER: "valberg"
MAILMAN_ADMIN_EMAIL: "valberg@orn.li"
MAILMAN_REST_URL: "http://{{ mailman.core_ip }}:8001"
MAILMAN_HOST_IP: "{{ mailman.core_ip }}"
SECRET_KEY: "{{ mailman_secrets.django_secret_key }}"
SMTP_HOST: smtp
VIRTUAL_HOST: "{{ mailman.domain }}"
VIRTUAL_PORT: 8000
LETSENCRYPT_HOST: "{{ mailman.domain }}"
LETSENCRYPT_EMAIL: "{{ letsencrypt_email }}"
networks:
default:
ipv4_address: "{{ mailman.web_ip }}"
external_services:
mailman-database:
image: postgres:13
restart: always
environment:
POSTGRES_DB: mailmandb
POSTGRES_USER: mailman
POSTGRES_PASSWORD: "{{ mailman_secrets.postgres_password }}"
volumes:
- "{{ mailman.volume_folder }}/database:/var/lib/postgresql/data"
networks:
default:
ipv4_address: "{{ mailman.database_ip }}"
networks:
default:
driver: bridge
ipam:
driver: default
config:
- subnet: "{{ mailu.subnet }}"
external_services:
external:
name: external_services