fix: mailserver account check via host file, not docker exec
Some checks failed
CI/CD / syntax-check (push) Successful in 1m30s
CI/CD / deploy (push) Has been cancelled

setup email list fails with rc=1 when postfix-accounts.cf doesn't
exist yet (fresh install). Check the mounted config file on the host
instead, which correctly handles the empty/missing case.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jack 2026-03-22 16:55:52 +07:00
parent b616c18c58
commit a28fffa7ae

View file

@ -61,16 +61,26 @@
delay: 10
until: postfix_status.rc == 0
# Check the host-side mounted config file directly (setup email list fails if file doesn't exist yet)
- name: Check if noreply mail account exists
ansible.builtin.stat:
path: "{{ tools_root }}/mailserver/config/postfix-accounts.cf"
register: postfix_accounts_file
- name: Check noreply account in postfix-accounts.cf
ansible.builtin.command: >
docker exec mailserver setup email list
register: mail_accounts
grep -q "noreply@{{ domain_base }}" {{ tools_root }}/mailserver/config/postfix-accounts.cf
register: mail_account_check
changed_when: false
failed_when: false
when: postfix_accounts_file.stat.exists
- name: Create noreply mail account
ansible.builtin.command: >
docker exec mailserver setup email add noreply@{{ domain_base }} {{ mailserver_noreply_password }}
when: "'noreply@' + domain_base not in mail_accounts.stdout"
when: >
not postfix_accounts_file.stat.exists or
(mail_account_check.rc is defined and mail_account_check.rc != 0)
- name: Check if DKIM key exists
ansible.builtin.stat: