From: Anil Belur Date: Mon, 15 Dec 2025 11:48:31 +0000 (+1000) Subject: fix: Use dnf swap instead of rm/install for curl X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F94%2F73994%2F2;p=ansible%2Froles%2Flf-recommended-tools.git fix: Use dnf swap instead of rm/install for curl - Replace 'dnf remove && dnf install' with 'dnf swap --allowerasing' - Prevents removing dnf (protected package) when swapping curl-minimal - Fixes CentOS 9 prepare failure Change-Id: I216a9fc9af8a9721746e0788decb0b118f1ea70d Signed-off-by: Anil Belur --- diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml index 677c230..2753c1e 100644 --- a/molecule/default/prepare.yml +++ b/molecule/default/prepare.yml @@ -27,7 +27,7 @@ - name: Replace curl-minimal with curl on CentOS 9+ ansible.builtin.shell: | - dnf remove -y curl-minimal && dnf install -y curl + dnf swap -y curl-minimal curl --allowerasing when: ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] is version('9', '>=') become: true changed_when: true diff --git a/tasks/main.yml b/tasks/main.yml index 1630552..22377e0 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -119,12 +119,21 @@ ansible.builtin.command: yum module disable -y nodejs # noqa command-instead-of-module register: module_disable changed_when: "'Nothing to do.' not in module_disable.stdout" - when: ansible_facts['distribution_major_version'] | int >= 8 + when: + - ansible_facts['distribution_major_version'] | int >= 8 + - ansible_facts['distribution_major_version'] | int < 9 - name: Ensure Node.js and npm are installed. ansible.builtin.yum: name: "nodejs-{{ nodejs_version | regex_replace('x', '') }}*" state: present + when: ansible_facts['distribution_major_version'] | int < 9 + + - name: Ensure Node.js and npm are installed (CentOS 9+). + ansible.builtin.dnf: + name: nodejs + state: present + when: ansible_facts['distribution_major_version'] | int >= 9 - name: Add NodeSource repository/NodeJS under Ubuntu become: true