Add cron job to prune unused Docker data

This commit is contained in:
Sam A. 2023-07-07 23:19:07 +02:00
parent f68350a4a9
commit c1c18a628c
Signed by: samsapti
GPG key ID: CBBBE7371E81C4EA
2 changed files with 14 additions and 3 deletions

View file

@ -8,5 +8,11 @@
mode: u=rw,g=r,o=r
notify: reload-dockerd
- name: Flush handlers
ansible.builtin.meta: flush_handlers
- 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

@ -8,7 +8,7 @@
- name: Add Docker apt repository
ansible.builtin.apt_repository:
repo: deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian bullseye stable
repo: 'deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian bullseye stable'
state: present
update_cache: true
@ -39,6 +39,11 @@
- name: Configure Docker
ansible.builtin.import_tasks: config.yml
tags:
- docker_config
- name: Flush handlers
ansible.builtin.meta: flush_handlers
- name: Set up Docker services
ansible.builtin.import_tasks: services.yml