---
# Mailu admin's start.py hard-requires a DNSSEC-validating resolver and exits
# until it sees the AD flag. On swarm we therefore point admin's `dns:` at a
# public DNSSEC resolver, which would NXDOMAIN the internal service names admin
# dials at startup (MAILU_SWARM_DB_HOST, MAILU_SWARM_REDIS_HOST). These facts
# pin those names to the central services' overlay VIPs via admin `extra_hosts`,
# resolved here at deploy time into literal IPs (extra_hosts rejects names).
- name: "π Inspect the central swarm peers behind admin extra_hosts"
when: peer.name != 'redis' or not lookup('engine', 'redis', application_id, 'local')
block:
- name: "π Resolve central mariadb/redis VIPs for admin extra_hosts (swarm)"
ansible.builtin.command:
argv:
- "{{ BIN_CONTAINER }}"
- service
- inspect
- "{{ peer.service }}"
- "--format"
- "{% raw %}{{range .Endpoint.VirtualIPs}}{{.NetworkID}}={{.Addr}}#{{end}}{% endraw %}"
delegate_to: "{{ STACK_HOST }}"
run_once: true
changed_when: false
register: mailu_swarm_vip_raw
loop:
- { name: db, service: "{{ MAILU_SWARM_DB_ENGINE }}_{{ MAILU_SWARM_DB_ENGINE }}", overlay: "{{ MAILU_SWARM_DB_ENGINE }}" }
- { name: redis, service: "redis_redis", overlay: "redis" }
loop_control:
loop_var: peer
- name: "π Resolve central overlay network ids (swarm)"
ansible.builtin.command:
argv:
- "{{ BIN_CONTAINER }}"
- network
- inspect
- "{{ peer.overlay }}"
- "--format"
- "{{ '{{.Id}}' }}"
delegate_to: "{{ STACK_HOST }}"
run_once: true
changed_when: false
register: mailu_swarm_net_raw
loop:
- { name: db, overlay: "{{ MAILU_SWARM_DB_ENGINE }}" }
- { name: redis, overlay: "redis" }
loop_control:
loop_var: peer
- name: "π§° Pin central mariadb VIP as an admin extra_hosts fact (swarm)"
ansible.builtin.set_fact:
MAILU_SWARM_DB_ADDR: >-
{{ mailu_swarm_vip_raw.results[0].stdout | split('#') | map('trim') | select
| map('split', '=') | selectattr('0', 'equalto', mailu_swarm_net_raw.results[0].stdout | trim)
| map(attribute='1') | first | split('/') | first }}
- name: "π§° Pin central redis VIP as an admin extra_hosts fact (swarm)"
ansible.builtin.set_fact:
MAILU_SWARM_REDIS_ADDR: >-
{{ mailu_swarm_vip_raw.results[1].stdout | split('#') | map('trim') | select
| map('split', '=') | selectattr('0', 'equalto', mailu_swarm_net_raw.results[1].stdout | trim)
| map(attribute='1') | first | split('/') | first }}
when: not lookup('engine', 'redis', application_id, 'local')