aggiunta cron job che fa il prune di volumi giornalmente
This commit is contained in:
parent
b3657fe7ce
commit
ee6857ef6f
|
|
@ -62,3 +62,4 @@ docker_node_labels: []
|
|||
# - { key: 'key_name', value: 'label_value' }
|
||||
|
||||
docker_restart_daemon_cronjob: false
|
||||
docker_prune_dangling_volumes: false
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# "system" prune, because pruning images only leaves a lot of garbage around
|
||||
docker system prune --force > /var/log/docker-prune.log 2>&1
|
||||
docker volume prune --force > /var/log/docker-volume-prune.log 2>&1
|
||||
exit 0
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# "system" prune, because pruning images only leaves a lot of garbage around
|
||||
docker system prune --force > /var/log/docker-prune.log 2>&1
|
||||
exit 0
|
||||
|
|
@ -106,6 +106,41 @@
|
|||
when: docker_install
|
||||
tags: [docker, docker_restart_daemon_cronjob]
|
||||
|
||||
- name: Cron job that prunes the dangling volumes
|
||||
block:
|
||||
- name: Install a script that prunes the docker dangling volumes
|
||||
copy:
|
||||
src: docker-prune-dangling-volumes.sh
|
||||
dest: /usr/local/sbin/docker-prune-dangling-volumes
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0744
|
||||
|
||||
- name: Install a cron job that prunes the docker volumes
|
||||
cron:
|
||||
name: Prune docker volumes
|
||||
cron_file: docker-prune-volumes
|
||||
special_time: daily
|
||||
user: root
|
||||
state: present
|
||||
job: "/usr/local/sbin/docker-prune-dangling-volumes"
|
||||
when: docker_prune_dangling_volumes
|
||||
|
||||
- name: Disable the cron job that prunes the docker volumes
|
||||
cron:
|
||||
name: Prune docker volumes
|
||||
cron_file: docker-prune-volumes
|
||||
special_time: daily
|
||||
user: root
|
||||
state: absent
|
||||
job: "/usr/local/sbin/docker-prune-dangling-volumes"
|
||||
when: not docker_prune_dangling_volumes
|
||||
|
||||
when: docker_install
|
||||
tags: [docker, docker_prune_volumes]
|
||||
|
||||
|
||||
|
||||
- block:
|
||||
- name: Remove the docker user
|
||||
user: name=docker state=absent
|
||||
|
|
|
|||
Loading…
Reference in New Issue