From b71b53ac7411f18e151b0b5abf51e7e66252b7a2 Mon Sep 17 00:00:00 2001 From: Tobias Trabelsi Date: Wed, 22 Dec 2021 22:23:42 +0100 Subject: [PATCH] added wrapper role --- README.md | 14 ++++++++++++++ defaults/main.yml | 2 ++ handlers/main.yml | 2 ++ meta/main.yml | 18 ++++++++++++++++++ tasks/main.yml | 19 +++++++++++++++++++ tests/inventory | 2 ++ tests/test.yml | 5 +++++ vars/main.yml | 2 ++ 8 files changed, 64 insertions(+) create mode 100644 README.md create mode 100644 defaults/main.yml create mode 100644 handlers/main.yml create mode 100644 meta/main.yml create mode 100644 tasks/main.yml create mode 100644 tests/inventory create mode 100644 tests/test.yml create mode 100644 vars/main.yml diff --git a/README.md b/README.md new file mode 100644 index 0000000..1e0119d --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +cri-o cleanup +========= + +Removes unused images from host + +Requirements +------------ + +cri-o needs to be installed and crictl needs to be available + +License +------- + +MIT diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..07dccfe --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for crio-cleanup diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..75bdf98 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for crio-cleanup diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..b132585 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,18 @@ +galaxy_info: + author: Tobias Trabelsi + description: removes unused OCI images from host + + license: MIT + + min_ansible_version: 2.9 + + platforms: + - name: CentOS + versions: + - 8 + - 7 + - name: Ubuntu + version: + - 16.04 + - 18.04 + - 20.04 \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..5e3d94e --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,19 @@ +--- +# tasks file for crio-cleanup + +- name: "Check if cri-o is installed" + become: yes + package_facts: + manager: "auto" + tags: [ "cleanup", "prepare" ] + +- name: fail if cri-o is not avaliable + fail: + msg: "crictl needs to be installed" + tags: [ "cleanup", "prepare" ] + +- name: delete unused images + become: yes + command: "/usr/local/bin/crictl rmi --prune" + when: "'cri-o' in ansible_facts.packages" + tags: ["cleanup"] diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..358d55a --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - crio-cleanup diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..5d17192 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for crio-cleanup