mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-07 03:15:56 +00:00
43 lines
1.9 KiB
YAML
43 lines
1.9 KiB
YAML
---
|
|
# include-gated: when: STALWART_IMPORT_MAILU and 'web-app-mailu' in group_names
|
|
# and STALWART_ACTIVE_PROVIDER and DEPLOYMENT_MODE == 'compose'
|
|
- name: "🔍 Resolve the legacy Mailu maildir volume mountpoint"
|
|
ansible.builtin.command: >-
|
|
container volume inspect --format "{{ '{{' }} .Mountpoint {{ '}}' }}"
|
|
{{ lookup('volume', 'web-app-mailu', 'dovecot_mail').name | quote }}
|
|
register: stalwart_mailu_maildir
|
|
changed_when: false
|
|
|
|
- name: "🔧 Assemble the migration account credentials"
|
|
ansible.builtin.set_fact:
|
|
stalwart_migration_accounts: >-
|
|
{%- set acc = {} -%}
|
|
{%- for key, u in STALWART_USERS.items() -%}
|
|
{%- set secret = u.password | hash('sha256') if 'bot' in (u.roles | default([])) else u.password -%}
|
|
{%- set _ = acc.update({u.email: secret}) -%}
|
|
{%- endfor -%}
|
|
{{ acc }}
|
|
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
|
|
|
|
- name: "📄 Stage the migration accounts file"
|
|
stack_host_copy:
|
|
content: "{{ stalwart_migration_accounts | to_json }}"
|
|
dest: "{{ [ lookup('container', application_id, 'directories.instance'), '.migration-accounts.json' ] | path_join }}"
|
|
mode: "0600"
|
|
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
|
|
|
|
- name: "📥 Import the Mailu maildirs into Stalwart over IMAP"
|
|
ansible.builtin.script:
|
|
cmd: >-
|
|
{{ [ role_path, 'files/python/migrate_from_mailu.py' ] | path_join }}
|
|
--maildir-root {{ stalwart_mailu_maildir.stdout | trim | quote }}
|
|
--imap-host 127.0.0.1 --imap-port 993 --imap-insecure
|
|
--accounts-file {{ [ lookup('container', application_id, 'directories.instance'), '.migration-accounts.json' ] | path_join | quote }}
|
|
register: stalwart_mailu_import
|
|
timeout: "{{ lookup('timeout', 3600) | int }}"
|
|
|
|
- name: "🧹 Remove the migration accounts file"
|
|
ansible.builtin.file:
|
|
path: "{{ [ lookup('container', application_id, 'directories.instance'), '.migration-accounts.json' ] | path_join }}"
|
|
state: absent
|