Add cron job to prune unused Docker data

This commit is contained in:
Sam A. 2023-07-07 23:15:05 +02:00
parent d3af3b9e28
commit ca73aa5b9b
Signed by: samsapti
GPG Key ID: CBBBE7371E81C4EA
3 changed files with 12 additions and 1 deletions

View File

@ -7,6 +7,7 @@ usage() {
printf '$ %s\n' "$0 [-h|--help]"
printf '$ %s\n' "$0 [--dry] os"
printf '$ %s\n' "$0 [--dry] docker"
printf '$ %s\n' "$0 [--dry] docker_config"
printf '$ %s\n' "$0 [--dry] firewall"
printf '$ %s\n' "$0 [--dry] ssh"
printf '$ %s\n' "$0 [--dry] users [-i|--init]"
@ -38,7 +39,7 @@ fi
case $TAG in
"")
install_modules; $EXEC "$BASE_CMD" ;;
os|docker|firewall|ssh)
os|docker|docker_config|firewall|ssh)
install_modules; $EXEC "$BASE_CMD --tags '$TAG'" ;;
users)
install_modules

View File

@ -17,3 +17,12 @@
- docker.socket
- docker.service
when: stop is undefined or not stop
- name: Configure cron job to prune unused Docker data weekly
ansible.builtin.cron:
name: Prune unused Docker data
cron_file: ansible_docker_prune
job: 'docker system prune -fa && docker volume prune -fa'
special_time: weekly
user: root
state: present

View File

@ -40,6 +40,7 @@
- name: Configure Docker
ansible.builtin.import_tasks: config.yml
tags:
- docker_config
- reboot
- name: Set up Docker services