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..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 = '12.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'] ? { @@ -38,7 +41,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' 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': 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 diff --git a/spec/classes/nodejs_spec.rb b/spec/classes/nodejs_spec.rb index c28dff9f..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_12.x/#{dist_type}/#{operatingsystemmajrelease}/$basearch" - repo_source_baseurl = "https://rpm.nodesource.com/pub_12.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_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 @@ -1312,8 +1303,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'