From 802144ecb61bca05a3353ab6fa8970eb4b69e345 Mon Sep 17 00:00:00 2001 From: Przemek Grondek Date: Tue, 3 May 2022 02:08:24 +0200 Subject: [PATCH] Add cleanup docker cron tasks --- main.yml | 4 ++-- roles/docker-cluster/tasks/docker-cron.yml | 17 +++++++++++++++++ roles/docker-cluster/tasks/main.yml | 4 +++- 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 roles/docker-cluster/tasks/docker-cron.yml diff --git a/main.yml b/main.yml index 6ea6365..b8186e2 100644 --- a/main.yml +++ b/main.yml @@ -12,9 +12,9 @@ - hosts: docker_cluster roles: - - node_explorer +# - node_explorer # - ssh -# - docker-cluster + - docker-cluster # - ubuntu # #- hosts: raspberry diff --git a/roles/docker-cluster/tasks/docker-cron.yml b/roles/docker-cluster/tasks/docker-cron.yml new file mode 100644 index 0000000..ef8cc82 --- /dev/null +++ b/roles/docker-cluster/tasks/docker-cron.yml @@ -0,0 +1,17 @@ +- name: Clean docker system + become: yes + ansible.builtin.cron: + user: root + name: "clean docker system" + minute: "0" + hour: "3" + job: "/usr/bin/docker system prune -f" + +- name: Clean docker image cache + become: yes + ansible.builtin.cron: + user: root + name: "clean docker system" + minute: "0" + hour: "3" + job: "/usr/bin/docker image prune -a -f" diff --git a/roles/docker-cluster/tasks/main.yml b/roles/docker-cluster/tasks/main.yml index 0fca0ae..c6b7e4b 100644 --- a/roles/docker-cluster/tasks/main.yml +++ b/roles/docker-cluster/tasks/main.yml @@ -13,4 +13,6 @@ - import_tasks: docker-watcher.yml -- import_tasks: ssh-external.yml \ No newline at end of file +- import_tasks: ssh-external.yml + +- import_tasks: docker-cron.yml \ No newline at end of file