Compare commits

...

3 Commits

3 changed files with 54 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
---
- name: Pull latest images and update Docker Compose stacks
become: true
community.docker.docker_compose_v2:
project_src: "{{ item }}"
state: present
pull: always
build: always
loop: "{{ docker_compose_dirs | default([]) }}"

View File

@@ -0,0 +1,19 @@
---
- name: Tear down Mailcow and main Docker stack(s) (LIFO)
become: true
community.docker.docker_compose_v2:
project_src: "{{ item }}"
state: absent
# Drops Mailcow first, THEN loops through your main stacks
loop: "{{ [mailcow_dir | default('/data/mailcow')] + (docker_compose_dirs | default([])) }}"
listen: Restart main Docker stack
- name: Bring main Docker stack(s) and Mailcow back up (FIFO)
become: true
community.docker.docker_compose_v2:
project_src: "{{ item }}"
state: present
# Brings your main stacks up first (recreating the network), THEN Mailcow
loop: "{{ (docker_compose_dirs | default([])) + [mailcow_dir | default('/data/mailcow')] }}"
listen: Restart main Docker stack

View File

@@ -0,0 +1,25 @@
---
- name: Execute unattended Mailcow update
become: true
ansible.builtin.command:
cmd: ./update.sh --force
chdir: "{{ mailcow_dir | default('/data/mailcow') }}"
register: mailcow_first_pass
# Exit code 2 means "modules updated, run me again". Anything else is a real failure.
failed_when: mailcow_first_pass.rc not in [0, 2]
changed_when:
- mailcow_first_pass.rc == 0
- "'Updated code is available' in mailcow_first_pass.stdout or 'Pulling' in mailcow_first_pass.stdout or 'Upgrading' in mailcow_first_pass.stdout"
notify: Restart main Docker stack
- name: Re-run unattended Mailcow update (if modules changed)
become: true
ansible.builtin.command:
cmd: ./update.sh --force
chdir: "{{ mailcow_dir | default('/data/mailcow') }}"
# Only trigger this second pass if the first pass threw the specific restart code
when: mailcow_first_pass.rc == 2
register: mailcow_second_pass
changed_when:
- "'Updated code is available' in mailcow_second_pass.stdout or 'Pulling' in mailcow_second_pass.stdout or 'Upgrading' in mailcow_second_pass.stdout"
notify: Restart main Docker stack