Add watchtower service
This commit is contained in:
parent
57ce1d2b44
commit
fe2478a373
4 changed files with 36 additions and 0 deletions
|
@ -16,4 +16,5 @@
|
|||
- { role: matrix, tags: ["matrix"] }
|
||||
- { role: iptables, tags: ["iptables"] }
|
||||
- { role: borg, tags: ["borg"] }
|
||||
- { role: watchtower, tags: ["watchtower"] }
|
||||
- { role: clean, tags: ["clean"] }
|
||||
|
|
22
roles/watchtower/tasks/base.yml
Normal file
22
roles/watchtower/tasks/base.yml
Normal file
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
|
||||
- name: Check watchtower directory exist
|
||||
ansible.builtin.file:
|
||||
path: watchtower
|
||||
state: directory
|
||||
|
||||
- name: Copy template conf
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "watchtower/{{ item.dest }}"
|
||||
loop:
|
||||
- { src: 'docker-compose.yml.j2', dest: 'docker-compose.yml' }
|
||||
register: watchtower_copy_templates_results
|
||||
|
||||
- name: Force update and restart container
|
||||
community.docker.docker_compose:
|
||||
project_src: watchtower
|
||||
state: present
|
||||
pull: true
|
||||
restarted: "{{ watchtower_copy_templates_results.changed }}"
|
||||
become: true
|
4
roles/watchtower/tasks/main.yml
Normal file
4
roles/watchtower/tasks/main.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
|
||||
- ansible.builtin.import_tasks: base.yml
|
||||
name: base
|
9
roles/watchtower/templates/docker-compose.yml.j2
Normal file
9
roles/watchtower/templates/docker-compose.yml.j2
Normal file
|
@ -0,0 +1,9 @@
|
|||
version: '3'
|
||||
|
||||
services:
|
||||
watchtower:
|
||||
image: containrrr/watchtower:latest
|
||||
restart: always
|
||||
container_name: watchtower
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
Loading…
Reference in a new issue