Initial commit of Docker and mailcow updates
This commit is contained in:
9
roles/docker_update/tasks/main.yaml
Normal file
9
roles/docker_update/tasks/main.yaml
Normal 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([]) }}"
|
||||||
|
|
||||||
8
roles/mailcow_update/handlers/main.yaml
Normal file
8
roles/mailcow_update/handlers/main.yaml
Normal 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
|
||||||
|
|
||||||
25
roles/mailcow_update/tasks/main.yaml
Normal file
25
roles/mailcow_update/tasks/main.yaml
Normal 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
|
||||||
Reference in New Issue
Block a user