From c30295130049230695f67728d702e2cb49357a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20HOVINNE?= <jean-francois.hovinne@ext.ec.europa.eu> Date: Fri, 12 Jan 2024 14:04:42 +0100 Subject: [PATCH] Switch to dnf module (RHEL), remove Node.js 16.x support (fixes #17) --- README.md | 2 +- RELEASES.md | 4 ++++ molecule/custom/converge.yml | 1 - tasks/main.yml | 4 ---- tasks/setup-RedHat.yml | 35 +++++++---------------------------- 5 files changed, 12 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index afdf961..97b6ba5 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Requirements Role Variables -------------- -- `nodejs_version`: Sets the Node.js version to install ("16.x", "18.x", "20.x", etc). +- `nodejs_version`: Sets the Node.js version to install ("18.x", "20.x", etc). The default version is 20.x. diff --git a/RELEASES.md b/RELEASES.md index 05ce80e..a6c88f7 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,5 +1,9 @@ # Releases +## 2.1.0 + +- Node.js 16.x support removed. + ## 2.0.0 - Node.js 20.x set as default version. diff --git a/molecule/custom/converge.yml b/molecule/custom/converge.yml index f614f0a..c773755 100644 --- a/molecule/custom/converge.yml +++ b/molecule/custom/converge.yml @@ -9,7 +9,6 @@ vars: nodejs_version: "{{ version }}" loop: - - "16.x" - "20.x" - "18.x" loop_control: diff --git a/tasks/main.yml b/tasks/main.yml index cbc3837..23bebc0 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -3,10 +3,6 @@ ansible.builtin.set_fact: nodejs_version_major: "{{ nodejs_version | regex_replace('.x', '') }}" -- name: Setup - ansible.builtin.include_tasks: setup-RedHat.yml - when: ansible_os_family == 'RedHat' and nodejs_version_major | int < 17 - - name: Setup ansible.builtin.include_tasks: setup-RedHat.yml when: ansible_os_family == 'RedHat' and ansible_distribution != 'Amazon' and nodejs_version_major | int > 16 diff --git a/tasks/setup-RedHat.yml b/tasks/setup-RedHat.yml index 30c6fb4..0c04b46 100644 --- a/tasks/setup-RedHat.yml +++ b/tasks/setup-RedHat.yml @@ -8,41 +8,20 @@ rhel_distribution_major_version: "{{ ansible_distribution_major_version }}" when: ansible_distribution_major_version | int >= 8 -- name: Import NodeSource RPM key - ansible.builtin.rpm_key: - key: https://rpm.nodesource.com/gpgkey/nodesource.gpg.key - state: present - become: true - -- name: Remove previous NodeSource repository file +- name: Remove previous NodeSource repository files ansible.builtin.file: - path: "/etc/yum.repos.d/nodesource-{{ nodejs_version }}.repo" + path: "{{ item }}" state: absent + loop: + - "/etc/yum.repos.d/nodesource-{{ nodejs_version }}.repo" + - "/etc/yum.repos.d/nodesource-nodejs-{{ nodejs_version }}.repo" notify: Clean yum metadata become: true -- name: Add Node.js repository file - ansible.builtin.template: - src: nodesource-nodejs.repo.j2 - dest: "/etc/yum.repos.d/nodesource-nodejs-{{ nodejs_version }}.repo" - owner: root - group: root - mode: '0644' - notify: Clean yum metadata - become: true - -- name: Ensure Node.js AppStream module is disabled (CentOS 8+) - 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_distribution_major_version | int >= 8 - become: true - - name: Ensure Node.js and npm are installed - ansible.builtin.yum: - name: "nodejs-{{ nodejs_version | regex_replace('x', '') }}*" + ansible.builtin.dnf: + name: "@nodejs:{{ nodejs_version_major }}/common" state: present - enablerepo: "nodesource-nodejs-{{ nodejs_version }}" allow_downgrade: true become: true -- GitLab