--- - name: Create mail network become: true community.docker.docker_network: name: mail - name: Create maddy volume become: true community.docker.docker_volume: name: maddy - name: Copy maddy config become: true ansible.builtin.template: src: maddy.conf.j2 dest: /var/lib/docker/volumes/maddy/_data/maddy.conf register: maddy_conf - name: Run maddy become: true community.docker.docker_container: name: maddy image: foxcpp/maddy:0.7.1 networks: - name: mail - name: postgresql ports: - "25:25" - "143:143" - "465:465" - "587:587" - "993:993" volumes: - maddy:/data - /etc/letsencrypt/live/{{ domain }}/fullchain.pem:/etc/tls/fullchain.pem:ro - /etc/letsencrypt/live/{{ domain }}/privkey.pem:/etc/tls/privkey.pem:ro recreate: "{{ maddy_conf.changed }}" - name: Get users become: true community.docker.docker_container_exec: container: maddy argv: ["maddy", "creds", "list"] register: maddy_users - name: Create users become: true community.docker.docker_container_exec: container: maddy argv: ["sh", "-c", "echo '{{ item.value }}' | maddy creds create {{ item.key }}"] when: not item.key in maddy_users.stdout no_log: True loop: "{{ users | dict2items }}" - name: Update passwords become: true community.docker.docker_container_exec: container: maddy argv: ["sh", "-c", "echo '{{ item.value }}' | maddy creds password {{ item.key }}"] no_log: True loop: "{{ users | dict2items }}" - name: Get imap accounts become: true community.docker.docker_container_exec: container: maddy argv: ["maddy", "imap-acct", "list"] register: maddy_imap_accounts - name: Create imap accounts become: true community.docker.docker_container_exec: container: maddy argv: ["maddy", "imap-acct", "create", "{{ item.key }}"] when: not item.key in maddy_imap_accounts.stdout no_log: True loop: "{{ users | dict2items }}" - name: Run mta-sts container become: true community.docker.docker_container: name: mta-sts-1 image: git.comfycamp.space/lumin/mta-sts:v0.1.2 networks: - name: haproxy env: MTA_STS_MX: "{{ hostname }}" restart_policy: unless-stopped