From 5afc14edf46c839843a057740537be4786214c8c Mon Sep 17 00:00:00 2001 From: pizzaniels Date: Sun, 5 Feb 2023 17:08:54 +0100 Subject: [PATCH] add watchtower container. elke dag om 5 uur worden de containers ge-update door watchtower indien nodig. --- playbooks/all.yml | 1 + roles/watchtower/files/docker-compose.yml | 7 +++++++ roles/watchtower/meta/main.yml | 4 ++++ roles/watchtower/tasks/main.yml | 14 ++++++++++++++ roles/watchtower/vars/main.yml | 2 ++ 5 files changed, 28 insertions(+) create mode 100644 roles/watchtower/files/docker-compose.yml create mode 100644 roles/watchtower/meta/main.yml create mode 100644 roles/watchtower/tasks/main.yml create mode 100644 roles/watchtower/vars/main.yml diff --git a/playbooks/all.yml b/playbooks/all.yml index 1868667..502f97f 100644 --- a/playbooks/all.yml +++ b/playbooks/all.yml @@ -2,6 +2,7 @@ hosts: homeserver roles: - {role: 'ssh', tags: 'ssh'} + - {role: 'watchtower', tags: 'watchtower'} - {role: 'borg', tags: 'borg'} - {role: 'nsd', tags: 'nsd'} - {role: 'forgejo', tags: 'forgejo'} diff --git a/roles/watchtower/files/docker-compose.yml b/roles/watchtower/files/docker-compose.yml new file mode 100644 index 0000000..3a1cf0f --- /dev/null +++ b/roles/watchtower/files/docker-compose.yml @@ -0,0 +1,7 @@ +version: "3" +services: + watchtower: + image: containrrr/watchtower + volumes: + - /var/run/docker.sock:/var/run/docker.sock + command: --schedule "0 0 4 * * *" # 4 uur UTC = 5 uur NL tijd diff --git a/roles/watchtower/meta/main.yml b/roles/watchtower/meta/main.yml new file mode 100644 index 0000000..7f5b1d3 --- /dev/null +++ b/roles/watchtower/meta/main.yml @@ -0,0 +1,4 @@ +dependencies: + - role: common + - role: docker + \ No newline at end of file diff --git a/roles/watchtower/tasks/main.yml b/roles/watchtower/tasks/main.yml new file mode 100644 index 0000000..2518ba7 --- /dev/null +++ b/roles/watchtower/tasks/main.yml @@ -0,0 +1,14 @@ +- name: Create app directory + file: + path: "{{ service_dir }}" + state: directory +- name: Copy Docker Compose script + copy: + src: "{{ role_path }}/files/docker-compose.yml" + dest: "{{ service_dir }}/docker-compose.yml" +- name: Start the Docker Compose + docker_compose: + project_src: "{{ service_dir }}" + pull: true + remove_orphans: true + diff --git a/roles/watchtower/vars/main.yml b/roles/watchtower/vars/main.yml new file mode 100644 index 0000000..6b39621 --- /dev/null +++ b/roles/watchtower/vars/main.yml @@ -0,0 +1,2 @@ +service_name: watchtower +service_dir: "{{ base_service_dir }}/{{ service_name }}"