Initial commit of Docker and mailcow updates

This commit is contained in:
2026-04-12 12:16:48 -04:00
parent c0e96f2543
commit 29b1e5eb02
3 changed files with 42 additions and 0 deletions

View File

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

View File

@@ -0,0 +1,8 @@
---
- name: Restart main Docker stack
become: true
community.docker.docker_compose_v2:
# This targets the first directory in the list you defined in your host_vars
project_src: "{{ docker_compose_dirs[0] }}"
state: restarted

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