Install watchtower
Also move file masks to config so they're consistent
This commit is contained in:
parent
3142ba75c6
commit
c3959d43c6
5 changed files with 46 additions and 5 deletions
7
ansible/roles/docker/files/watchtower/docker-compose.yml
Normal file
7
ansible/roles/docker/files/watchtower/docker-compose.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
version: "3"
|
||||
services:
|
||||
watchtower:
|
||||
image: containrrr/watchtower:latest
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
command: --cleanup --schedule "0 23 * * *"
|
|
@ -6,3 +6,6 @@
|
|||
|
||||
- name: Install netdata
|
||||
include: netdata.yml
|
||||
|
||||
- name: Install watchtower
|
||||
include: watchtower.yml
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
path: '/opt/netdata'
|
||||
state: directory
|
||||
owner: "{{ docker_user.name }}"
|
||||
mode: 0755
|
||||
mode: "{{ docker_compose_directory_mask }}"
|
||||
become: true
|
||||
become_user: root
|
||||
|
||||
|
@ -11,15 +11,13 @@
|
|||
template:
|
||||
src: files/netdata/docker-compose.yml
|
||||
dest: "/opt/netdata/docker-compose.yml"
|
||||
mode: 0644
|
||||
mode: "{{ docker_compose_file_mask }}"
|
||||
owner: "{{ docker_user.name }}"
|
||||
backup: true
|
||||
trim_blocks: false
|
||||
register: compose_file
|
||||
become: true
|
||||
become_user: root
|
||||
|
||||
- name: Cycle container
|
||||
- name: Cycle netdata container
|
||||
docker_compose:
|
||||
project_src: /opt/netdata
|
||||
pull: true
|
||||
|
|
30
ansible/roles/docker/tasks/watchtower.yml
Normal file
30
ansible/roles/docker/tasks/watchtower.yml
Normal file
|
@ -0,0 +1,30 @@
|
|||
- name: Create watchtower directory
|
||||
file:
|
||||
path: '/opt/watchtower'
|
||||
state: directory
|
||||
owner: "{{ docker_user.name }}"
|
||||
mode: "{{ docker_compose_directory_mask }}"
|
||||
become: true
|
||||
become_user: root
|
||||
|
||||
- name: Install watchtower config
|
||||
template:
|
||||
src: files/watchtower/docker-compose.yml
|
||||
dest: "/opt/watchtower/docker-compose.yml"
|
||||
mode: "{{ docker_compose_file_mask }}"
|
||||
owner: "{{ docker_user.name }}"
|
||||
register: compose_file
|
||||
become: true
|
||||
become_user: root
|
||||
|
||||
- name: Cycle watchtower container
|
||||
docker_compose:
|
||||
project_src: /opt/watchtower
|
||||
pull: true
|
||||
remove_orphans: true
|
||||
remove_volumes: true
|
||||
state: "{{ item }}"
|
||||
when: compose_file.changed
|
||||
loop:
|
||||
- absent
|
||||
- present
|
|
@ -1,3 +1,6 @@
|
|||
docker_user:
|
||||
id: 3000
|
||||
name: dockeruser
|
||||
|
||||
docker_compose_file_mask: 0664
|
||||
docker_compose_directory_mask: 0775
|
||||
|
|
Loading…
Reference in a new issue