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

165 lines
4.9 KiB
YAML
Raw Normal View History

2019-03-02 22:05:00 +00:00
---
- name: create mailu volume folders
2022-11-26 08:52:41 +00:00
ansible.builtin.file:
name: '{{ services.mailu.volume_folder }}/{{ volume }}'
2019-03-02 22:05:00 +00:00
state: directory
loop:
- redis
- certs
- overrides
- data
- dkim
- mail
- filter
- dav
- webmail
loop_control:
loop_var: volume
- name: upload mailu.env file
2022-11-26 08:52:41 +00:00
ansible.builtin.template:
2019-03-02 22:05:00 +00:00
src: mailu.env.j2
2022-11-26 08:52:41 +00:00
dest: '{{ services.mailu.volume_folder}}/mailu.env'
2019-03-02 22:05:00 +00:00
2019-03-05 14:10:15 +00:00
- name: hard link to Let's Encrypt TLS certificate
2022-11-26 08:52:41 +00:00
ansible.builtin.file:
src: '{{ services.nginx_proxy.volume_folder }}/certs/{{ services.mailu.domain
}}/fullchain.pem'
dest: '{{ services.mailu.volume_folder }}/certs/cert.pem'
2019-03-05 14:10:15 +00:00
state: hard
2022-11-26 08:52:41 +00:00
force: true
when: letsencrypt_enabled
2019-03-05 14:10:15 +00:00
- name: hard link to Let's Encrypt TLS key
2022-11-26 08:52:41 +00:00
ansible.builtin.file:
src: '{{ services.nginx_proxy.volume_folder }}/certs/{{ services.mailu.domain
}}/key.pem'
dest: '{{ services.mailu.volume_folder }}/certs/key.pem'
2019-03-05 14:10:15 +00:00
state: hard
2022-11-26 08:52:41 +00:00
force: true
when: letsencrypt_enabled
2019-03-05 14:10:15 +00:00
- name: run mail server containers
2022-11-26 08:52:41 +00:00
community.docker.docker_compose:
project_name: mail_server
2022-11-26 08:52:41 +00:00
pull: true
definition:
version: '3.6'
services:
redis:
image: redis:alpine
restart: always
volumes:
2022-11-26 08:52:41 +00:00
- '{{ services.mailu.volume_folder }}/redis:/data'
2019-03-05 14:10:15 +00:00
database:
image: mailu/postgresql:{{ services.mailu.version }}
restart: always
2022-11-26 08:52:41 +00:00
env_file: '{{ services.mailu.volume_folder}}/mailu.env'
volumes:
2022-11-26 08:52:41 +00:00
- '{{ services.mailu.volume_folder }}/data/psql_db:/data'
- '{{ services.mailu.volume_folder }}/data/psql_backup:/backup'
networks:
- default
- external_services
2019-03-02 22:05:00 +00:00
front:
image: mailu/nginx:{{ services.mailu.version }}
restart: always
2022-11-26 08:52:41 +00:00
env_file: '{{ services.mailu.volume_folder}}/mailu.env'
environment:
2022-11-26 08:52:41 +00:00
VIRTUAL_HOST: '{{ services.mailu.domain }}'
LETSENCRYPT_HOST: '{{ services.mailu.domain }}'
LETSENCRYPT_EMAIL: '{{ letsencrypt_email }}'
volumes:
2022-11-26 08:52:41 +00:00
- '{{ services.mailu.volume_folder }}/certs:/certs'
- '{{ services.mailu.volume_folder }}/overrides/nginx:/overrides'
expose:
2022-11-26 08:52:41 +00:00
- '80'
ports:
2022-11-26 08:52:41 +00:00
- 993:993
- 25:25
- 587:587
- 465:465
networks:
- default
- external_services
2019-03-02 22:05:00 +00:00
resolver:
image: mailu/unbound:{{ services.mailu.version }}
restart: always
2022-11-26 08:52:41 +00:00
env_file: '{{ services.mailu.volume_folder}}/mailu.env'
networks:
default:
2022-11-26 08:52:41 +00:00
ipv4_address: '{{ services.mailu.dns }}'
2019-03-02 22:05:00 +00:00
admin:
image: mailu/admin:{{ services.mailu.version }}
restart: always
2022-11-26 08:52:41 +00:00
env_file: '{{ services.mailu.volume_folder}}/mailu.env'
volumes:
2022-11-26 08:52:41 +00:00
- '{{ services.mailu.volume_folder }}/data:/data'
- '{{ services.mailu.volume_folder }}/dkim:/dkim'
depends_on:
- redis
2019-03-02 22:05:00 +00:00
imap:
image: mailu/dovecot:{{ services.mailu.version }}
restart: always
2022-11-26 08:52:41 +00:00
env_file: '{{ services.mailu.volume_folder}}/mailu.env'
volumes:
2022-11-26 08:52:41 +00:00
- '{{ services.mailu.volume_folder }}/mail:/mail'
- '{{ services.mailu.volume_folder }}/overrides:/overrides'
depends_on:
- front
2019-03-02 22:05:00 +00:00
smtp:
image: mailu/postfix:{{ services.mailu.version }}
restart: always
2022-11-26 08:52:41 +00:00
env_file: '{{ services.mailu.volume_folder}}/mailu.env'
volumes:
2022-11-26 08:52:41 +00:00
- '{{ services.mailu.volume_folder }}/overrides:/overrides'
depends_on:
- front
- resolver
dns:
2022-11-26 08:52:41 +00:00
- '{{ services.mailu.dns }}'
2019-03-02 22:05:00 +00:00
antispam:
image: mailu/rspamd:{{ services.mailu.version }}
restart: always
2022-11-26 08:52:41 +00:00
env_file: '{{ services.mailu.volume_folder}}/mailu.env'
volumes:
2022-11-26 08:52:41 +00:00
- '{{ services.mailu.volume_folder }}/filter:/var/lib/rspamd'
- '{{ services.mailu.volume_folder }}/dkim:/dkim'
- '{{ services.mailu.volume_folder }}/overrides/rspamd:/etc/rspamd/override.d'
depends_on:
- front
- resolver
dns:
2022-11-26 08:52:41 +00:00
- '{{ services.mailu.dns }}'
2019-03-02 22:05:00 +00:00
webmail:
image: mailu/rainloop:1.6
restart: always
2022-11-26 08:52:41 +00:00
env_file: '{{ services.mailu.volume_folder}}/mailu.env'
volumes:
2022-11-26 08:52:41 +00:00
- '{{ services.mailu.volume_folder }}/webmail:/data'
depends_on:
- front
- resolver
dns:
2022-11-26 08:52:41 +00:00
- '{{ services.mailu.dns }}'
2019-03-02 22:05:00 +00:00
networks:
default:
driver: bridge
ipam:
driver: default
config:
2022-11-26 08:52:41 +00:00
- subnet: '{{ services.mailu.subnet }}'
external_services:
external:
name: external_services