From bcf920053c0f6b5a76cfd46c39c33d523b1d70d6 Mon Sep 17 00:00:00 2001 From: Thomas Kleinendorst Date: Mon, 3 Jun 2024 13:47:22 +0200 Subject: [PATCH] Allow removal of Podman container on version bump Before this change it was necessary to remove the container manually. With these changes it will automatically detect when a new version should be deployed and the role will automatically remove the old container. --- roles/actual/tasks/main.yml | 10 ++++++---- roles/actual/vars/main/defaults.yml | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/roles/actual/tasks/main.yml b/roles/actual/tasks/main.yml index 064d0a9..dc65a9a 100644 --- a/roles/actual/tasks/main.yml +++ b/roles/actual/tasks/main.yml @@ -19,17 +19,19 @@ containers.podman.podman_container_info: name: actual-server register: actual_server_container_info -# This step doesn't work correctly when updating the contianer in any way. In this case it will simply skip the step. -# The easiest workaround is to remove the container altogether and rerun. - name: Start the actual container with correct systemd linking - when: "'no such container' in actual_server_container_info.stderr" + when: not actual_server_container_info.containers[0]["Config"]["Image"] is match(".*:" + actual_version) become: true become_user: "{{ actual_username }}" block: + - name: Remove the actual container + containers.podman.podman_container: + name: actual-server + state: absent - name: Start the Actual container containers.podman.podman_container: name: actual-server - image: docker.io/actualbudget/actual-server:24.5.0 + image: "docker.io/actualbudget/actual-server:{{ actual_version }}" restart_policy: always publish: - 127.0.0.1:5006:5006 diff --git a/roles/actual/vars/main/defaults.yml b/roles/actual/vars/main/defaults.yml index 2de65f0..45d2322 100644 --- a/roles/actual/vars/main/defaults.yml +++ b/roles/actual/vars/main/defaults.yml @@ -1,2 +1,3 @@ --- actual_username: actual +actual_version: 24.6.0