---
# include-gated: when: STALWART_IMPORT_MAILU and 'web-app-mailu' in group_names
# and STALWART_ACTIVE_PROVIDER and IS_COMPOSE_MODE
- name: "π List the container volumes on the stack host"
ansible.builtin.command: >-
container volume ls --format "{{ '{{' }} .Name {{ '}}' }}"
register: stalwart_volume_names
changed_when: false
- name: "βΉοΈ Report that Mailu has no maildir volume to import yet"
ansible.builtin.debug:
msg: "Mailu's maildir volume {{ STALWART_MAILU_MAILDIR_VOLUME }} does not exist on this host yet; there is nothing to import."
when: STALWART_MAILU_MAILDIR_VOLUME not in stalwart_volume_names.stdout_lines
- name: "π¨ Handle the Mailu maildir volume this host carries"
when: STALWART_MAILU_MAILDIR_VOLUME in stalwart_volume_names.stdout_lines
block:
- name: "π Check whether a finished import left its marker"
ansible.builtin.stat:
path: "{{ STALWART_IMPORT_DONE_FILE }}"
register: stalwart_import_done
- name: "βΉοΈ Report that the Mailu import is complete"
ansible.builtin.debug:
msg: "The Mailu import finished earlier; delete {{ STALWART_IMPORT_DONE_FILE }} to import again."
when: stalwart_import_done.stat.exists
- name: "π₯ Import the Mailu mailboxes unless an earlier run finished"
when: not stalwart_import_done.stat.exists
block:
- name: "π Read the state of the import unit"
ansible.builtin.command:
argv:
- systemctl
- show
- --property
- ActiveState
- --value
- "{{ STALWART_IMPORT_UNIT }}"
register: stalwart_import_unit_state
changed_when: false
- name: "βΉοΈ Report that the import of an earlier deploy still runs"
ansible.builtin.debug:
msg: "{{ STALWART_IMPORT_UNIT }} is {{ stalwart_import_unit_state.stdout }}; follow it with: journalctl -fu {{ STALWART_IMPORT_UNIT }}"
when: stalwart_import_unit_state.stdout not in ['inactive', 'failed']
- name: "π₯ Import every Mailu mailbox into Stalwart"
when: stalwart_import_unit_state.stdout in ['inactive', 'failed']
block:
- name: "π Resolve the legacy Mailu maildir volume mountpoint"
ansible.builtin.command: >-
container volume inspect --format "{{ '{{' }} .Mountpoint {{ '}}' }}"
{{ STALWART_MAILU_MAILDIR_VOLUME | quote }}
register: stalwart_mailu_maildir
changed_when: false
- name: "π₯ Stage and start the import"
include_tasks: 12_import_mailu/run.yml