- 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
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