fix: mailserver account check via host file, not docker exec
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:
parent
b616c18c58
commit
a28fffa7ae
1 changed files with 13 additions and 3 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue