From ed665c03da423f0371e47411185ce6aeb3875709 Mon Sep 17 00:00:00 2001 From: vincent Date: Tue, 24 Oct 2023 22:45:58 +0200 Subject: [PATCH] fix: issue with OS detection --- tasks/main.yml | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 19f64f0..3920d59 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -16,20 +16,20 @@ changed_when: false register: arch -- name: Install python for rocky - ansible.builtin.raw: dnf install python3 --assumeyes - changed_when: false - when: rocky.stdout +#- name: Install python for rocky + # ansible.builtin.raw: dnf install python3 --assumeyes + #changed_when: false + #when: rocky.stdout -- name: Install python for debian - ansible.builtin.raw: apt install python3 --assume-yes - changed_when: false - when: debian.stdout +#- name: Install python for debian + # ansible.builtin.raw: apt install python3 --assume-yes + #changed_when: false + #when: debian.stdout - name: Install python on arch ansible.builtin.raw: pacman -Sy python --noconfirm changed_when: false - when: arch.stdout + when: arch.stdout is match(".*Arch Linux.*") - name: Add local repo to mirrorlist become: true @@ -38,14 +38,15 @@ line: 'Server= {{ system_arch_local_mirror }}/$repo/os/$arch' state: present insertbefore: BOF - when: system_arch_local_mirror is defined and arch.stdout + when: system_arch_local_mirror is defined and arch.stdout is match(".*Arch Linux.*") + - name: Update archlinux-keyring community.general.pacman: state: latest name: archlinux-keyring become: true - when: arch.stdout + when: arch.stdout is match(".*Arch Linux.*") - name: Upgrade system for arch community.general.pacman: @@ -55,7 +56,8 @@ update_cache: true become: true register: upgrade_arch - when: arch.stdout + when: arch.stdout is match(".*Arch Linux.*") + - name: Upgrade system for debian ansible.builtin.apt: @@ -63,15 +65,15 @@ only_upgrade: true upgrade: full become: true - when: debian.stdout + when: debian.stdout is match(".*Debian.*") register: upgrade_debian - name: Reboot updates to apply ansible.builtin.reboot: reboot_timeout: 3600 when: - (arch.stdout and (upgrade_arch.changed and upgrade_arch.packages is defined and "linux" in upgrade_arch.packages)) - or (debian.stdout and upgrade_debian.changed) + (arch.stdout is match(".*Arch Linux.*") and (upgrade_arch.changed and upgrade_arch.packages is defined and "linux" in upgrade_arch.packages)) + or (debian.stdout is match(".*Debian.*") and upgrade_debian.changed) become: true - name: Collect only selected facts @@ -90,7 +92,7 @@ ansible.builtin.package: state: present name: inetutils - when: arch.stdout + when: ansible_os_family == "Archlinux" - name: Sudoers install ansible.builtin.package: