From 93c291289cd2c8f3d6afaaba61bb07c030792d2f Mon Sep 17 00:00:00 2001 From: Viyurz Date: Fri, 23 Feb 2024 14:29:10 +0100 Subject: [PATCH] Run backup before recreating container(s) if a new image has been downloaded. --- roles/etebase/tasks/update.yml | 18 ++++++++++++++++-- roles/synapse/tasks/update.yml | 18 ++++++++++++++++-- roles/vaultwarden/tasks/update.yml | 18 ++++++++++++++++-- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/roles/etebase/tasks/update.yml b/roles/etebase/tasks/update.yml index 2199a6b..89c28ed 100644 --- a/roles/etebase/tasks/update.yml +++ b/roles/etebase/tasks/update.yml @@ -28,7 +28,21 @@ mode: '770' become: true -- name: Pull/Create/Restart project services +- name: Pull project services + community.docker.docker_compose: + project_src: "{{ etebase_project_dir }}" + recreate: never + pull: true + debug: true + when: docker_pull_images | bool + register: etebase_docker_compose_pull_result + +- name: Include backup tasks + include_tasks: + file: backup.yml + # Make a backup if we didn't already make one and we pulled a new image + when: not run_backup and etebase_docker_compose_pull_result['actions'] | default([]) | selectattr('pulled_image', 'defined') | length > 0 + +- name: Create/Restart project services community.docker.docker_compose: project_src: "{{ etebase_project_dir }}" - pull: "{{ docker_pull_images | bool }}" diff --git a/roles/synapse/tasks/update.yml b/roles/synapse/tasks/update.yml index 321c5cb..e6f2fa1 100644 --- a/roles/synapse/tasks/update.yml +++ b/roles/synapse/tasks/update.yml @@ -45,9 +45,23 @@ mode: '770' become: true -- name: Pull/Create/Restart project services +- name: Pull project services + community.docker.docker_compose: + project_src: "{{ synapse_project_dir }}" + recreate: never + pull: true + debug: true + when: docker_pull_images | bool + register: synapse_docker_compose_pull_result + +- name: Include backup tasks + include_tasks: + file: backup.yml + # Make a backup if we didn't already make one and we pulled a new image + when: not run_backup and synapse_docker_compose_pull_result['actions'] | default([]) | selectattr('pulled_image', 'defined') | length > 0 + +- name: Create/Restart project services community.docker.docker_compose: project_src: "{{ synapse_project_dir }}" - pull: "{{ docker_pull_images | bool }}" # Restart if config file(s) changed restarted: "{{ synapse_template_homeserver_result['changed'] | bool }}" diff --git a/roles/vaultwarden/tasks/update.yml b/roles/vaultwarden/tasks/update.yml index c28683b..a238636 100644 --- a/roles/vaultwarden/tasks/update.yml +++ b/roles/vaultwarden/tasks/update.yml @@ -20,7 +20,21 @@ mode: '770' become: true -- name: Pull/Create/Restart project services +- name: Pull project services + community.docker.docker_compose: + project_src: "{{ vaultwarden_project_dir }}" + recreate: never + pull: true + debug: true + when: docker_pull_images | bool + register: vaultwarden_docker_compose_pull_result + +- name: Include backup tasks + include_tasks: + file: backup.yml + # Make a backup if we didn't already make one and we pulled a new image + when: not run_backup and vaultwarden_docker_compose_pull_result['actions'] | default([]) | selectattr('pulled_image', 'defined') | length > 0 + +- name: Create/Restart project services community.docker.docker_compose: project_src: "{{ vaultwarden_project_dir }}" - pull: "{{ docker_pull_images | bool }}"