From 6afc7ca9c310ef1a2223d558e373181f1e998949 Mon Sep 17 00:00:00 2001 From: "tom.chivert" Date: Fri, 16 Sep 2022 11:33:42 +0200 Subject: [PATCH] Add maildev install --- README.md | 4 ++++ handlers/main.yml | 10 ++++++++++ tasks/base.yml | 1 + tasks/maildev.yml | 9 +++++++++ tasks/main.yml | 1 + templates/compose/maildev.yml.j2 | 24 ++++++++++++++++++++++++ 6 files changed, 49 insertions(+) create mode 100644 tasks/maildev.yml create mode 100644 templates/compose/maildev.yml.j2 diff --git a/README.md b/README.md index 0539e7f..dfeba0a 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Available services - Traefik - Watchtower - Grafana + - Maildev Role variables --------------- @@ -48,9 +49,12 @@ Example variables - traefik - watchtower - grafana + - maildev traefik_domain: 'mydomain.com' traefik_letsencrypt_email: 'cert@mydomain.com' + + maildev_domain: 'maildev.mydomain.com' ``` TODO diff --git a/handlers/main.yml b/handlers/main.yml index dd9645f..4a26463 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -3,16 +3,26 @@ systemd: name: docker-compose@traefik state: restarted + ignore_errors: '{{ ansible_check_mode }}' tags: ['docker_traefik'] - name: watchtower-restart systemd: name: docker-compose@watchtower state: restarted + ignore_errors: '{{ ansible_check_mode }}' tags: ['docker_watchtower'] - name: grafana-restart systemd: name: docker-compose@grafana state: restarted + ignore_errors: '{{ ansible_check_mode }}' tags: ['docker_grafana'] + +- name: maildev-restart + systemd: + name: docker-compose@maildev + state: restarted + ignore_errors: '{{ ansible_check_mode }}' + tags: ['docker_maildev'] diff --git a/tasks/base.yml b/tasks/base.yml index db4d819..6ebf355 100644 --- a/tasks/base.yml +++ b/tasks/base.yml @@ -34,4 +34,5 @@ daemon_reload: yes name: docker-compose@{{ service }} enabled: true + ignore_errors: '{{ ansible_check_mode }}' tags: [ 'docker_{{ service }}' ] diff --git a/tasks/maildev.yml b/tasks/maildev.yml new file mode 100644 index 0000000..fed412e --- /dev/null +++ b/tasks/maildev.yml @@ -0,0 +1,9 @@ +--- +- name: maildev | check vars are defined + assert: + that: + - maildev_domain is defined + tags: ['docker_maildev'] + +- include_tasks: base.yml + tags: ['docker_maildev'] diff --git a/tasks/main.yml b/tasks/main.yml index c545dc2..5e522fd 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -13,5 +13,6 @@ - docker_traefik - docker_watchtower - docker_grafana + - docker_maildev with_items: - "{{ docker_services }}" diff --git a/templates/compose/maildev.yml.j2 b/templates/compose/maildev.yml.j2 new file mode 100644 index 0000000..d7abba9 --- /dev/null +++ b/templates/compose/maildev.yml.j2 @@ -0,0 +1,24 @@ +version: '3.7' + +networks: + traefik: + external: true + +services: + maildev: + container_name: maildev + image: maildev/maildev:{{ maildev_version | default("latest") }} + restart: unless-stopped + ports: + - "1080:1080" + - "1025:1025" + labels: + traefik.enable: true + traefik.docker.network: traefik + traefik.http.routers.maildev.rule: Host(`{{ maildev_domain }}`) + traefik.http.routers.maildev.tls: true + traefik.http.routers.maildev.tls.certresolver: letsencrypt + traefik.http.routers.maildev.entrypoints: websecure + traefik.http.services.maildev.loadbalancer.server.port: 1080 + networks: + - traefik