fix(snappymail): correct admin password setup and network config
Some checks failed
CI/CD / syntax-check (push) Successful in 1m35s
CI/CD / deploy (push) Has been cancelled

- Replace broken PHP require path with docker restart to let entrypoint
  apply SNAPPYMAIL_ADMIN_PASSWORD env var (path /var/www/snappymail/index.php
  does not exist in djmaze/snappymail image)
- Move snappymail from webmail-internal to mail-internal so it can reach
  mailserver for IMAP/SMTP connections
- Remove unused webmail-internal network

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jack 2026-03-22 21:45:17 +07:00
parent 1c16183bf5
commit 1b3f3e62b9
2 changed files with 8 additions and 25 deletions

View file

@ -147,26 +147,12 @@
state: present state: present
pull: missing pull: missing
# ── SnappyMail admin password (set explicitly — env var may not apply on restart) ── # ── SnappyMail: force restart so entrypoint applies SNAPPYMAIL_ADMIN_PASSWORD ──
- name: Wait for SnappyMail to be ready # The env var is processed by the container entrypoint on every start.
ansible.builtin.command: docker exec snappymail wget -qO- http://127.0.0.1:8888 # Explicit restart ensures the password is always written to config correctly.
register: snappymail_ready - name: Restart SnappyMail to apply admin password from env
changed_when: false ansible.builtin.command: docker restart snappymail
retries: 12 changed_when: true
delay: 5
until: snappymail_ready.rc == 0
- name: Set SnappyMail admin password via PHP
ansible.builtin.shell: |
docker exec snappymail php -r "
require '/var/www/snappymail/index.php';
\$oConfig = \RainLoop\Api::Config();
\$oConfig->Set('security', 'admin_password', \RainLoop\Utils::PasswordHash('{{ snappymail_admin_password }}'));
\$oConfig->Save();
echo 'password set';
"
register: snappymail_pw
changed_when: "'password set' in snappymail_pw.stdout"
# ── Mail accounts (idempotent: check host-side config file) ────────────────── # ── Mail accounts (idempotent: check host-side config file) ──────────────────
- name: Wait for mailserver to be ready - name: Wait for mailserver to be ready

View file

@ -15,9 +15,6 @@ networks:
mail-internal: mail-internal:
driver: bridge driver: bridge
internal: true internal: true
webmail-internal:
driver: bridge
internal: true
volumes: volumes:
outline_db_data: outline_db_data:
@ -180,8 +177,8 @@ services:
container_name: snappymail container_name: snappymail
restart: unless-stopped restart: unless-stopped
networks: networks:
- webmail-internal - mail-internal # reach mailserver for IMAP/SMTP
- front - front # expose port 8888 to host
ports: ports:
- "{{ ip_tools }}:8888:8888" - "{{ ip_tools }}:8888:8888"
volumes: volumes: