fix: Use dnf swap instead of rm/install for curl 94/73994/2
authorAnil Belur <abelur@linuxfoundation.org>
Mon, 15 Dec 2025 11:48:31 +0000 (21:48 +1000)
committerAnil Belur <abelur@linuxfoundation.org>
Mon, 15 Dec 2025 11:56:25 +0000 (21:56 +1000)
- 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 <abelur@linuxfoundation.org>
molecule/default/prepare.yml
tasks/main.yml

index 677c230..2753c1e 100644 (file)
@@ -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
index 1630552..22377e0 100644 (file)
           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