From 9ff11808ce4bd55e0826a9a4a0beda413eed6ea9 Mon Sep 17 00:00:00 2001 From: Jesper Hess Nielsen Date: Sun, 3 Mar 2019 15:26:39 +0100 Subject: [PATCH] Add watchtower to manage auto-update of containers --- playbook.yml | 1 + roles/docker/tasks/services/watchtower.yml | 12 ++++++++++++ roles/docker/tasks/services/websites.yml | 4 ++++ 3 files changed, 17 insertions(+) create mode 100644 roles/docker/tasks/services/watchtower.yml diff --git a/playbook.yml b/playbook.yml index 8b7f99a3..db999e19 100644 --- a/playbook.yml +++ b/playbook.yml @@ -23,6 +23,7 @@ - docker_registry - drone - websites + - watchtower smtp_host: postfix smtp_port: 587 diff --git a/roles/docker/tasks/services/watchtower.yml b/roles/docker/tasks/services/watchtower.yml new file mode 100644 index 00000000..ffe05afa --- /dev/null +++ b/roles/docker/tasks/services/watchtower.yml @@ -0,0 +1,12 @@ +--- +- name: watchtower container + docker_container: + name: watchtower + image: v2tec/watchtower + restart_policy: unless-stopped + networks: + - name: external_services + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - /root/.docker/config.json:/config.json + command: ["--label-enable"] diff --git a/roles/docker/tasks/services/websites.yml b/roles/docker/tasks/services/websites.yml index 58334143..74649cd8 100644 --- a/roles/docker/tasks/services/websites.yml +++ b/roles/docker/tasks/services/websites.yml @@ -11,6 +11,8 @@ VIRTUAL_HOST : "{{ data_coop_website.domain }}" LETSENCRYPT_HOST: "{{ data_coop_website.domain }}" LETSENCRYPT_EMAIL: "{{ letsencrypt_email }}" + labels: + com.centurylinklabs.watchtower.enable: "true" - name: setup cryptohagen.dk website docker container docker_container: @@ -23,3 +25,5 @@ VIRTUAL_HOST : "{{ cryptohagen_website.domain }}" LETSENCRYPT_HOST: "{{ cryptohagen_website.domain }}" LETSENCRYPT_EMAIL: "{{ letsencrypt_email }}" + labels: + com.centurylinklabs.watchtower.enable: "true"