From 343a67e0e7d6e2e2a381b876bca21a34a66ad693 Mon Sep 17 00:00:00 2001 From: Stefan Bethke Date: Sun, 11 Aug 2024 20:49:21 +0200 Subject: [PATCH] Add auto-update * for all hosts, use debops.unattended_upgrades * for docker compose, install a cron job pulling new images and restarting affected containers --- .gitignore | 1 + playbooks/deploy.yaml | 7 +++++++ playbooks/roles/docker_compose/tasks/main.yaml | 8 ++++++++ 3 files changed, 16 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..722d5e7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vscode diff --git a/playbooks/deploy.yaml b/playbooks/deploy.yaml index fd33911..d71b9de 100644 --- a/playbooks/deploy.yaml +++ b/playbooks/deploy.yaml @@ -81,3 +81,10 @@ hosts: nginx_hosts:!public_reverse_proxy_hosts roles: - nginx + +- name: Configure unattended upgrades + collections: [ 'debops.debops' ] + hosts: all + become: true + roles: + - role: unattended_upgrades diff --git a/playbooks/roles/docker_compose/tasks/main.yaml b/playbooks/roles/docker_compose/tasks/main.yaml index 542e096..63cb9fc 100644 --- a/playbooks/roles/docker_compose/tasks/main.yaml +++ b/playbooks/roles/docker_compose/tasks/main.yaml @@ -97,3 +97,11 @@ # msg: "If this reports changed, then the docker compose containers changed." # changed_when: (docker_compose__ps_json_before_up.stdout | from_json | community.general.json_query('[].ID') | sort) # != (docker_compose__ps_json_after_up.stdout | from_json | community.general.json_query('[].ID') | sort) + +- name: Install automatic update cron job + become: true + ansible.builtin.cron: + name: 'docker compose auto update' + minute: "0" + hour: "5" + job: "cd /ansible_docker_compose; docker compose pull && docker compose up -d"