From 330e7e93055c87c32c7855004969781f8536e17f Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 14 Nov 2022 09:04:53 +0000 Subject: [PATCH] Clear pacman cache --- ansible/main.yml | 2 ++ ansible/roles/paccache/files/paccache.hook | 11 +++++++++++ ansible/roles/paccache/tasks/main.yml | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 ansible/roles/paccache/files/paccache.hook create mode 100644 ansible/roles/paccache/tasks/main.yml diff --git a/ansible/main.yml b/ansible/main.yml index e312333..390b606 100644 --- a/ansible/main.yml +++ b/ansible/main.yml @@ -3,6 +3,8 @@ - base - role: realorangeone.reflector when: ansible_os_family == 'Archlinux' + - role: paccache + when: ansible_os_family == 'Archlinux' - hosts: casey roles: diff --git a/ansible/roles/paccache/files/paccache.hook b/ansible/roles/paccache/files/paccache.hook new file mode 100644 index 0000000..92c559a --- /dev/null +++ b/ansible/roles/paccache/files/paccache.hook @@ -0,0 +1,11 @@ +[Trigger] +Operation = Upgrade +Operation = Install +Operation = Remove +Type = Package +Target = * + +[Action] +Description = Cleaning pacman cache... +When = PostTransaction +Exec = /usr/bin/paccache -r diff --git a/ansible/roles/paccache/tasks/main.yml b/ansible/roles/paccache/tasks/main.yml new file mode 100644 index 0000000..3265413 --- /dev/null +++ b/ansible/roles/paccache/tasks/main.yml @@ -0,0 +1,18 @@ +- name: Install Pacman utils + package: + name: pacman-contrib + become: true + +- name: Create hooks directory + file: + path: /etc/pacman.d/hooks/ + state: directory + mode: "0755" + become: true + +- name: Install pacman hook + template: + src: files/paccache.hook + dest: /etc/pacman.d/hooks/clean_package_cache.hook + mode: "0644" + become: true