Use ansible_service to run mailu containers with docker compose.

This commit is contained in:
Víðir Valberg Guðmundsson 2019-03-05 13:07:57 +01:00
parent f5bc79e636
commit ae78c942d7
2 changed files with 114 additions and 89 deletions

View file

@ -50,4 +50,6 @@ cryptohagen_website:
domain: "cryptohagen.dk" domain: "cryptohagen.dk"
mailu: mailu:
domain: "mail.{{ base_domain }}"
dns: 192.168.203.254
subnet: 192.168.203.0/24 subnet: 192.168.203.0/24

View file

@ -1,11 +1,5 @@
--- ---
- name: setup network for mailu
docker_network:
name: mailu
ipam_options:
subnet: "{{ mailu.subnet }}"
- name: create mailu volume folders - name: create mailu volume folders
file: file:
name: "{{ mailu.volume_folder }}/{{ volume }}" name: "{{ mailu.volume_folder }}/{{ volume }}"
@ -23,99 +17,128 @@
loop_control: loop_control:
loop_var: volume loop_var: volume
- name: mailu redis container
docker_container:
name: mailu_redis
image: redis:alpine
restart_policy: always
volumes:
- "{{ mailu.volume_folder }}/redis:/data"
- name: mailu database container
docker_container:
image: mailu/postgresql:1.6
restart_policy: always
env_file: "{{ mailu.volume_folder}}/mailu.env"
volumes:
- "{{ mailu.volume_folder }}/data/psql_db:/data"
- "{{ mailu.volume_folder }}/data/psql_backup:/backup"
- name: upload mailu.env file - name: 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: mailu front container - name: run mail server containers
docker_container: docker_service:
name: mailu_front project_name: mail_server
image: mailu/nginx:1.6 pull: yes
definition:
version: '3.6'
services:
redis:
image: redis:alpine
restart: always
volumes:
- "{{ mailu.volume_folder }}/redis:/data"
postgresql:
image: mailu/postgresql:1.6
restart: always
env_file: "{{ mailu.volume_folder}}/mailu.env" env_file: "{{ mailu.volume_folder}}/mailu.env"
volumes:
- "{{ mailu.volume_folder }}/data/psql_db:/data"
- "{{ mailu.volume_folder }}/data/psql_backup:/backup"
networks:
- name: mailu
front:
image: mailu/nginx:{{ mail_server_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: volumes:
- "{{ mailu.volume_folder }}/certs:/certs" - "{{ mailu.volume_folder }}/certs:/certs"
- "{{ mailu.volume_folder }}/overrides/nginx:/overrides" - "{{ mailu.volume_folder }}/overrides/nginx:/overrides"
expose:
- "80"
ports:
- "993:993"
- "25:25"
- "587:587"
networks:
- default
- external_services
- name: mailu admin container resolver:
docker_container: image: mailu/unbound:{{ mail_server_mailu_version }}
image: mailu/admin:1.6 restart: always
restart_policy: always env_file: "{{ mailu.volume_folder}}/mailu.env"
networks:
default:
ipv4_address: "{{ mailu.dns }}"
admin:
image: mailu/admin:{{ mail_server_mailu_version }}
restart: always
env_file: "{{ mailu.volume_folder}}/mailu.env" env_file: "{{ mailu.volume_folder}}/mailu.env"
volumes: volumes:
- "{{ mailu.volume_folder }}/data:/data" - "{{ mailu.volume_folder }}/data:/data"
- "{{ mailu.volume_folder }}/dkim:/dkim" - "{{ mailu.volume_folder }}/dkim:/dkim"
depends_on:
- redis
- name: mailu imap container imap:
docker_container: image: mailu/dovecot:{{ mail_server_mailu_version }}
image: mailu/dovecot:1.6 restart: always
restart_policy: always
env_file: "{{ mailu.volume_folder}}/mailu.env" env_file: "{{ mailu.volume_folder}}/mailu.env"
volumes: volumes:
- "{{ mailu.volume_folder }}/mail:/mail" - "{{ mailu.volume_folder }}/mail:/mail"
- "{{ mailu.volume_folder }}/overrides:/overrides" - "{{ mailu.volume_folder }}/overrides:/overrides"
depends_on:
- front
- name: mailu smtp container smtp:
docker_container: image: mailu/postfix:{{ mail_server_mailu_version }}
image: mailu/postfix:1.6 restart: always
restart_policy: always
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"
depends_on:
- front
- resolver
dns:
- "{{ mailu.dns }}"
- name: mailu antispam container antispam:
docker_container: image: mailu/rspamd:{{ mail_server_mailu_version }}
image: mailu/rspamd:1.6 restart: always
restart_policy: always
env_file: "{{ mailu.volume_folder}}/mailu.env" env_file: "{{ mailu.volume_folder}}/mailu.env"
volumes: volumes:
- "{{ mailu.volume_folder }}/filter:/var/lib/rspamd" - "{{ mailu.volume_folder }}/filter:/var/lib/rspamd"
- "{{ mailu.volume_folder }}/dkim:/dkim" - "{{ mailu.volume_folder }}/dkim:/dkim"
- "{{ mailu.volume_folder }}/overrides/rspamd:/etc/rspamd/override.d" - "{{ mailu.volume_folder }}/overrides/rspamd:/etc/rspamd/override.d"
depends_on:
- front
- resolver
dns:
- "{{ mailu.dns }}"
- name: mailu antivirus container webmail:
docker_container:
image: mailu/clamav:1.6
restart_policy: always
env_file: "{{ mailu.volume_folder}}/mailu.env"
volumes:
- "{{ mailu.volume_folder}}/filter:/data"
- name: mailu webdav container
docker_container:
image: mailu/radicale:1.6
restart_policy: always
env_file: "{{ mailu.volume_folder}}/mailu.env"
volumes:
- "{{ mailu.volume_folder}}/dav:/data"
- name: mailu fetchmail container
docker_container:
image: mailu/fetchmail:1.6
restart_policy: always
env_file: "{{ mailu.volume_folder}}/mailu.env"
- name: mailu webmail container
docker_container:
image: mailu/rainloop:1.6 image: mailu/rainloop:1.6
restart_policy: always restart: always
env_file: "{{ mailu.volume_folder}}/mailu.env" env_file: "{{ mailu.volume_folder}}/mailu.env"
volumes: volumes:
- "{{ mailu.volume_folder }}/webmail:/data" - "{{ mailu.volume_folder }}/webmail:/data"
depends_on:
- front
- resolver
dns:
- "{{ mailu.dns }}"
networks:
default:
driver: bridge
ipam:
driver: default
config:
- subnet: "{{ mailu.subnet }}"
external_services:
external:
name: external_services