From a29e10e31324dbba1045dac1593888258ebdb8f3 Mon Sep 17 00:00:00 2001 From: Claude Bot Date: Fri, 6 Nov 2026 13:26:34 +0100 Subject: [PATCH 1/2] fix(common): empty the pacman package cache in the base play The cache cleanup from #1579 sat in os-update, which site.yml does not run, so site.yml still failed on edge-1 with "no space left on device" when pulling the Alloy image. The hook and the cleanup move to common, which site.yml runs on every host before install-edge-host. Co-Authored-By: Claude Opus 5.5 --- .../files/pacman-cache.hook | 2 +- ansible/roles/common/tasks/main.yml | 23 +++++++++++++++ ansible/roles/os-update/tasks/main.yml | 28 ------------------- 3 files changed, 24 insertions(+), 29 deletions(-) rename ansible/roles/{os-update => common}/files/pacman-cache.hook (89%) diff --git a/ansible/roles/os-update/files/pacman-cache.hook b/ansible/roles/common/files/pacman-cache.hook similarity index 89% rename from ansible/roles/os-update/files/pacman-cache.hook rename to ansible/roles/common/files/pacman-cache.hook index 1fa1597e..6f8ef293 100644 --- a/ansible/roles/os-update/files/pacman-cache.hook +++ b/ansible/roles/common/files/pacman-cache.hook @@ -1,4 +1,4 @@ -# Managed by ansible (roles/os-update). +# Managed by ansible (roles/common). # Downloaded packages are not kept; older versions come from the Arch Linux # Archive. [Trigger] diff --git a/ansible/roles/common/tasks/main.yml b/ansible/roles/common/tasks/main.yml index c5e02472..bf3935fe 100644 --- a/ansible/roles/common/tasks/main.yml +++ b/ansible/roles/common/tasks/main.yml @@ -35,6 +35,29 @@ state: present when: ansible_facts['os_family'] is defined and ansible_facts['os_family'] == 'RedHat' +# pacman keeps every downloaded package; on the edge hosts' 7 GB eMMC root +# the cache grows to gigabytes. The hook empties it after every transaction. +- name: Ensure the pacman hook directory exists (Arch) + ansible.builtin.file: + path: /etc/pacman.d/hooks + state: directory + mode: "0755" + when: ansible_facts['os_family'] == 'Archlinux' + +- name: Empty the package cache after every transaction (Arch) + ansible.builtin.copy: + src: pacman-cache.hook + dest: /etc/pacman.d/hooks/pacman-cache.hook + mode: "0644" + when: ansible_facts['os_family'] == 'Archlinux' + +- name: Empty the package cache (Arch) + ansible.builtin.command: + argv: [find, /var/cache/pacman/pkg, -mindepth, "1", -delete, -print] + register: common_pacman_cache + changed_when: common_pacman_cache.stdout | length > 0 + when: ansible_facts['os_family'] == 'Archlinux' + # ------------------------------------------------------- # 2. Configure QEMU Guest Agent (VMs Only) # ------------------------------------------------------- diff --git a/ansible/roles/os-update/tasks/main.yml b/ansible/roles/os-update/tasks/main.yml index fc2f8506..d7963f05 100644 --- a/ansible/roles/os-update/tasks/main.yml +++ b/ansible/roles/os-update/tasks/main.yml @@ -25,34 +25,6 @@ check_mode: false when: os_update_docker.stat.exists -# pacman keeps every downloaded package; on the edge hosts' 7 GB eMMC root -# the cache grows to gigabytes. -- name: Ensure the pacman hook directory exists (Arch) - ansible.builtin.file: - path: /etc/pacman.d/hooks - state: directory - mode: "0755" - when: ansible_facts['os_family'] == 'Archlinux' - -- name: Empty the package cache after every transaction (Arch) - ansible.builtin.copy: - src: pacman-cache.hook - dest: /etc/pacman.d/hooks/pacman-cache.hook - mode: "0644" - when: ansible_facts['os_family'] == 'Archlinux' - -- name: Empty the package cache (Arch) - ansible.builtin.command: - argv: [find, /var/cache/pacman/pkg, -mindepth, "1", -delete, -print] - register: os_update_pacman_cache - changed_when: os_update_pacman_cache.stdout | length > 0 - when: ansible_facts['os_family'] == 'Archlinux' - -- name: Re-read mounts after the cache cleanup - ansible.builtin.setup: - gather_subset: [mounts] - when: os_update_pacman_cache is changed - - name: Assert at least 1 GiB free on / ansible.builtin.assert: that: >- -- 2.54.0 From d457c7e639d5aba17dbc0b33b1493fbc224fa368 Mon Sep 17 00:00:00 2001 From: Claude Bot Date: Fri, 6 Nov 2026 13:45:30 +0100 Subject: [PATCH 2/2] refactor(pacman-cache): own role instead of common The pacman cache policy is its own concern, not base configuration of every host. The new role pacman-cache runs in install-edge-host after common and before docker-install; common is unchanged. Co-Authored-By: Claude Opus 5.5 --- ansible/plays/install-edge-host.yml | 1 + ansible/roles/common/tasks/main.yml | 23 ------------------- .../files/pacman-cache.hook | 2 +- ansible/roles/pacman-cache/tasks/main.yml | 21 +++++++++++++++++ 4 files changed, 23 insertions(+), 24 deletions(-) rename ansible/roles/{common => pacman-cache}/files/pacman-cache.hook (88%) create mode 100644 ansible/roles/pacman-cache/tasks/main.yml diff --git a/ansible/plays/install-edge-host.yml b/ansible/plays/install-edge-host.yml index 45e1c99f..16056a9a 100644 --- a/ansible/plays/install-edge-host.yml +++ b/ansible/plays/install-edge-host.yml @@ -34,6 +34,7 @@ roles: - certificates - common + - pacman-cache - edge-flash-wear - docker-install - edge-log-shipper diff --git a/ansible/roles/common/tasks/main.yml b/ansible/roles/common/tasks/main.yml index bf3935fe..c5e02472 100644 --- a/ansible/roles/common/tasks/main.yml +++ b/ansible/roles/common/tasks/main.yml @@ -35,29 +35,6 @@ state: present when: ansible_facts['os_family'] is defined and ansible_facts['os_family'] == 'RedHat' -# pacman keeps every downloaded package; on the edge hosts' 7 GB eMMC root -# the cache grows to gigabytes. The hook empties it after every transaction. -- name: Ensure the pacman hook directory exists (Arch) - ansible.builtin.file: - path: /etc/pacman.d/hooks - state: directory - mode: "0755" - when: ansible_facts['os_family'] == 'Archlinux' - -- name: Empty the package cache after every transaction (Arch) - ansible.builtin.copy: - src: pacman-cache.hook - dest: /etc/pacman.d/hooks/pacman-cache.hook - mode: "0644" - when: ansible_facts['os_family'] == 'Archlinux' - -- name: Empty the package cache (Arch) - ansible.builtin.command: - argv: [find, /var/cache/pacman/pkg, -mindepth, "1", -delete, -print] - register: common_pacman_cache - changed_when: common_pacman_cache.stdout | length > 0 - when: ansible_facts['os_family'] == 'Archlinux' - # ------------------------------------------------------- # 2. Configure QEMU Guest Agent (VMs Only) # ------------------------------------------------------- diff --git a/ansible/roles/common/files/pacman-cache.hook b/ansible/roles/pacman-cache/files/pacman-cache.hook similarity index 88% rename from ansible/roles/common/files/pacman-cache.hook rename to ansible/roles/pacman-cache/files/pacman-cache.hook index 6f8ef293..12641271 100644 --- a/ansible/roles/common/files/pacman-cache.hook +++ b/ansible/roles/pacman-cache/files/pacman-cache.hook @@ -1,4 +1,4 @@ -# Managed by ansible (roles/common). +# Managed by ansible (roles/pacman-cache). # Downloaded packages are not kept; older versions come from the Arch Linux # Archive. [Trigger] diff --git a/ansible/roles/pacman-cache/tasks/main.yml b/ansible/roles/pacman-cache/tasks/main.yml new file mode 100644 index 00000000..1b9dc263 --- /dev/null +++ b/ansible/roles/pacman-cache/tasks/main.yml @@ -0,0 +1,21 @@ +--- +# Keep the pacman package cache empty. pacman keeps every downloaded package; +# on a 7 GB eMMC root the cache grows to gigabytes. Arch hosts only. + +- name: Ensure the pacman hook directory exists + ansible.builtin.file: + path: /etc/pacman.d/hooks + state: directory + mode: "0755" + +- name: Empty the package cache after every transaction + ansible.builtin.copy: + src: pacman-cache.hook + dest: /etc/pacman.d/hooks/pacman-cache.hook + mode: "0644" + +- name: Empty the package cache + ansible.builtin.command: + argv: [find, /var/cache/pacman/pkg, -mindepth, "1", -delete, -print] + register: pacman_cache_clean + changed_when: pacman_cache_clean.stdout | length > 0 -- 2.54.0