Files
computer-playbook/roles/sys-svc-msmtp/tasks/01_core.yml
Kevin Veen-Birkenbach de121338cf Fix MSMTP Mailu routine loading condition
- Correct grouping of reachability check
- Replace incorrect boolean cast for mailu_token with length check
- Load Mailu routines only when host is unreachable or token is missing

Details: https://chatgpt.com/share/692f1e58-0d6c-800f-9699-e9a26f1e8db9
2025-12-02 18:14:16 +01:00

48 lines
1.2 KiB
YAML

- include_tasks: utils/once_flag.yml
- name: "Check if Mail Host is reachable"
uri:
url: "{{ WEB_PROTOCOL }}://{{ SYSTEM_EMAIL.HOST }}"
method: HEAD
validate_certs: yes
status_code: 200
register: mail_host_reachability
failed_when: false
changed_when: false
when:
- run_once_web_app_mailu is not defined
- "'web-app-mailu' in group_names"
- SYSTEM_EMAIL.HOST == (domains | get_domain('web-app-mailu'))
- name: "Load Mailu Routines for '{{ role_name }}'"
include_tasks: 02_mailu.yml
when:
- "'web-app-mailu' in group_names"
- >
(
mail_host_reachability is defined and
(mail_host_reachability.status | default(0) | int) != 200
)
or
(
users['no-reply'].mailu_token | default('', true) | length == 0
)
- name: install msmtp msmtp-mta
community.general.pacman:
name:
- msmtp
- msmtp-mta
state: present
- name: configure msmtprc.conf.j2
template:
src: "msmtprc.conf.j2"
dest: "/root/.msmtprc"
mode: 600
- include_role:
name: sys-ctl-hlth-msmtp
when: run_once_sys_ctl_hlth_msmtp is not defined
- include_tasks: utils/compose_up.yml