From be95e6202873af6893b2ca1f04de8ca295382fe2 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Thu, 19 Oct 2023 09:38:34 +0200 Subject: [PATCH 1/5] Update default release to 18.x --- README.md | 8 ++++---- manifests/params.pp | 2 +- spec/classes/nodejs_spec.rb | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index b1270885..80ea5fed 100644 --- a/README.md +++ b/README.md @@ -50,14 +50,14 @@ To install Node.js and npm (using the NodeSource repository if possible): class { 'nodejs': } ``` -The default version installed is currently `12.x`. +The default version installed is currently `18.x`. -If you wish to install a Node.js 13.x release from the NodeSource repository -rather than 12.x on Debian/RHEL platforms: +If you wish to install a Node.js 21.x release from the NodeSource repository +rather than 18.x on Debian/RHEL platforms: ```puppet class { 'nodejs': - repo_url_suffix => '13.x', + repo_url_suffix => '21.x', } ``` diff --git a/manifests/params.pp b/manifests/params.pp index abeb4cb0..78db11b4 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -11,7 +11,7 @@ $repo_proxy_password = 'absent' $repo_proxy_username = 'absent' $repo_release = undef - $repo_url_suffix = '12.x' + $repo_url_suffix = '18.x' $use_flags = ['npm', 'snapshot'] $cmd_exe_path = $facts['os']['family'] ? { diff --git a/spec/classes/nodejs_spec.rb b/spec/classes/nodejs_spec.rb index c28dff9f..480dd828 100644 --- a/spec/classes/nodejs_spec.rb +++ b/spec/classes/nodejs_spec.rb @@ -299,15 +299,15 @@ if operatingsystemmajrelease == '7' operatingsystem = 'CentOS' dist_type = 'el' - repo_baseurl = "https://rpm.nodesource.com/pub_12.x/#{dist_type}/#{operatingsystemmajrelease}/$basearch" - repo_source_baseurl = "https://rpm.nodesource.com/pub_12.x/#{dist_type}/#{operatingsystemmajrelease}/SRPMS" + repo_baseurl = "https://rpm.nodesource.com/pub_18.x/#{dist_type}/#{operatingsystemmajrelease}/$basearch" + repo_source_baseurl = "https://rpm.nodesource.com/pub_18.x/#{dist_type}/#{operatingsystemmajrelease}/SRPMS" repo_descr = "Node.js Packages for Enterprise Linux #{operatingsystemmajrelease} - $basearch" repo_source_descr = "Node.js for Enterprise Linux #{operatingsystemmajrelease} - $basearch - Source" else operatingsystem = 'Fedora' dist_type = 'fc' - repo_baseurl = "https://rpm.nodesource.com/pub_12.x/#{dist_type}/#{operatingsystemmajrelease}/$basearch" - repo_source_baseurl = "https://rpm.nodesource.com/pub_12.x/#{dist_type}/#{operatingsystemmajrelease}/SRPMS" + repo_baseurl = "https://rpm.nodesource.com/pub_18.x/#{dist_type}/#{operatingsystemmajrelease}/$basearch" + repo_source_baseurl = "https://rpm.nodesource.com/pub_18.x/#{dist_type}/#{operatingsystemmajrelease}/SRPMS" repo_descr = "Node.js Packages for Fedora Core #{operatingsystemmajrelease} - $basearch" repo_source_descr = "Node.js for Fedora Core #{operatingsystemmajrelease} - $basearch - Source" end @@ -1312,8 +1312,8 @@ } end - repo_baseurl = 'https://rpm.nodesource.com/pub_12.x/el/7/$basearch' - repo_source_baseurl = 'https://rpm.nodesource.com/pub_12.x/el/7/SRPMS' + repo_baseurl = 'https://rpm.nodesource.com/pub_18.x/el/7/$basearch' + repo_source_baseurl = 'https://rpm.nodesource.com/pub_18.x/el/7/SRPMS' repo_descr = 'Node.js Packages for Enterprise Linux 7 - $basearch' repo_source_descr = 'Node.js for Enterprise Linux 7 - $basearch - Source' From 1746e33140bb2f4bc071296319845f8cac7c3295 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Thu, 19 Oct 2023 09:58:37 +0200 Subject: [PATCH 2/5] use _authToken not _secret as the later is not accepted by modern npm --- spec/acceptance/class_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index eda53722..92765f54 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -97,7 +97,7 @@ class { 'nodejs': let(:manifest) do <<-PUPPET class { 'nodejs': } - nodejs::npm::global_config_entry { '//path.to.registry/:_secret': + nodejs::npm::global_config_entry { '//path.to.registry/:_authToken': ensure => present, value => 'cGFzc3dvcmQ=', require => Package[nodejs], @@ -109,7 +109,7 @@ class { 'nodejs': } describe 'npm config' do it 'contains the global_config_entry secret' do npm_output = shell('cat $(/usr/bin/npm config get globalconfig)') - expect(npm_output.stdout).to match '//path.to.registry/:_secret="cGFzc3dvcmQ="' + expect(npm_output.stdout).to match '//path.to.registry/:_authToken="cGFzc3dvcmQ="' end end end @@ -121,7 +121,7 @@ class { 'nodejs': } let(:manifest) do <<-PUPPET class { 'nodejs': } - nodejs::npm::global_config_entry { '//path.to.registry/:_secret': + nodejs::npm::global_config_entry { '//path.to.registry/:_authToken': ensure => present, value => 'cGFzc3dvcmQ', require => Package[nodejs], @@ -133,7 +133,7 @@ class { 'nodejs': } describe 'npm config' do it 'contains the global_config_entry secret' do npm_output = shell('cat $(/usr/bin/npm config get globalconfig)') - expect(npm_output.stdout).to match '//path.to.registry/:_secret=cGFzc3dvcmQ' + expect(npm_output.stdout).to match '//path.to.registry/:_authToken=cGFzc3dvcmQ' end end end From f5ebc49f35745cfb5745d440859f8f01ff7dd79b Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Thu, 19 Oct 2023 10:24:20 +0200 Subject: [PATCH 3/5] set module_hotfixes=true on EL8+ to be able to install from nodesource --- manifests/repo/nodesource/yum.pp | 50 ++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/manifests/repo/nodesource/yum.pp b/manifests/repo/nodesource/yum.pp index d45f7b13..be31b8e6 100644 --- a/manifests/repo/nodesource/yum.pp +++ b/manifests/repo/nodesource/yum.pp @@ -31,34 +31,40 @@ owner => 'root', source => "puppet:///modules/${module_name}/repo/dnf/nodejs.module", } + + $module_hotfixes = true + } else { + $module_hotfixes = undef } yumrepo { 'nodesource': - descr => $descr, - baseurl => $baseurl, - enabled => '1', - failovermethod => $yum_failovermethod, - gpgkey => 'file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL', - gpgcheck => '1', - priority => $priority, - proxy => $proxy, - proxy_password => $proxy_password, - proxy_username => $proxy_username, - require => File['/etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL'], + descr => $descr, + baseurl => $baseurl, + enabled => '1', + failovermethod => $yum_failovermethod, + gpgkey => 'file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL', + gpgcheck => '1', + module_hotfixes => $module_hotfixes, + priority => $priority, + proxy => $proxy, + proxy_password => $proxy_password, + proxy_username => $proxy_username, + require => File['/etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL'], } yumrepo { 'nodesource-source': - descr => $source_descr, - baseurl => $source_baseurl, - enabled => $yum_source_enabled, - failovermethod => $yum_failovermethod, - gpgkey => 'file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL', - gpgcheck => '1', - priority => $priority, - proxy => $proxy, - proxy_password => $proxy_password, - proxy_username => $proxy_username, - require => File['/etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL'], + descr => $source_descr, + baseurl => $source_baseurl, + enabled => $yum_source_enabled, + failovermethod => $yum_failovermethod, + gpgkey => 'file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL', + gpgcheck => '1', + module_hotfixes => $module_hotfixes, + priority => $priority, + proxy => $proxy, + proxy_password => $proxy_password, + proxy_username => $proxy_username, + require => File['/etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL'], } file { '/etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL': From 160ea93dbc6f6633d01f0a078541bbad21ad93ba Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Fri, 27 Oct 2023 10:07:31 +0200 Subject: [PATCH 4/5] ensure npm to present by default on EL nodesource started adding "provides: npm" to their nodejs packages, which makes our code uninstall the nodejs package again --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index 78db11b4..8a70a8c8 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -38,7 +38,7 @@ $nodejs_dev_package_name = 'nodejs-devel' $nodejs_dev_package_ensure = 'absent' $nodejs_package_name = 'nodejs' - $npm_package_ensure = 'absent' + $npm_package_ensure = 'present' $npm_package_name = 'npm' $npm_path = '/usr/bin/npm' $repo_class = 'nodejs::repo::nodesource' From 1952085b8e4dcd32c5d4a1bd46e017859f030410 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Fri, 27 Oct 2023 11:00:45 +0200 Subject: [PATCH 5/5] default to 16.x on el7 --- manifests/params.pp | 5 ++++- spec/classes/nodejs_spec.rb | 23 +++++++---------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 8a70a8c8..ff11fa3f 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -11,7 +11,10 @@ $repo_proxy_password = 'absent' $repo_proxy_username = 'absent' $repo_release = undef - $repo_url_suffix = '18.x' + $repo_url_suffix = ($facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '7') ? { + true => '16.x', + default => '18.x', + } $use_flags = ['npm', 'snapshot'] $cmd_exe_path = $facts['os']['family'] ? { diff --git a/spec/classes/nodejs_spec.rb b/spec/classes/nodejs_spec.rb index 480dd828..b77263d4 100644 --- a/spec/classes/nodejs_spec.rb +++ b/spec/classes/nodejs_spec.rb @@ -292,25 +292,16 @@ end end - ['7.0', '27'].each do |operatingsystemrelease| + ['7.0'].each do |operatingsystemrelease| osversions = operatingsystemrelease.split('.') operatingsystemmajrelease = osversions[0] - if operatingsystemmajrelease == '7' - operatingsystem = 'CentOS' - dist_type = 'el' - repo_baseurl = "https://rpm.nodesource.com/pub_18.x/#{dist_type}/#{operatingsystemmajrelease}/$basearch" - repo_source_baseurl = "https://rpm.nodesource.com/pub_18.x/#{dist_type}/#{operatingsystemmajrelease}/SRPMS" - repo_descr = "Node.js Packages for Enterprise Linux #{operatingsystemmajrelease} - $basearch" - repo_source_descr = "Node.js for Enterprise Linux #{operatingsystemmajrelease} - $basearch - Source" - else - operatingsystem = 'Fedora' - dist_type = 'fc' - repo_baseurl = "https://rpm.nodesource.com/pub_18.x/#{dist_type}/#{operatingsystemmajrelease}/$basearch" - repo_source_baseurl = "https://rpm.nodesource.com/pub_18.x/#{dist_type}/#{operatingsystemmajrelease}/SRPMS" - repo_descr = "Node.js Packages for Fedora Core #{operatingsystemmajrelease} - $basearch" - repo_source_descr = "Node.js for Fedora Core #{operatingsystemmajrelease} - $basearch - Source" - end + operatingsystem = 'CentOS' + dist_type = 'el' + repo_baseurl = "https://rpm.nodesource.com/pub_16.x/#{dist_type}/#{operatingsystemmajrelease}/$basearch" + repo_source_baseurl = "https://rpm.nodesource.com/pub_16.x/#{dist_type}/#{operatingsystemmajrelease}/SRPMS" + repo_descr = "Node.js Packages for Enterprise Linux #{operatingsystemmajrelease} - $basearch" + repo_source_descr = "Node.js for Enterprise Linux #{operatingsystemmajrelease} - $basearch - Source" context "when run on #{operatingsystem} release #{operatingsystemrelease}" do let :facts do