Move mailman containers to the mailu.yml file.

This commit is contained in:
Víðir Valberg Guðmundsson 2021-03-08 15:53:23 +01:00
parent 24d91d36af
commit f4054dcb01
4 changed files with 108 additions and 7 deletions

View file

@ -76,13 +76,22 @@ drone:
domain: "drone.{{ base_domain }}" domain: "drone.{{ base_domain }}"
volume_folder: "{{ volume_root_folder }}/drone" volume_folder: "{{ volume_root_folder }}/drone"
mail_subnet_base: "192.168.203"
mailu: mailu:
version: 1.6 version: 1.6
domain: "mail.{{ base_domain }}" domain: "mail.{{ base_domain }}"
dns: 192.168.203.254 dns: "{{ mail_subnet_base }}.254"
subnet: 192.168.203.0/24 subnet: "{{ mail_subnet_base }}.0/24"
volume_folder: "{{ volume_root_folder }}/mailu" volume_folder: "{{ volume_root_folder }}/mailu"
mailman:
domain: "lists.{{ base_domain }}"
volume_folder: "{{ volume_root_folder }}/mailman"
core_ip: "{{ mail_subnet_base }}.12"
web_ip: "{{ mail_subnet_base }}.13"
database_ip: "{{ mail_subnet_base }}.14"
portainer: portainer:
domain: "portainer.{{ base_domain }}" domain: "portainer.{{ base_domain }}"
volume_folder: "{{ volume_root_folder }}/portainer" volume_folder: "{{ volume_root_folder }}/portainer"

View file

@ -0,0 +1,10 @@
append_at_myorigin=no
append_dot_mydomain=no
recipient_delimiter = +
unknown_local_recipient_reject_code = 550
owner_request_special = no
virtual_mailbox_maps = regexp:/opt/mailman-core-data/postfix_lmtp \$virtual_alias_maps
transport_maps = regexp:/opt/mailman-core-data/postfix_lmtp
local_recipient_maps = regexp:/opt/mailman-core-data/postfix_lmtp
always_add_missing_headers = yes
local_header_rewrite_clients = permit_sasl_authenticated

View file

@ -1,6 +1,6 @@
--- ---
- name: create mailu volume folders - name: "[Mailu] create mailu volume folders"
file: file:
name: "{{ mailu.volume_folder }}/{{ volume }}" name: "{{ mailu.volume_folder }}/{{ volume }}"
state: directory state: directory
@ -17,12 +17,12 @@
loop_control: loop_control:
loop_var: volume loop_var: volume
- name: upload mailu.env file - name: "[Mailu] upload mailu.env file"
template: template:
src: mailu.env.j2 src: mailu.env.j2
dest: "{{ mailu.volume_folder}}/mailu.env" dest: "{{ mailu.volume_folder}}/mailu.env"
- name: hard link to Let's Encrypt TLS certificate - name: "[Mailu] hard link to Let's Encrypt TLS certificate"
file: file:
src: "{{ nginx.volume_folder }}/certs/{{ mailu.domain }}/fullchain.pem" src: "{{ nginx.volume_folder }}/certs/{{ mailu.domain }}/fullchain.pem"
dest: "{{ mailu.volume_folder }}/certs/cert.pem" dest: "{{ mailu.volume_folder }}/certs/cert.pem"
@ -30,20 +30,34 @@
force: yes force: yes
- name: hard link to Let's Encrypt TLS key - name: "[Mailu] hard link to Let's Encrypt TLS key"
file: file:
src: "{{ nginx.volume_folder }}/certs/{{ mailu.domain }}/key.pem" src: "{{ nginx.volume_folder }}/certs/{{ mailu.domain }}/key.pem"
dest: "{{ mailu.volume_folder }}/certs/key.pem" dest: "{{ mailu.volume_folder }}/certs/key.pem"
state: hard state: hard
force: yes force: yes
- name: run mail server containers - 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"
- name: Start containers
docker_compose: docker_compose:
project_name: mail_server project_name: mail_server
pull: yes pull: yes
definition: definition:
version: '3.6' version: '3.6'
services: services:
### Mailu containers ###
redis: redis:
image: redis:alpine image: redis:alpine
restart: always restart: always
@ -117,6 +131,7 @@
env_file: "{{ mailu.volume_folder}}/mailu.env" env_file: "{{ mailu.volume_folder}}/mailu.env"
volumes: volumes:
- "{{ mailu.volume_folder }}/overrides:/overrides" - "{{ mailu.volume_folder }}/overrides:/overrides"
- "{{ mailman.volume_folder }}/core/var/data:/opt/mailman-core-data/"
depends_on: depends_on:
- front - front
- resolver - resolver
@ -149,6 +164,73 @@
dns: dns:
- "{{ mailu.dns }}" - "{{ mailu.dns }}"
### Mailman containers ###
mailman-core:
image: maxking/mailman-core:0.3.11
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:
image: maxking/mailman-web:0.3.11
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: networks:
default: default:
driver: bridge driver: bridge