From 64b50f7501fe26b5112fa50396d259874651d7e8 Mon Sep 17 00:00:00 2001 From: jakub Date: Thu, 3 Sep 2026 14:58:24 +0200 Subject: [PATCH] support Arch Linux system updates --- requirements.yml | 3 ++- roles/update_apt/tasks/main.yml | 23 ++++++++++++++++++ roles/update_arch/tasks/main.yml | 9 +++++++ update.yml | 40 ++++++++++++++------------------ 4 files changed, 51 insertions(+), 24 deletions(-) create mode 100644 roles/update_apt/tasks/main.yml create mode 100644 roles/update_arch/tasks/main.yml diff --git a/requirements.yml b/requirements.yml index 285ae31..6d419ad 100644 --- a/requirements.yml +++ b/requirements.yml @@ -1,2 +1,3 @@ collections: - - name: community.routeros \ No newline at end of file + - name: community.routeros + - name: community.general diff --git a/roles/update_apt/tasks/main.yml b/roles/update_apt/tasks/main.yml new file mode 100644 index 0000000..85fe83c --- /dev/null +++ b/roles/update_apt/tasks/main.yml @@ -0,0 +1,23 @@ +--- +- name: Update apt cache + ansible.builtin.apt: + update_cache: true + lock_timeout: 300 + +- name: Perform full upgrade + ansible.builtin.apt: + upgrade: full + autoremove: true + autoclean: true + lock_timeout: 300 + register: apt_upgrade + retries: 3 + delay: 10 + until: apt_upgrade is succeeded + +- name: Fix broken packages + ansible.builtin.command: + cmd: apt-get -f install -y + register: fix_result + failed_when: false + changed_when: "'Setting up' in fix_result.stdout" diff --git a/roles/update_arch/tasks/main.yml b/roles/update_arch/tasks/main.yml new file mode 100644 index 0000000..a1a7b72 --- /dev/null +++ b/roles/update_arch/tasks/main.yml @@ -0,0 +1,9 @@ +--- +- name: Update pacman cache and upgrade all packages + community.general.pacman: + update_cache: true + upgrade: true + register: pacman_upgrade + retries: 3 + delay: 10 + until: pacman_upgrade is succeeded diff --git a/update.yml b/update.yml index 6a110b5..a1f753c 100644 --- a/update.yml +++ b/update.yml @@ -1,5 +1,5 @@ --- -- name: Update system (APT + Flatpak) +- name: Update Linux system hosts: all:!localhost:!portainer2-jim.im.lab become: true gather_facts: false @@ -36,31 +36,25 @@ until: ping_result is success # --------------------------------------------------------- - # APT + # Distribution packages # --------------------------------------------------------- - - name: Update apt cache - ansible.builtin.apt: - update_cache: true - lock_timeout: 300 + - name: Update Debian-family packages + ansible.builtin.include_role: + name: update_apt + when: ansible_facts.os_family == 'Debian' - - name: Perform full upgrade - ansible.builtin.apt: - upgrade: full - autoremove: true - autoclean: true - lock_timeout: 300 - register: apt_upgrade - retries: 3 - delay: 10 - until: apt_upgrade is succeeded + - name: Update Arch Linux packages + ansible.builtin.include_role: + name: update_arch + when: ansible_facts.os_family == 'Archlinux' - - name: Fix broken packages - ansible.builtin.command: - cmd: apt-get -f install -y - register: fix_result - failed_when: false - changed_when: "'Setting up' in fix_result.stdout" + - name: Skip unsupported Linux distribution + ansible.builtin.debug: + msg: >- + Package updates are not configured for + {{ ansible_facts.distribution }} ({{ ansible_facts.os_family }}). + when: ansible_facts.os_family not in ['Debian', 'Archlinux'] # --------------------------------------------------------- # Flatpak @@ -144,4 +138,4 @@ - portainer tags: - never - - portainer \ No newline at end of file + - portainer