From ee4298966d213f1773d0cb490f79e7c61dfdebaf Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 15 Dec 2021 20:44:35 +0100 Subject: [PATCH 01/31] modulesync 5.1.0 --- .msync.yml | 2 +- .puppet-lint.rc | 3 +++ Gemfile | 4 ++-- Rakefile | 2 +- spec/spec_helper.rb | 10 +++++----- spec/spec_helper_acceptance.rb | 2 ++ 6 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 .puppet-lint.rc diff --git a/.msync.yml b/.msync.yml index 43966c2f..a83abd9b 100644 --- a/.msync.yml +++ b/.msync.yml @@ -2,4 +2,4 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -modulesync_config_version: '4.2.0' +modulesync_config_version: '5.1.0' diff --git a/.puppet-lint.rc b/.puppet-lint.rc new file mode 100644 index 00000000..dd8272c7 --- /dev/null +++ b/.puppet-lint.rc @@ -0,0 +1,3 @@ +--fail-on-warnings +--no-parameter_documentation-check +--no-parameter_types-check diff --git a/Gemfile b/Gemfile index a39114ce..b6dcf456 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" group :test do - gem 'voxpupuli-test', '~> 2.5', :require => false + gem 'voxpupuli-test', '~> 5.0', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false gem 'puppet_metadata', '~> 1.0', :require => false @@ -21,7 +21,7 @@ end group :release do gem 'github_changelog_generator', '>= 1.16.1', :require => false if RUBY_VERSION >= '2.5' - gem 'voxpupuli-release', '>= 1.0.2', :require => false + gem 'voxpupuli-release', '>= 1.2.0', :require => false gem 'puppet-strings', '>= 2.2', :require => false end diff --git a/Rakefile b/Rakefile index 80b799d6..f92f0516 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,7 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -# Attempt to load voxupuli-test (which pulls in puppetlabs_spec_helper), +# Attempt to load voxpupuli-test (which pulls in puppetlabs_spec_helper), # otherwise attempt to load it directly. begin require 'voxpupuli/test/rake' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 13da4ce5..78e8b77e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ @@ -7,15 +9,13 @@ # puppetlabs_spec_helper will set up coverage if the env variable is set. # We want to do this if lib exists and it hasn't been explicitly set. -ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../../lib', __FILE__)) +ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../lib', __dir__)) require 'voxpupuli/test/spec_helper' if File.exist?(File.join(__dir__, 'default_module_facts.yml')) facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml'))) - if facts - facts.each do |name, value| - add_custom_fact name.to_sym, value - end + facts&.each do |name, value| + add_custom_fact name.to_sym, value end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index d3b906bf..d3a6e23c 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ From f3b95d67e16aad79cd11531a62b9a044a7d30dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Tue, 18 Jan 2022 10:39:21 -1000 Subject: [PATCH 02/31] Auto-correct rubocop offenses --- lib/puppet/feature/npm.rb | 2 ++ lib/puppet/provider/package/npm.rb | 4 +++- lib/puppet/util/npm.rb | 2 ++ spec/acceptance/class_spec.rb | 6 +++++ spec/classes/nodejs_spec.rb | 24 ++++++++++--------- spec/defines/global_config_entry_spec.rb | 4 +++- spec/defines/nodejs_npm_spec.rb | 8 ++++--- spec/support/acceptance/shared_examples.rb | 2 ++ spec/unit/puppet/provider/package/npm_spec.rb | 4 +++- 9 files changed, 39 insertions(+), 17 deletions(-) diff --git a/lib/puppet/feature/npm.rb b/lib/puppet/feature/npm.rb index 877d4f27..31ba2d40 100644 --- a/lib/puppet/feature/npm.rb +++ b/lib/puppet/feature/npm.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'puppet/util/feature' require 'puppet/util/npm' diff --git a/lib/puppet/provider/package/npm.rb b/lib/puppet/provider/package/npm.rb index 07d82503..8d33a887 100644 --- a/lib/puppet/provider/package/npm.rb +++ b/lib/puppet/provider/package/npm.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'puppet/provider/package' Puppet::Type.type(:package).provide :npm, parent: Puppet::Provider::Package do @@ -18,7 +20,7 @@ def self.npmlist Puppet.debug("Warning: npm list --json exited with code #{output.exitstatus}") if output.exitstatus != 0 begin # ignore any npm output lines to be a bit more robust - output = PSON.parse(output.lines.select { |l| l =~ %r{^((?!^npm).*)$} }.join("\n"), max_nesting: 100) + output = PSON.parse(output.lines.grep(%r{^((?!^npm).*)$}).join("\n"), max_nesting: 100) @npmlist = output['dependencies'] || {} rescue PSON::ParserError => e Puppet.debug("Error: npm list --json command error #{e.message}") diff --git a/lib/puppet/util/npm.rb b/lib/puppet/util/npm.rb index 7f5a1c8c..4d0ed627 100644 --- a/lib/puppet/util/npm.rb +++ b/lib/puppet/util/npm.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Puppet module Util class Npm diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index ab7b3e19..dbf442c6 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper_acceptance' describe 'nodejs class:' do @@ -18,6 +20,7 @@ if %w[RedHat Debian].include? fact('os.family') describe package('nodejs') do it { is_expected.to be_installed } + it 'comes from the expected source' do pkg_output = shell(pkg_cmd) expect(pkg_output.stdout).to match 'nodesource' @@ -33,6 +36,7 @@ describe package('nodejs') do it { is_expected.to be_installed } + it 'comes from the expected source' do pending("This won't work until we have CentOS 7.4 because of dependency") pkg_output = shell(pkg_cmd) @@ -116,6 +120,7 @@ class { 'nodejs': describe package('nodejs-dev') do it { is_expected.to be_installed } end + if %w[16.04 18.04].include? fact('os.release.major') describe package('npm') do it { is_expected.to be_installed } @@ -125,6 +130,7 @@ class { 'nodejs': describe package('libnode-dev') do it { is_expected.to be_installed } end + describe package('npm') do it { is_expected.to be_installed } end diff --git a/spec/classes/nodejs_spec.rb b/spec/classes/nodejs_spec.rb index 95b3b462..df3f8c15 100644 --- a/spec/classes/nodejs_spec.rb +++ b/spec/classes/nodejs_spec.rb @@ -1,10 +1,12 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'nodejs', type: :class do on_supported_os.each do |os, facts| next unless facts[:os]['family'] == 'Debian' - context "on #{os} " do + context "on #{os}" do let :facts do facts end @@ -20,10 +22,10 @@ it 'the file resource root_npmrc should be in the catalog' do is_expected.to contain_file('root_npmrc').with( 'ensure' => 'file', - 'path' => '/root/.npmrc', - 'owner' => 'root', - 'group' => '0', - 'mode' => '0600' + 'path' => '/root/.npmrc', + 'owner' => 'root', + 'group' => '0', + 'mode' => '0600' ) end @@ -340,7 +342,7 @@ 'name' => operatingsystem, 'release' => { 'major' => operatingsystemmajrelease, - 'full' => operatingsystemrelease + 'full' => operatingsystemrelease } } } @@ -390,10 +392,10 @@ it 'the nodesource and nodesource-source repos should contain the right description and baseurl' do is_expected.to contain_yumrepo('nodesource').with('baseurl' => repo_baseurl, - 'descr' => repo_descr) + 'descr' => repo_descr) is_expected.to contain_yumrepo('nodesource-source').with('baseurl' => repo_source_baseurl, - 'descr' => repo_source_descr) + 'descr' => repo_source_descr) end end @@ -1320,7 +1322,7 @@ 'family' => 'RedHat', 'name' => 'Amazon', 'release' => { - 'full' => '2015.03', + 'full' => '2015.03', 'major' => '2015', 'minor' => '03' } @@ -1377,10 +1379,10 @@ it 'the nodesource and nodesource-source repos should contain the right description and baseurl' do is_expected.to contain_yumrepo('nodesource').with('baseurl' => repo_baseurl, - 'descr' => repo_descr) + 'descr' => repo_descr) is_expected.to contain_yumrepo('nodesource-source').with('baseurl' => repo_source_baseurl, - 'descr' => repo_source_descr) + 'descr' => repo_source_descr) end end diff --git a/spec/defines/global_config_entry_spec.rb b/spec/defines/global_config_entry_spec.rb index 15221b57..77a99e26 100644 --- a/spec/defines/global_config_entry_spec.rb +++ b/spec/defines/global_config_entry_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'nodejs::npm::global_config_entry', type: :define do @@ -6,7 +8,7 @@ end on_supported_os.each do |os, facts| - context "on #{os} " do + context "on #{os}" do let :facts do facts end diff --git a/spec/defines/nodejs_npm_spec.rb b/spec/defines/nodejs_npm_spec.rb index b9d65907..41c01304 100644 --- a/spec/defines/nodejs_npm_spec.rb +++ b/spec/defines/nodejs_npm_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'nodejs::npm', type: :define do @@ -6,7 +8,7 @@ end on_supported_os.each do |os, facts| - context "on #{os} " do + context "on #{os}" do let :facts do facts end @@ -35,7 +37,7 @@ it 'the npm install command should run under user foo' do is_expected.to contain_exec('npm_install_express').with( 'command' => "#{npm_path} install express ", - 'user' => 'foo' + 'user' => 'foo' ) end end @@ -380,7 +382,7 @@ it 'the command should be npm rm express --save' do is_expected.to contain_exec('npm_rm_express').with( 'command' => "#{npm_path} rm express --save", - 'cwd' => '/home/npm/packages' + 'cwd' => '/home/npm/packages' ) end end diff --git a/spec/support/acceptance/shared_examples.rb b/spec/support/acceptance/shared_examples.rb index f3b7627f..894e7d97 100644 --- a/spec/support/acceptance/shared_examples.rb +++ b/spec/support/acceptance/shared_examples.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + shared_examples 'an idempotent resource' do it 'applies with no errors' do apply_manifest(pp, catch_failures: true) diff --git a/spec/unit/puppet/provider/package/npm_spec.rb b/spec/unit/puppet/provider/package/npm_spec.rb index a9f0d7ff..f96ead57 100644 --- a/spec/unit/puppet/provider/package/npm_spec.rb +++ b/spec/unit/puppet/provider/package/npm_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Puppet::Type.type(:package).provider(:npm) do @@ -21,7 +23,7 @@ def self.it_should_respond_to(*actions) actions.each do |action| - it "should respond to :#{action}" do + it "responds to :#{action}" do expect(provider).to respond_to(action) end end From c986947bcee4bb2171a99ff4e0aa40d27b19269e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Tue, 18 Jan 2022 10:49:13 -1000 Subject: [PATCH 03/31] Fix remaining rubocop offences --- spec/acceptance/class_spec.rb | 62 ++++++++-------------- spec/classes/nodejs_spec.rb | 5 +- spec/support/acceptance/shared_examples.rb | 18 +++++++ 3 files changed, 43 insertions(+), 42 deletions(-) diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index dbf442c6..beeafc6b 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper_acceptance' -describe 'nodejs class:' do +describe 'nodejs' do case fact('os.family') when 'RedHat' pkg_cmd = 'yum info nodejs | grep "^From repo"' @@ -32,6 +32,8 @@ context 'repo_class => epel', if: ((fact('os.family') == 'RedHat') && (fact('os.release.major') != '8')) do let(:pp) { "class { 'nodejs': repo_class => '::epel' }" } + include_examples 'cleanup' + it_behaves_like 'an idempotent resource' describe package('nodejs') do @@ -82,58 +84,40 @@ end end end -end - -# Must uninstall the default nodesource repo and packages which come from there before attempting -# to install native packages. -context 'uninstall' do - let(:pp) do - " - class { 'nodejs': - nodejs_debug_package_ensure => absent, - nodejs_dev_package_ensure => absent, - nodejs_package_ensure => absent, - npm_package_ensure => absent, - repo_ensure => absent, - } - " - end - - it_behaves_like 'an idempotent resource' -end -context 'native Debian packages' do - let(:pp) do - " + context 'native Debian packages' do + let(:pp) do + " class { 'nodejs': manage_package_repo => false, nodejs_dev_package_ensure => present, npm_package_ensure => present, } " - end + end - it_behaves_like 'an idempotent resource' + include_examples 'cleanup' - if fact('os.family') == 'Debian' - if %w[9 16.04 18.04].include? fact('os.release.major') - describe package('nodejs-dev') do - it { is_expected.to be_installed } + it_behaves_like 'an idempotent resource' + + expected_packages = [] + + if fact('os.family') == 'Debian' + if %w[9 16.04 18.04].include? fact('os.release.major') + expected_packages << 'nodejs-dev' + + expected_packages << 'npm' if %w[16.04 18.04].include? fact('os.release.major') + else + expected_packages << 'libnode-dev' + + expected_packages << 'npm' end - if %w[16.04 18.04].include? fact('os.release.major') - describe package('npm') do + expected_packages.each do |pkg| + describe package(pkg) do it { is_expected.to be_installed } end end - else - describe package('libnode-dev') do - it { is_expected.to be_installed } - end - - describe package('npm') do - it { is_expected.to be_installed } - end end end end diff --git a/spec/classes/nodejs_spec.rb b/spec/classes/nodejs_spec.rb index df3f8c15..a020e0fb 100644 --- a/spec/classes/nodejs_spec.rb +++ b/spec/classes/nodejs_spec.rb @@ -11,9 +11,8 @@ facts end - native_debian_devel_package = if facts[:os]['name'] == 'Ubuntu' && Gem::Version.new(facts[:os]['release']['major']) >= Gem::Version.new('20.04') - 'libnode-dev' - elsif facts[:os]['name'] == 'Debian' && Gem::Version.new(facts[:os]['release']['major']) >= Gem::Version.new(10) + native_debian_devel_package = if (facts[:os]['name'] == 'Ubuntu' && Gem::Version.new(facts[:os]['release']['major']) >= Gem::Version.new('20.04')) || + (facts[:os]['name'] == 'Debian' && Gem::Version.new(facts[:os]['release']['major']) >= Gem::Version.new(10)) 'libnode-dev' else 'nodejs-dev' diff --git a/spec/support/acceptance/shared_examples.rb b/spec/support/acceptance/shared_examples.rb index 894e7d97..701bca62 100644 --- a/spec/support/acceptance/shared_examples.rb +++ b/spec/support/acceptance/shared_examples.rb @@ -9,3 +9,21 @@ apply_manifest(pp, catch_changes: true) end end + +shared_examples 'cleanup' do + context 'cleanup' do + let(:pp) do + " + class { 'nodejs': + nodejs_debug_package_ensure => absent, + nodejs_dev_package_ensure => absent, + nodejs_package_ensure => absent, + npm_package_ensure => absent, + repo_ensure => absent, + } + " + end + + it_behaves_like 'an idempotent resource' + end +end From c2268230f205080eab68983016263faa558d72cf Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 19 Jan 2022 08:48:35 +0100 Subject: [PATCH 04/31] enforce UTF-8 locales for CentOS workaround --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d08d05e8..3a77f90b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,6 +77,8 @@ jobs: - name: Run tests run: bundle exec rake beaker env: + LANG: en_US + LC_ALL: en_US.UTF-8 BEAKER_PUPPET_COLLECTION: ${{ matrix.puppet.collection }} BEAKER_setfile: ${{ matrix.setfile.value }} From ec4797123ddf891728e1cdb6151edf9d5fdf6102 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 30 May 2022 12:24:35 +0200 Subject: [PATCH 05/31] modulesync 5.3.0 --- .github/CONTRIBUTING.md | 7 +++---- .github/workflows/release.yml | 32 ++++++++++---------------------- .msync.yml | 2 +- Dockerfile | 2 +- Gemfile | 6 +++--- spec/setup_acceptance_helper.pp | 6 ++++++ 6 files changed, 24 insertions(+), 31 deletions(-) create mode 100644 spec/setup_acceptance_helper.pp diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 048d2b55..8b466cfb 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -124,7 +124,7 @@ If you have Ruby 2.x or want a specific version of Puppet, you must set an environment variable such as: ```sh -export PUPPET_VERSION="~> 5.5.6" +export PUPPET_GEM_VERSION="~> 6.1.0" ``` You can install all needed gems for spec tests into the modules directory by @@ -232,17 +232,16 @@ simple tests against it after applying the module. You can run this with: ```sh -BEAKER_setfile=debian10-x64 bundle exec rake beaker +BEAKER_setfile=debian11-64 bundle exec rake beaker ``` You can replace the string `debian10` with any common operating system. The following strings are known to work: -* ubuntu1604 * ubuntu1804 * ubuntu2004 -* debian9 * debian10 +* debian11 * centos7 * centos8 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 664ba694..15f17213 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,26 +9,14 @@ on: tags: - '*' -env: - BUNDLE_WITHOUT: development:test:system_tests - jobs: - deploy: - name: 'deploy to forge' - runs-on: ubuntu-latest - if: github.repository_owner == 'voxpupuli' - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '2.7' - bundler-cache: true - - name: Build and Deploy - env: - # Configure secrets here: - # https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets - BLACKSMITH_FORGE_USERNAME: '${{ secrets.PUPPET_FORGE_USERNAME }}' - BLACKSMITH_FORGE_API_KEY: '${{ secrets.PUPPET_FORGE_API_KEY }}' - run: bundle exec rake module:push + release: + name: Release + uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v1 + with: + allowed_owner: 'voxpupuli' + secrets: + # Configure secrets here: + # https://docs.github.com/en/actions/security-guides/encrypted-secrets + username: ${{ secrets.PUPPET_FORGE_USERNAME }} + api_key: ${{ secrets.PUPPET_FORGE_API_KEY }} diff --git a/.msync.yml b/.msync.yml index a83abd9b..02353859 100644 --- a/.msync.yml +++ b/.msync.yml @@ -2,4 +2,4 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -modulesync_config_version: '5.1.0' +modulesync_config_version: '5.3.0' diff --git a/Dockerfile b/Dockerfile index e3cf307f..8dd82d63 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ WORKDIR /opt/puppet # https://github.com/puppetlabs/puppet/blob/06ad255754a38f22fb3a22c7c4f1e2ce453d01cb/lib/puppet/provider/service/runit.rb#L39 RUN mkdir -p /etc/sv -ARG PUPPET_VERSION="~> 6.0" +ARG PUPPET_GEM_VERSION="~> 6.0" ARG PARALLEL_TEST_PROCESSORS=4 # Cache gems diff --git a/Gemfile b/Gemfile index b6dcf456..07209b79 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,10 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -source ENV['GEM_SOURCE'] || "https://rubygems.org" +source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :test do - gem 'voxpupuli-test', '~> 5.0', :require => false + gem 'voxpupuli-test', '~> 5.4', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false gem 'puppet_metadata', '~> 1.0', :require => false @@ -28,7 +28,7 @@ end gem 'rake', :require => false gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test] -puppetversion = ENV['PUPPET_VERSION'] || '>= 6.0' +puppetversion = ENV['PUPPET_GEM_VERSION'] || '>= 6.0' gem 'puppet', puppetversion, :require => false, :groups => [:test] # vim: syntax=ruby diff --git a/spec/setup_acceptance_helper.pp b/spec/setup_acceptance_helper.pp new file mode 100644 index 00000000..79a1cadf --- /dev/null +++ b/spec/setup_acceptance_helper.pp @@ -0,0 +1,6 @@ +# Facter < 4 needs lsb-release for os.distro.codename +if versioncmp($facts['facterversion'], '4.0.0') < 0 and $facts['os']['family'] == 'Debian' { + package { 'lsb-release': + ensure => 'installed', + } +} From a924d0157778cedb050a65358b944cac7610a271 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 2 Oct 2022 16:05:04 +0200 Subject: [PATCH 06/31] modulesync 5.3.0 --- .github/workflows/ci.yml | 86 +++------------------------------------- Rakefile | 2 +- spec/spec_helper.rb | 2 + 3 files changed, 9 insertions(+), 81 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a77f90b..8a077911 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,86 +7,12 @@ name: CI on: pull_request concurrency: - group: ${{ github.head_ref }} + group: ${{ github.ref_name }} cancel-in-progress: true jobs: - setup_matrix: - name: 'Setup Test Matrix' - runs-on: ubuntu-latest - timeout-minutes: 40 - outputs: - puppet_unit_test_matrix: ${{ steps.get-outputs.outputs.puppet_unit_test_matrix }} - github_action_test_matrix: ${{ steps.get-outputs.outputs.github_action_test_matrix }} - env: - BUNDLE_WITHOUT: development:system_tests:release - steps: - - uses: actions/checkout@v2 - - name: Setup ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '3.0' - bundler-cache: true - - name: Run static validations - run: bundle exec rake validate lint check - - name: Run rake rubocop - run: bundle exec rake rubocop - - name: Setup Test Matrix - id: get-outputs - run: bundle exec metadata2gha --use-fqdn --pidfile-workaround false - - unit: - needs: setup_matrix - runs-on: ubuntu-latest - timeout-minutes: 40 - strategy: - fail-fast: false - matrix: - include: ${{fromJson(needs.setup_matrix.outputs.puppet_unit_test_matrix)}} - env: - BUNDLE_WITHOUT: development:system_tests:release - PUPPET_VERSION: "~> ${{ matrix.puppet }}.0" - name: Puppet ${{ matrix.puppet }} (Ruby ${{ matrix.ruby }}) - steps: - - uses: actions/checkout@v2 - - name: Setup ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby }} - bundler-cache: true - - name: Run tests - run: bundle exec rake parallel_spec - - acceptance: - needs: setup_matrix - runs-on: ubuntu-latest - env: - BUNDLE_WITHOUT: development:test:release - strategy: - fail-fast: false - matrix: - include: ${{fromJson(needs.setup_matrix.outputs.github_action_test_matrix)}} - name: ${{ matrix.puppet.name }} - ${{ matrix.setfile.name }} - steps: - - uses: actions/checkout@v2 - - name: Setup ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '3.0' - bundler-cache: true - - name: Run tests - run: bundle exec rake beaker - env: - LANG: en_US - LC_ALL: en_US.UTF-8 - BEAKER_PUPPET_COLLECTION: ${{ matrix.puppet.collection }} - BEAKER_setfile: ${{ matrix.setfile.value }} - - tests: - needs: - - unit - - acceptance - runs-on: ubuntu-latest - name: Test suite - steps: - - run: echo Test suite completed + puppet: + name: Puppet + uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v1 + with: + pidfile_workaround: 'false' diff --git a/Rakefile b/Rakefile index f92f0516..c8f91524 100644 --- a/Rakefile +++ b/Rakefile @@ -52,7 +52,7 @@ begin config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module." config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog} config.user = 'voxpupuli' - config.project = metadata.metadata['name'] + config.project = 'puppet-nodejs' end # Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 78e8b77e..a489d4f8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,6 +13,8 @@ require 'voxpupuli/test/spec_helper' +add_mocked_facts! + if File.exist?(File.join(__dir__, 'default_module_facts.yml')) facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml'))) facts&.each do |name, value| From d3146ed855d780bf5ac7e099709d9b01a40350da Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Tue, 20 Dec 2022 16:34:22 +0100 Subject: [PATCH 07/31] modulesync 5.4.0 --- .msync.yml | 2 +- Gemfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.msync.yml b/.msync.yml index 02353859..f3156d15 100644 --- a/.msync.yml +++ b/.msync.yml @@ -2,4 +2,4 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -modulesync_config_version: '5.3.0' +modulesync_config_version: '5.4.0' diff --git a/Gemfile b/Gemfile index 07209b79..b3827ba7 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ group :test do gem 'voxpupuli-test', '~> 5.4', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false - gem 'puppet_metadata', '~> 1.0', :require => false + gem 'puppet_metadata', '~> 2.0', :require => false end group :development do From d83bbcfcdc1b97a033acaf79504f6cd6bed6a8a3 Mon Sep 17 00:00:00 2001 From: Massimiliano Adamo Date: Sat, 15 Apr 2023 10:01:51 +0200 Subject: [PATCH 08/31] modulesync 5.5.0 --- .github/SECURITY.md | 3 --- .gitignore | 36 ++++++++++++------------- .msync.yml | 2 +- .pmtignore | 64 ++++++++++++++++++++++----------------------- Gemfile | 3 +-- Rakefile | 36 +++---------------------- 6 files changed, 56 insertions(+), 88 deletions(-) delete mode 100644 .github/SECURITY.md diff --git a/.github/SECURITY.md b/.github/SECURITY.md deleted file mode 100644 index cacadf22..00000000 --- a/.github/SECURITY.md +++ /dev/null @@ -1,3 +0,0 @@ -# Vox Pupuli Security Policy - -Our vulnerabilities reporting process is at https://voxpupuli.org/security/ diff --git a/.gitignore b/.gitignore index 9b95224c..84fd904c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,23 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -pkg/ -Gemfile.lock -Gemfile.local -vendor/ -.vendor/ -spec/fixtures/manifests/ -spec/fixtures/modules/ -.vagrant/ -.bundle/ -.ruby-version -coverage/ -log/ -.idea/ -.dependencies/ -.librarian/ -Puppetfile.lock +/pkg/ +/Gemfile.lock +/Gemfile.local +/vendor/ +/.vendor/ +/spec/fixtures/manifests/ +/spec/fixtures/modules/ +/.vagrant/ +/.bundle/ +/.ruby-version +/coverage/ +/log/ +/.idea/ +/.dependencies/ +/.librarian/ +/Puppetfile.lock *.iml .*.sw? -.yardoc/ -Guardfile +/.yardoc/ +/Guardfile diff --git a/.msync.yml b/.msync.yml index f3156d15..a4b00691 100644 --- a/.msync.yml +++ b/.msync.yml @@ -2,4 +2,4 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -modulesync_config_version: '5.4.0' +modulesync_config_version: '5.5.0' diff --git a/.pmtignore b/.pmtignore index 65f50514..58a04088 100644 --- a/.pmtignore +++ b/.pmtignore @@ -1,37 +1,37 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -docs/ -pkg/ -Gemfile -Gemfile.lock -Gemfile.local -vendor/ -.vendor/ -spec/ -Rakefile -.vagrant/ -.bundle/ -.ruby-version -coverage/ -log/ -.idea/ -.dependencies/ -.github/ -.librarian/ -Puppetfile.lock +/docs/ +/pkg/ +/Gemfile +/Gemfile.lock +/Gemfile.local +/vendor/ +/.vendor/ +/spec/ +/Rakefile +/.vagrant/ +/.bundle/ +/.ruby-version +/coverage/ +/log/ +/.idea/ +/.dependencies/ +/.github/ +/.librarian/ +/Puppetfile.lock *.iml -.editorconfig -.fixtures.yml -.gitignore -.msync.yml -.overcommit.yml -.pmtignore -.rspec -.rspec_parallel -.rubocop.yml -.sync.yml +/.editorconfig +/.fixtures.yml +/.gitignore +/.msync.yml +/.overcommit.yml +/.pmtignore +/.rspec +/.rspec_parallel +/.rubocop.yml +/.sync.yml .*.sw? -.yardoc/ -.yardopts -Dockerfile +/.yardoc/ +/.yardopts +/Dockerfile diff --git a/Gemfile b/Gemfile index b3827ba7..15313c38 100644 --- a/Gemfile +++ b/Gemfile @@ -21,8 +21,7 @@ end group :release do gem 'github_changelog_generator', '>= 1.16.1', :require => false if RUBY_VERSION >= '2.5' - gem 'voxpupuli-release', '>= 1.2.0', :require => false - gem 'puppet-strings', '>= 2.2', :require => false + gem 'voxpupuli-release', '~> 2.0', :require => false end gem 'rake', :require => false diff --git a/Rakefile b/Rakefile index c8f91524..862d8697 100644 --- a/Rakefile +++ b/Rakefile @@ -24,6 +24,10 @@ end begin require 'voxpupuli/release/rake_tasks' rescue LoadError + # voxpupuli-release not present +else + GCGConfig.user = 'voxpupuli' + GCGConfig.project = 'puppet-nodejs' end desc "Run main 'test' task and report merged results to coveralls" @@ -37,36 +41,4 @@ task test_with_coveralls: [:test] do end end -desc 'Generate REFERENCE.md' -task :reference, [:debug, :backtrace] do |t, args| - patterns = '' - Rake::Task['strings:generate:reference'].invoke(patterns, args[:debug], args[:backtrace]) -end - -begin - require 'github_changelog_generator/task' - require 'puppet_blacksmith' - GitHubChangelogGenerator::RakeTask.new :changelog do |config| - metadata = Blacksmith::Modulefile.new - config.future_release = "v#{metadata.version}" if metadata.version =~ /^\d+\.\d+.\d+$/ - config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module." - config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog} - config.user = 'voxpupuli' - config.project = 'puppet-nodejs' - end - - # Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715 - require 'rbconfig' - if RbConfig::CONFIG['host_os'] =~ /linux/ - task :changelog do - puts 'Fixing line endings...' - changelog_file = File.join(__dir__, 'CHANGELOG.md') - changelog_txt = File.read(changelog_file) - new_contents = changelog_txt.gsub(%r{\r\n}, "\n") - File.open(changelog_file, "w") {|file| file.puts new_contents } - end - end - -rescue LoadError -end # vim: syntax=ruby From caf6e0b415276417325edfafc6a56ef6a49a00a1 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 12 May 2023 12:57:04 +0200 Subject: [PATCH 09/31] modulesync 6.0.0 --- .msync.yml | 2 +- Gemfile | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.msync.yml b/.msync.yml index a4b00691..b929160c 100644 --- a/.msync.yml +++ b/.msync.yml @@ -2,4 +2,4 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -modulesync_config_version: '5.5.0' +modulesync_config_version: '6.0.0' diff --git a/Gemfile b/Gemfile index 15313c38..98a04cfb 100644 --- a/Gemfile +++ b/Gemfile @@ -4,10 +4,10 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :test do - gem 'voxpupuli-test', '~> 5.4', :require => false + gem 'voxpupuli-test', '~> 6.0', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false - gem 'puppet_metadata', '~> 2.0', :require => false + gem 'puppet_metadata', '~> 3.0', :require => false end group :development do @@ -16,18 +16,19 @@ group :development do end group :system_tests do - gem 'voxpupuli-acceptance', '~> 1.0', :require => false + gem 'voxpupuli-acceptance', '~> 2.0', :require => false end group :release do - gem 'github_changelog_generator', '>= 1.16.1', :require => false if RUBY_VERSION >= '2.5' - gem 'voxpupuli-release', '~> 2.0', :require => false + gem 'github_changelog_generator', '>= 1.16.1', :require => false + gem 'voxpupuli-release', '~> 3.0', :require => false + gem 'faraday-retry', '~> 2.1', :require => false end gem 'rake', :require => false gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test] -puppetversion = ENV['PUPPET_GEM_VERSION'] || '>= 6.0' +puppetversion = ENV['PUPPET_GEM_VERSION'] || '~> 7.24' gem 'puppet', puppetversion, :require => false, :groups => [:test] # vim: syntax=ruby From 458ad66891a813f01ef04943f5ec338dbce80972 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 17 Aug 2023 16:41:37 +0200 Subject: [PATCH 10/31] modulesync 7.0.0 --- .github/CONTRIBUTING.md | 11 +++++++---- .msync.yml | 2 +- Gemfile | 2 +- spec/spec_helper.rb | 1 + spec/spec_helper_acceptance.rb | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 8b466cfb..6aaa603f 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -232,18 +232,21 @@ simple tests against it after applying the module. You can run this with: ```sh -BEAKER_setfile=debian11-64 bundle exec rake beaker +BEAKER_PUPPET_COLLECTION=puppet7 BEAKER_setfile=debian11-64 bundle exec rake beaker ``` -You can replace the string `debian10` with any common operating system. +You can replace the string `debian11` with any common operating system. The following strings are known to work: -* ubuntu1804 * ubuntu2004 -* debian10 +* ubuntu2204 * debian11 * centos7 * centos8 +* centos9 +* almalinux8 +* almalinux9 +* fedora36 For more information and tips & tricks, see [voxpupuli-acceptance's documentation](https://github.com/voxpupuli/voxpupuli-acceptance#running-tests). diff --git a/.msync.yml b/.msync.yml index b929160c..dd3e9572 100644 --- a/.msync.yml +++ b/.msync.yml @@ -2,4 +2,4 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -modulesync_config_version: '6.0.0' +modulesync_config_version: '7.0.0' diff --git a/Gemfile b/Gemfile index 98a04cfb..db21d3b5 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :test do - gem 'voxpupuli-test', '~> 6.0', :require => false + gem 'voxpupuli-test', '~> 7.0', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false gem 'puppet_metadata', '~> 3.0', :require => false diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a489d4f8..3b8712f9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -21,3 +21,4 @@ add_custom_fact name.to_sym, value end end +Dir['./spec/support/spec/**/*.rb'].sort.each { |f| require f } diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index d3a6e23c..2681792e 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -5,6 +5,6 @@ require 'voxpupuli/acceptance/spec_helper_acceptance' -configure_beaker +configure_beaker(modules: :metadata) Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f } From 52006cd66e650c30aca7e5adb78589c6c10df954 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 18 Aug 2023 08:26:59 +0200 Subject: [PATCH 11/31] rubocop: autofix --- spec/classes/nodejs_spec.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/classes/nodejs_spec.rb b/spec/classes/nodejs_spec.rb index a020e0fb..dc14d43a 100644 --- a/spec/classes/nodejs_spec.rb +++ b/spec/classes/nodejs_spec.rb @@ -320,17 +320,17 @@ if operatingsystemmajrelease == '7' operatingsystem = 'CentOS' dist_type = 'el' - repo_baseurl = "https://rpm.nodesource.com/pub_12.x/#{dist_type}/#{operatingsystemmajrelease}/\$basearch" + 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" + 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_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" + repo_descr = "Node.js Packages for Fedora Core #{operatingsystemmajrelease} - $basearch" + repo_source_descr = "Node.js for Fedora Core #{operatingsystemmajrelease} - $basearch - Source" end context "when run on #{operatingsystem} release #{operatingsystemrelease}" do @@ -403,8 +403,8 @@ default_params.merge!(repo_url_suffix: '5.x') end - it "the yum nodesource repo resource should contain baseurl = https://rpm.nodesource.com/pub_5.x/#{dist_type}/#{operatingsystemmajrelease}/\$basearch" do - is_expected.to contain_yumrepo('nodesource').with('baseurl' => "https://rpm.nodesource.com/pub_5.x/#{dist_type}/#{operatingsystemmajrelease}/\$basearch") + it "the yum nodesource repo resource should contain baseurl = https://rpm.nodesource.com/pub_5.x/#{dist_type}/#{operatingsystemmajrelease}/$basearch" do + is_expected.to contain_yumrepo('nodesource').with('baseurl' => "https://rpm.nodesource.com/pub_5.x/#{dist_type}/#{operatingsystemmajrelease}/$basearch") end end From 153c311d30435dcf86ba769fb880bec16d64a850 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Mon, 4 Oct 2021 16:39:21 -1000 Subject: [PATCH 12/31] Drop support for Debian 9, Ubuntu 16.04 and 18.04, FreeBSD 11 (EOL) --- metadata.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/metadata.json b/metadata.json index 66c1fca1..67f12fff 100644 --- a/metadata.json +++ b/metadata.json @@ -39,7 +39,6 @@ { "operatingsystem": "Debian", "operatingsystemrelease": [ - "9", "10", "11" ] @@ -47,15 +46,12 @@ { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ - "16.04", - "18.04", "20.04" ] }, { "operatingsystem": "FreeBSD", "operatingsystemrelease": [ - "11", "12", "13" ] From 581bb57f449d2edf643827a3045f594e252c9d2a Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 3 Jul 2023 09:19:22 +0200 Subject: [PATCH 13/31] Add Puppet 8 support --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 67f12fff..33364252 100644 --- a/metadata.json +++ b/metadata.json @@ -60,7 +60,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 7.0.0 < 8.0.0" + "version_requirement": ">= 7.0.0 < 9.0.0" } ], "dependencies": [ From 74cd95bcbef7b7a52b959fc871f1ce899a6d6a1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix-Antoine=20Fortin?= Date: Fri, 12 May 2023 10:11:28 -0400 Subject: [PATCH 14/31] Add support for RHEL 9 based distros --- README.md | 2 +- manifests/params.pp | 2 +- manifests/repo/nodesource.pp | 2 +- manifests/repo/nodesource/yum.pp | 4 ++-- metadata.json | 12 ++++++++---- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index c449ecf2..8f8bab80 100644 --- a/README.md +++ b/README.md @@ -519,7 +519,7 @@ this with the package_provider parameter to use an alternative This module has received limited testing on: -* CentOS/RHEL 7/8 +* CentOS/RHEL 7/8/9 * Debian 9/10 * Ubuntu 16.04/18.04/20.04 diff --git a/manifests/params.pp b/manifests/params.pp index 163c7313..65efb77e 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -78,7 +78,7 @@ $package_provider = undef } 'RedHat': { - if $facts['os']['release']['major'] =~ /^[78]$/ { + if $facts['os']['release']['major'] =~ /^[789]$/ { $manage_package_repo = true $nodejs_debug_package_name = 'nodejs-debuginfo' $nodejs_dev_package_name = 'nodejs-devel' diff --git a/manifests/repo/nodesource.pp b/manifests/repo/nodesource.pp index 564766b8..ac8a52cf 100644 --- a/manifests/repo/nodesource.pp +++ b/manifests/repo/nodesource.pp @@ -12,7 +12,7 @@ case $facts['os']['family'] { 'RedHat': { - if $facts['os']['release']['major'] =~ /^[78]$/ { + if $facts['os']['release']['major'] =~ /^[789]$/ { $dist_version = $facts['os']['release']['major'] $name_string = "Enterprise Linux ${dist_version}" } diff --git a/manifests/repo/nodesource/yum.pp b/manifests/repo/nodesource/yum.pp index f8ad9efb..d45f7b13 100644 --- a/manifests/repo/nodesource/yum.pp +++ b/manifests/repo/nodesource/yum.pp @@ -22,7 +22,7 @@ } if ($ensure == 'present') { - if $facts['os']['release']['major'] == '8' { + if versioncmp($facts['os']['release']['major'], '8') >= 0 { file { 'dnf_module': ensure => file, path => '/etc/dnf/modules.d/nodejs.module', @@ -79,7 +79,7 @@ ensure => 'absent', } - if $facts['os']['release']['major'] == '8' { + if versioncmp($facts['os']['release']['major'], '8') >= 0 { file { 'dnf_module': ensure => absent, path => '/etc/dnf/modules.d/nodejs.module', diff --git a/metadata.json b/metadata.json index 33364252..421bd726 100644 --- a/metadata.json +++ b/metadata.json @@ -12,28 +12,32 @@ "operatingsystem": "RedHat", "operatingsystemrelease": [ "7", - "8" + "8", + "9" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "7", - "8" + "8", + "9" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "7", - "8" + "8", + "9" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "7", - "8" + "8", + "9" ] }, { From 8d007d0ac2e05885990651421a511c931676a1e0 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 1 Jul 2023 15:49:19 +0200 Subject: [PATCH 15/31] puppetlabs/stdlib: Allow 9.x --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 421bd726..acb3c598 100644 --- a/metadata.json +++ b/metadata.json @@ -70,7 +70,7 @@ "dependencies": [ { "name": "puppetlabs/stdlib", - "version_requirement": ">= 4.25.0 < 9.0.0" + "version_requirement": ">= 4.25.0 < 10.0.0" } ] } From 9d6742a8be983b2116b6c66f48797be1771903e1 Mon Sep 17 00:00:00 2001 From: Trevor Rea Date: Wed, 21 Jun 2023 15:10:33 +0100 Subject: [PATCH 16/31] Replace PSON parsing with JSON parsing as PSON is deprecated in Puppet 8 --- lib/puppet/provider/package/npm.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/puppet/provider/package/npm.rb b/lib/puppet/provider/package/npm.rb index 8d33a887..d34e5a49 100644 --- a/lib/puppet/provider/package/npm.rb +++ b/lib/puppet/provider/package/npm.rb @@ -20,9 +20,9 @@ def self.npmlist Puppet.debug("Warning: npm list --json exited with code #{output.exitstatus}") if output.exitstatus != 0 begin # ignore any npm output lines to be a bit more robust - output = PSON.parse(output.lines.grep(%r{^((?!^npm).*)$}).join("\n"), max_nesting: 100) + output = JSON.parse(output.lines.grep(%r{^((?!^npm).*)$}).join("\n"), max_nesting: 100) @npmlist = output['dependencies'] || {} - rescue PSON::ParserError => e + rescue JSON::ParserError => e Puppet.debug("Error: npm list --json command error #{e.message}") @npmlist = {} end From 683e4ec79dd9b8b1e694e24a685d1d363643b4b5 Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Sat, 16 Sep 2023 17:03:36 -0700 Subject: [PATCH 17/31] spec/setup_acceptance_node.pp: remove Duplicate of spec/setup_acceptance_helper.pp. --- spec/setup_acceptance_node.pp | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 spec/setup_acceptance_node.pp diff --git a/spec/setup_acceptance_node.pp b/spec/setup_acceptance_node.pp deleted file mode 100644 index 79a1cadf..00000000 --- a/spec/setup_acceptance_node.pp +++ /dev/null @@ -1,6 +0,0 @@ -# Facter < 4 needs lsb-release for os.distro.codename -if versioncmp($facts['facterversion'], '4.0.0') < 0 and $facts['os']['family'] == 'Debian' { - package { 'lsb-release': - ensure => 'installed', - } -} From a7ba1a8a2228d2a2bae53ea97dc4791840b96ef9 Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Sun, 17 Sep 2023 13:16:27 -0700 Subject: [PATCH 18/31] shared examples: remove 'an idempotent resource' Use the shared example provided by https://github.com/voxpupuli/voxpupuli-acceptance/blob/730a129a9b5a9fc660f016e74e67dc3be9b4968a/lib/voxpupuli/acceptance/examples.rb instead. This also removes test code for EOL Debian-family. --- spec/acceptance/class_spec.rb | 87 ++++++++++++---------- spec/support/acceptance/shared_examples.rb | 34 +++------ 2 files changed, 61 insertions(+), 60 deletions(-) diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index beeafc6b..f100db4a 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -13,9 +13,9 @@ end context 'default parameters' do - let(:pp) { "class { 'nodejs': }" } - - it_behaves_like 'an idempotent resource' + it_behaves_like 'an idempotent resource' do + let(:manifest) { "class { 'nodejs': }" } + end if %w[RedHat Debian].include? fact('os.family') describe package('nodejs') do @@ -30,11 +30,17 @@ end context 'repo_class => epel', if: ((fact('os.family') == 'RedHat') && (fact('os.release.major') != '8')) do - let(:pp) { "class { 'nodejs': repo_class => '::epel' }" } - include_examples 'cleanup' - it_behaves_like 'an idempotent resource' + it_behaves_like 'an idempotent resource' do + let(:manifest) do + <<-PUPPET + class { 'nodejs': + repo_class => '::epel', + } + PUPPET + end + end describe package('nodejs') do it { is_expected.to be_installed } @@ -47,12 +53,19 @@ end context 'set global_config_entry secret', if: fact('os.family') == 'RedHat' do - let :pp do - "class { 'nodejs': }; nodejs::npm::global_config_entry { '//path.to.registry/:_secret': ensure => present, value => 'cGFzc3dvcmQ=', require => Package[nodejs],}" + it_behaves_like 'an idempotent resource' do + let(:manifest) do + <<-PUPPET + class { 'nodejs': } + nodejs::npm::global_config_entry { '//path.to.registry/:_secret': + ensure => present, + value => 'cGFzc3dvcmQ=', + require => Package[nodejs], + } + PUPPET + end end - it_behaves_like 'an idempotent resource' - describe package('nodejs') do it { is_expected.to be_installed } end @@ -66,12 +79,19 @@ end context 'set global_config_entry secret unquoted', if: fact('os.family') == 'RedHat' do - let :pp do - "class { 'nodejs': }; nodejs::npm::global_config_entry { '//path.to.registry/:_secret': ensure => present, value => 'cGFzc3dvcmQ', require => Package[nodejs],}" + it_behaves_like 'an idempotent resource' do + let(:manifest) do + <<-PUPPET + class { 'nodejs': } + nodejs::npm::global_config_entry { '//path.to.registry/:_secret': + ensure => present, + value => 'cGFzc3dvcmQ', + require => Package[nodejs], + } + PUPPET + end end - it_behaves_like 'an idempotent resource' - describe package('nodejs') do it { is_expected.to be_installed } end @@ -86,34 +106,25 @@ end context 'native Debian packages' do - let(:pp) do - " - class { 'nodejs': - manage_package_repo => false, - nodejs_dev_package_ensure => present, - npm_package_ensure => present, - } - " - end - include_examples 'cleanup' - it_behaves_like 'an idempotent resource' - - expected_packages = [] - - if fact('os.family') == 'Debian' - if %w[9 16.04 18.04].include? fact('os.release.major') - expected_packages << 'nodejs-dev' - - expected_packages << 'npm' if %w[16.04 18.04].include? fact('os.release.major') - else - expected_packages << 'libnode-dev' - - expected_packages << 'npm' + it_behaves_like 'an idempotent resource' do + let(:manifest) do + <<-PUPPET + class { 'nodejs': + manage_package_repo => false, + nodejs_dev_package_ensure => present, + npm_package_ensure => present, + } + PUPPET end + end - expected_packages.each do |pkg| + if fact('os.family') == 'Debian' + %w[ + libnode-dev + npm + ].each do |pkg| describe package(pkg) do it { is_expected.to be_installed } end diff --git a/spec/support/acceptance/shared_examples.rb b/spec/support/acceptance/shared_examples.rb index 701bca62..e42eed16 100644 --- a/spec/support/acceptance/shared_examples.rb +++ b/spec/support/acceptance/shared_examples.rb @@ -1,29 +1,19 @@ # frozen_string_literal: true -shared_examples 'an idempotent resource' do - it 'applies with no errors' do - apply_manifest(pp, catch_failures: true) - end - - it 'applies a second time without changes' do - apply_manifest(pp, catch_changes: true) - end -end - shared_examples 'cleanup' do context 'cleanup' do - let(:pp) do - " - class { 'nodejs': - nodejs_debug_package_ensure => absent, - nodejs_dev_package_ensure => absent, - nodejs_package_ensure => absent, - npm_package_ensure => absent, - repo_ensure => absent, - } - " + it_behaves_like 'an idempotent resource' do + let(:manifest) do + <<-PUPPET + class { 'nodejs': + nodejs_debug_package_ensure => absent, + nodejs_dev_package_ensure => absent, + nodejs_package_ensure => absent, + npm_package_ensure => absent, + repo_ensure => absent, + } + PUPPET + end end - - it_behaves_like 'an idempotent resource' end end From df346f4b81f977cb78be4597dfc00872bfbed5a3 Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Sun, 17 Sep 2023 14:04:40 -0700 Subject: [PATCH 19/31] README: formatting fixes --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8f8bab80..d6b39896 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![Puppet Forge - endorsement](https://img.shields.io/puppetforge/e/puppet/nodejs.svg)](https://forge.puppetlabs.com/puppet/nodejs) [![Puppet Forge - scores](https://img.shields.io/puppetforge/f/puppet/nodejs.svg)](https://forge.puppetlabs.com/puppet/nodejs) -#### Table of Contents +## Table of Contents 1. [Overview](#overview) 1. [Setup - The basics of getting started with nodejs](#setup) @@ -100,9 +100,9 @@ For example: ```puppet # Upgrade from nodejs 5.x to 6.x class { 'nodejs': - repo_url_suffix => '6.x', - nodejs_package_ensure => '6.12.2', - } + repo_url_suffix => '6.x', + nodejs_package_ensure => '6.12.2', +} ``` ### Forcing the installation of NodeSource packages over native packages From 1c7ba2329e2d57faeff3312fa27e1b4a3fabfe3f Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Sun, 17 Sep 2023 14:05:18 -0700 Subject: [PATCH 20/31] change default package ensure value to `installed` For compatibility with https://github.com/puppetlabs/puppetlabs-stdlib/pull/1196. --- README.md | 14 +-- manifests/params.pp | 10 +- spec/acceptance/class_spec.rb | 4 +- spec/classes/nodejs_spec.rb | 166 +++++++++++++++++----------------- 4 files changed, 97 insertions(+), 97 deletions(-) diff --git a/README.md b/README.md index d6b39896..9f77070d 100644 --- a/README.md +++ b/README.md @@ -74,8 +74,8 @@ Install Node.js and npm using the native packages provided by the distribution: ```puppet class { '::nodejs': manage_package_repo => false, - nodejs_dev_package_ensure => 'present', - npm_package_ensure => 'present', + nodejs_dev_package_ensure => installed, + npm_package_ensure => installed, } ``` @@ -83,15 +83,15 @@ Install Node.js and npm using the packages from EPEL: ```puppet class { '::nodejs': - nodejs_dev_package_ensure => 'present', - npm_package_ensure => 'present', + nodejs_dev_package_ensure => installed, + npm_package_ensure => installed, repo_class => '::epel', } ``` ### Upgrades -The parameter `nodejs_package_ensure` defaults to `present`. Changing the +The parameter `nodejs_package_ensure` defaults to `installed`. Changing the `repo_url_suffix` will not result in a new version being installed. Changing the `nodejs_package_ensure` parameter should provide the desired effect. @@ -132,7 +132,7 @@ For example: ```puppet package { 'express': - ensure => 'present', + ensure => installed, provider => 'npm', } @@ -161,7 +161,7 @@ except version ranges. The title simply must be a unique, arbitrary value. the package parameter needs to be match the name of the package in the npm registry. * Package versions are specified with the ensure parameter, which defaults to - `present`. + `installed`. * Install options and uninstall options are also supported, and need to be specified as an array. * The user parameter is provided should you wish to run npm install or npm rm diff --git a/manifests/params.pp b/manifests/params.pp index 65efb77e..1ee3b711 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -2,7 +2,7 @@ $npmrc_auth = undef $npmrc_config = undef $nodejs_debug_package_ensure = 'absent' - $nodejs_package_ensure = 'present' + $nodejs_package_ensure = 'installed' $repo_enable_src = false $repo_ensure = 'present' $repo_pin = undef @@ -122,7 +122,7 @@ $nodejs_dev_package_name = 'nodejs-devel' $nodejs_dev_package_ensure = 'absent' $nodejs_package_name = 'nodejs' - $npm_package_ensure = 'present' + $npm_package_ensure = 'installed' $npm_package_name = 'npm' $npm_path = '/usr/bin/npm' $repo_class = undef @@ -134,7 +134,7 @@ $nodejs_dev_package_name = undef $nodejs_dev_package_ensure = 'absent' $nodejs_package_name = 'nodejs' - $npm_package_ensure = 'present' + $npm_package_ensure = 'installed' $npm_package_name = 'npm' $npm_path = '/usr/bin/npm' $repo_class = undef @@ -146,7 +146,7 @@ $nodejs_dev_package_name = 'www/node-devel' $nodejs_dev_package_ensure = 'absent' $nodejs_package_name = 'www/node' - $npm_package_ensure = 'present' + $npm_package_ensure = 'installed' $npm_package_name = 'www/npm' $npm_path = '/usr/local/bin/npm' $repo_class = undef @@ -170,7 +170,7 @@ $nodejs_dev_package_name = 'nodejs-devel' $nodejs_dev_package_ensure = 'absent' $nodejs_package_name = 'nodejs' - $npm_package_ensure = 'present' + $npm_package_ensure = 'installed' $npm_package_name = 'npm' $npm_path = '/opt/local/bin/npm' $repo_class = undef diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index f100db4a..5473251e 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -113,8 +113,8 @@ class { 'nodejs': } <<-PUPPET class { 'nodejs': manage_package_repo => false, - nodejs_dev_package_ensure => present, - npm_package_ensure => present, + nodejs_dev_package_ensure => installed, + npm_package_ensure => installed, } PUPPET end diff --git a/spec/classes/nodejs_spec.rb b/spec/classes/nodejs_spec.rb index dc14d43a..ea99ac7b 100644 --- a/spec/classes/nodejs_spec.rb +++ b/spec/classes/nodejs_spec.rb @@ -185,15 +185,15 @@ end # nodejs_debug_package_ensure - context 'with nodejs_debug_package_ensure set to present' do + context 'with nodejs_debug_package_ensure set to installed' do let :params do { - nodejs_debug_package_ensure: 'present' + nodejs_debug_package_ensure: 'installed' } end it 'the nodejs package with debugging symbols should be installed' do - is_expected.to contain_package('nodejs-dbg').with('ensure' => 'present') + is_expected.to contain_package('nodejs-dbg').with('ensure' => 'installed') end end @@ -210,15 +210,15 @@ end # nodejs_dev_package_ensure - context 'with nodejs_dev_package_ensure set to present' do + context 'with nodejs_dev_package_ensure set to installed' do let :params do { - nodejs_dev_package_ensure: 'present' + nodejs_dev_package_ensure: 'installed' } end it 'the nodejs development package should be installed' do - is_expected.to contain_package(native_debian_devel_package).with('ensure' => 'present') + is_expected.to contain_package(native_debian_devel_package).with('ensure' => 'installed') end end @@ -235,15 +235,15 @@ end # nodejs_package_ensure - context 'with nodejs_package_ensure set to present' do + context 'with nodejs_package_ensure set to installed' do let :params do { - nodejs_package_ensure: 'present' + nodejs_package_ensure: 'installed' } end - it 'the nodejs package should be present' do - is_expected.to contain_package('nodejs').with('ensure' => 'present') + it 'the nodejs package should be installed' do + is_expected.to contain_package('nodejs').with('ensure' => 'installed') end end @@ -260,10 +260,10 @@ end # npm_package_ensure - context 'with npm_package_ensure set to present' do + context 'with npm_package_ensure set to installed' do let :params do { - npm_package_ensure: 'present' + npm_package_ensure: 'installed' } end @@ -273,8 +273,8 @@ is_expected.not_to contain_package('npm') end else - it 'the npm package should be present' do - is_expected.to contain_package('npm').with('ensure' => 'present') + it 'the npm package should be installed' do + is_expected.to contain_package('npm').with('ensure' => 'installed') end end end @@ -550,15 +550,15 @@ end # nodejs_debug_package_ensure - context 'with nodejs_debug_package_ensure set to present' do + context 'with nodejs_debug_package_ensure set to installed' do let :params do { - nodejs_debug_package_ensure: 'present' + nodejs_debug_package_ensure: 'installed' } end it 'the nodejs package with debugging symbols should be installed' do - is_expected.to contain_package('nodejs-debuginfo').with('ensure' => 'present') + is_expected.to contain_package('nodejs-debuginfo').with('ensure' => 'installed') end end @@ -575,15 +575,15 @@ end # nodejs_dev_package_ensure - context 'with nodejs_dev_package_ensure set to present' do + context 'with nodejs_dev_package_ensure set to installed' do let :params do { - nodejs_dev_package_ensure: 'present' + nodejs_dev_package_ensure: 'installed' } end it 'the nodejs development package should be installed' do - is_expected.to contain_package('nodejs-devel').with('ensure' => 'present') + is_expected.to contain_package('nodejs-devel').with('ensure' => 'installed') end end @@ -600,15 +600,15 @@ end # nodejs_package_ensure - context 'with nodejs_package_ensure set to present' do + context 'with nodejs_package_ensure set to installed' do let :params do { - nodejs_package_ensure: 'present' + nodejs_package_ensure: 'installed' } end it 'the nodejs package should be present' do - is_expected.to contain_package('nodejs').with('ensure' => 'present') + is_expected.to contain_package('nodejs').with('ensure' => 'installed') end end @@ -625,15 +625,15 @@ end # npm_package_ensure - context 'with npm_package_ensure set to present' do + context 'with npm_package_ensure set to installed' do let :params do { - npm_package_ensure: 'present' + npm_package_ensure: 'installed' } end it 'the npm package should be present' do - is_expected.to contain_package('npm').with('ensure' => 'present') + is_expected.to contain_package('npm').with('ensure' => 'installed') end end @@ -662,15 +662,15 @@ end # nodejs_debug_package_ensure - context 'with nodejs_debug_package_ensure set to present' do + context 'with nodejs_debug_package_ensure set to installed' do let :params do { - nodejs_debug_package_ensure: 'present' + nodejs_debug_package_ensure: 'installed' } end it 'the nodejs package with debugging symbols should be installed' do - is_expected.to contain_package('nodejs-debuginfo').with('ensure' => 'present') + is_expected.to contain_package('nodejs-debuginfo').with('ensure' => 'installed') end end @@ -687,15 +687,15 @@ end # nodejs_dev_package_ensure - context 'with nodejs_dev_package_ensure set to present' do + context 'with nodejs_dev_package_ensure set to installed' do let :params do { - nodejs_dev_package_ensure: 'present' + nodejs_dev_package_ensure: 'installed' } end it 'the nodejs development package should be installed' do - is_expected.to contain_package('nodejs-devel').with('ensure' => 'present') + is_expected.to contain_package('nodejs-devel').with('ensure' => 'installed') end end @@ -738,15 +738,15 @@ end # nodejs_package_ensure - context 'with nodejs_package_ensure set to present' do + context 'with nodejs_package_ensure set to installed' do let :params do { - nodejs_package_ensure: 'present' + nodejs_package_ensure: 'installed' } end it 'the nodejs package should be present' do - is_expected.to contain_package('nodejs').with('ensure' => 'present') + is_expected.to contain_package('nodejs').with('ensure' => 'installed') end end @@ -763,15 +763,15 @@ end # npm_package_ensure - context 'with npm_package_ensure set to present' do + context 'with npm_package_ensure set to installed' do let :params do { - npm_package_ensure: 'present' + npm_package_ensure: 'installed' } end it 'the npm package should be present' do - is_expected.to contain_package('npm').with('ensure' => 'present') + is_expected.to contain_package('npm').with('ensure' => 'installed') end end @@ -824,15 +824,15 @@ end # nodejs_package_ensure - context 'with nodejs_package_ensure set to present' do + context 'with nodejs_package_ensure set to installed' do let :params do { - nodejs_package_ensure: 'present' + nodejs_package_ensure: 'installed' } end it 'the nodejs package should be present' do - is_expected.to contain_package('nodejs').with('ensure' => 'present') + is_expected.to contain_package('nodejs').with('ensure' => 'installed') end end @@ -886,15 +886,15 @@ end # nodejs_dev_package_ensure - context 'with nodejs_dev_package_ensure set to present' do + context 'with nodejs_dev_package_ensure set to installed' do let :params do { - nodejs_dev_package_ensure: 'present' + nodejs_dev_package_ensure: 'installed' } end it 'the nodejs development package should be installed' do - is_expected.to contain_package('www/node-devel').with('ensure' => 'present') + is_expected.to contain_package('www/node-devel').with('ensure' => 'installed') end end @@ -911,15 +911,15 @@ end # nodejs_package_ensure - context 'with nodejs_package_ensure set to present' do + context 'with nodejs_package_ensure set to installed' do let :params do { - nodejs_package_ensure: 'present' + nodejs_package_ensure: 'installed' } end it 'the nodejs package should be present' do - is_expected.to contain_package('www/node').with('ensure' => 'present') + is_expected.to contain_package('www/node').with('ensure' => 'installed') end end @@ -936,15 +936,15 @@ end # npm_package_ensure - context 'with npm_package_ensure set to present' do + context 'with npm_package_ensure set to installed' do let :params do { - npm_package_ensure: 'present' + npm_package_ensure: 'installed' } end it 'the npm package should be present' do - is_expected.to contain_package('www/npm').with('ensure' => 'present') + is_expected.to contain_package('www/npm').with('ensure' => 'installed') end end @@ -997,15 +997,15 @@ end # nodejs_package_ensure - context 'with nodejs_package_ensure set to present' do + context 'with nodejs_package_ensure set to installed' do let :params do { - nodejs_package_ensure: 'present' + nodejs_package_ensure: 'installed' } end it 'the nodejs package should be present' do - is_expected.to contain_package('node').with('ensure' => 'present') + is_expected.to contain_package('node').with('ensure' => 'installed') end end @@ -1059,15 +1059,15 @@ end # nodejs_dev_package_ensure - context 'with nodejs_dev_package_ensure set to present' do + context 'with nodejs_dev_package_ensure set to installed' do let :params do { - nodejs_dev_package_ensure: 'present' + nodejs_dev_package_ensure: 'installed' } end it 'the nodejs development package should be installed' do - is_expected.to contain_package('nodejs-devel').with('ensure' => 'present') + is_expected.to contain_package('nodejs-devel').with('ensure' => 'installed') end end @@ -1084,15 +1084,15 @@ end # nodejs_package_ensure - context 'with nodejs_package_ensure set to present' do + context 'with nodejs_package_ensure set to installed' do let :params do { - nodejs_package_ensure: 'present' + nodejs_package_ensure: 'installed' } end it 'the nodejs package should be present' do - is_expected.to contain_package('nodejs').with('ensure' => 'present') + is_expected.to contain_package('nodejs').with('ensure' => 'installed') end end @@ -1109,15 +1109,15 @@ end # npm_package_ensure - context 'with npm_package_ensure set to present' do + context 'with npm_package_ensure set to installed' do let :params do { - npm_package_ensure: 'present' + npm_package_ensure: 'installed' } end it 'the npm package should be present' do - is_expected.to contain_package('npm').with('ensure' => 'present') + is_expected.to contain_package('npm').with('ensure' => 'installed') end end @@ -1191,15 +1191,15 @@ end # nodejs_package_ensure - context 'with nodejs_package_ensure set to present' do + context 'with nodejs_package_ensure set to installed' do let :params do { - nodejs_package_ensure: 'present' + nodejs_package_ensure: 'installed' } end it 'the nodejs package should be present' do - is_expected.to contain_package('nodejs').with('ensure' => 'present') + is_expected.to contain_package('nodejs').with('ensure' => 'installed') end end @@ -1216,15 +1216,15 @@ end # npm_package_ensure - context 'with npm_package_ensure set to present' do + context 'with npm_package_ensure set to installed' do let :params do { - npm_package_ensure: 'present' + npm_package_ensure: 'installed' } end it 'the npm package should be present' do - is_expected.to contain_package('npm').with('ensure' => 'present') + is_expected.to contain_package('npm').with('ensure' => 'installed') end end @@ -1277,15 +1277,15 @@ end # nodejs_package_ensure - context 'with nodejs_package_ensure set to present' do + context 'with nodejs_package_ensure set to installed' do let :params do { - nodejs_package_ensure: 'present' + nodejs_package_ensure: 'installed' } end it 'the nodejs package should be present' do - is_expected.to contain_package('net-libs/nodejs').with('ensure' => 'present') + is_expected.to contain_package('net-libs/nodejs').with('ensure' => 'installed') end end @@ -1507,15 +1507,15 @@ end # nodejs_debug_package_ensure - context 'with nodejs_debug_package_ensure set to present' do + context 'with nodejs_debug_package_ensure set to installed' do let :params do { - nodejs_debug_package_ensure: 'present' + nodejs_debug_package_ensure: 'installed' } end it 'the nodejs package with debugging symbols should be installed' do - is_expected.to contain_package('nodejs-debuginfo').with('ensure' => 'present') + is_expected.to contain_package('nodejs-debuginfo').with('ensure' => 'installed') end end @@ -1532,15 +1532,15 @@ end # nodejs_dev_package_ensure - context 'with nodejs_dev_package_ensure set to present' do + context 'with nodejs_dev_package_ensure set to installed' do let :params do { - nodejs_dev_package_ensure: 'present' + nodejs_dev_package_ensure: 'installed' } end it 'the nodejs development package should be installed' do - is_expected.to contain_package('nodejs-devel').with('ensure' => 'present') + is_expected.to contain_package('nodejs-devel').with('ensure' => 'installed') end end @@ -1557,15 +1557,15 @@ end # nodejs_package_ensure - context 'with nodejs_package_ensure set to present' do + context 'with nodejs_package_ensure set to installed' do let :params do { - nodejs_package_ensure: 'present' + nodejs_package_ensure: 'installed' } end it 'the nodejs package should be present' do - is_expected.to contain_package('nodejs').with('ensure' => 'present') + is_expected.to contain_package('nodejs').with('ensure' => 'installed') end end @@ -1582,15 +1582,15 @@ end # npm_package_ensure - context 'with npm_package_ensure set to present' do + context 'with npm_package_ensure set to installed' do let :params do { - npm_package_ensure: 'present' + npm_package_ensure: 'installed' } end it 'the npm package should be present' do - is_expected.to contain_package('npm').with('ensure' => 'present') + is_expected.to contain_package('npm').with('ensure' => 'installed') end end From 3d37bac292f7c22ca461e3c374c03d7233babf66 Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Sun, 17 Sep 2023 14:06:23 -0700 Subject: [PATCH 21/31] README: remove parameter docs Use the autogenerated REFERENCE.md instead. --- README.md | 154 ------------------------------------------------------ 1 file changed, 154 deletions(-) diff --git a/README.md b/README.md index 9f77070d..d648154d 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,6 @@ * [Beginning with nodejs - Installation](#beginning-with-nodejs) 1. [Usage](#usage) 1. [Npm packages](#npm-packages) -1. [Parameters](#parameters) 1. [Limitations - OS compatibility, etc.](#limitations) * [Module dependencies](#module-dependencies) 1. [Development](#development) @@ -170,17 +169,6 @@ except version ranges. The title simply must be a unique, arbitrary value. (e.g. if you have a NodeJS server app), set the parameter use_package_json to true. The package name is then only used for the resource name. source parameter is ignored. -nodejs::npm parameters: - -* ensure: present (default), absent, latest, tag or version number. -* source: package source (defaults to a reserved value 'registry') -* target: where to install the package -* install_options: option flags invoked during installation such as --link (optional). -* uninstall_options: option flags invoked during removal (optional). -* npm_path: defaults to the value listed in `nodejs::params` -* user: defaults to undef -* use_package_json: read and install modules listed in package.json in target dir and install those in subdirectory node_modules (defaults to false) - Examples: Install the express package published on the npm registry to /opt/packages: @@ -373,148 +361,6 @@ nodejs::npm::global_config_entry { 'color': If a global_config_entry of `proxy` or `https-proxy` is specified, this will be applied before the local installation of npm packages using `nodejs::npm`. -### Parameters - -#### `cmd_exe_path` - -Path to cmd.exe on Windows. Defaults to C:\Windows\system32\cmd.exe. You may -need to change this parameter for certain versions of Windows Server. - -#### `manage_nodejs_package` - -Whether to manage the nodejs and nodejs-dev packages. Defaults to `true`. - -#### `manage_package_repo` - -Whether to manage an external repository and use it as the source of the -Node.js and npm package. Defaults to `true`. - -#### `nodejs_debug_package_ensure` - -When set to `present` or a version number, determines whether to install the -Node.js package with debugging symbols, if available. Defaults to `absent`. - -#### `nodejs_dev_package_ensure` - -When set to `present` or a version number, determines whether to install the -development Node.js package, if available. Defaults to `absent`. - -#### `nodejs_package_ensure` - -When set to `present` or a version number, determines whether to install the -Node.js package. Defaults to `present`. - -#### `npm_package_ensure` - -When set to `present` or a version number, determines whether to install the -separate npm package. When using the NodeSource repository, the Node.js -package includes npm, so this value defaults to `absent`. This parameter will -need to be set to `present` if you wish to use the native packages or are -using the EPEL repository. - -#### `npm_path` - -Path to the npm binary. - -#### `npmrc_auth` - -A string that contains the value for the key `_auth` that will be set in -`/root/.npmrc`, as this value is not allowed to be set by -nodejs::npm::global_config_entry. The default value is `undef`. - -#### `npmrc_config` - -A hash that contains keys/values that will be set in `/root/.npmrc`, -in the form of `key=value`. Useful for setting a http-proxy for npm only. -The default value is `undef`. - -#### `repo_class` - -Name of the Puppet class used for the setup and management of the Node.js -repository. Defaults to `::nodejs::repo::nodesource` (NodeSource). -If using the Node.js and npm packages from the EPEL repository, set this to -`::epel` and make sure that the EPEL module is applied before the nodejs -module in your Puppet node definitions. - -#### `repo_enable_src` - -Whether any repositories which hold sources are enabled. Defaults to `false`. - -#### `repo_ensure` - -Whether to ensure that the repository exists, if it is being managed. Defaults -to `present` and may also be set to `absent`. - -#### `repo_pin` - -Whether to perform APT pinning to pin the Node.js repository with a specific -value. Defaults to `undef`. - -#### `repo_priority` - -Whether to set a Yum priority for the Node.js repository. If using EPEL and -the NodeSource repository on the same system, you may wish to set this to a -value less than 99 (or the priority set for the EPEL repository) to ensure -that the NodeSource repository will always be preferred over the Node.js -packages in EPEL, should they both hold the same Node.js version. Defaults to -`absent`. - -#### `repo_proxy` - -Whether to use a proxy for this particular repository. For example, -`http://proxy.domain`. Defaults to `absent`. - -#### `repo_proxy_password` - -Password for the proxy used by the repository, if required. - -#### `repo_proxy_username` - -User for the proxy used by the repository, if required. - -#### `repo_release` - -Optional value to override the apt distribution release. Defaults to `undef` -which will autodetect the distribution. If a value is specified, this will -change the NodeSource apt repository distribution. -This is useful if the distribution name does not exist in the NodeSource -repositories. For example, the Ubilinux distribution release name 'dolcetto' -does not exist in NodeSource, but is a derivative of Debian 9 (Stretch). -Setting this value to `stretch` allows NodeSource repository management to -then work as expected on these systems. - -#### `repo_url_suffix` - -Defaults to ```12.x``` which means that the latest NodeSource 12.x release -is installed. If you wish to install a 13.x release or greater, you will -need to set this value accordingly. This parameter is a just a reflection of -the NodeSource URL structure - NodeSource might remove old versions (such as -0.10 and 0.12) or add new ones (such as 20.x) at any time. - -The following are ``repo_url_suffix`` values that reflect NodeSource versions -that were available on 2017-11-29: - -* Debian 9 (Stretch) ```4.x``` ```6.x``` ```7.x``` ```8.x``` ```9.x``` -* Debian (Sid) ```0.10``` ```0.12``` ```4.x``` ```5.x``` ```6.x``` ```7.x``` ```8.x``` ```9.x``` -* Ubuntu 16.04 (Xenial) ```0.10``` ```0.12``` ```4.x``` ```5.x``` ```6.x``` ```7.x``` ```8.x``` ```9.x``` -* Ubuntu 16.10 (Yakkety) ```0.12``` ```4.x``` ```6.x``` ```7.x``` ```8.x``` -* Ubuntu 17.10 (Artful) ```4.x``` ```6.x``` ```8.x``` ```9.x``` -* RHEL/CentOS 7 ```0.10``` ```0.12``` ```4.x``` ```5.x``` ```6.x``` ```7.x``` ```8.x``` ```9.x``` -* Amazon Linux - See RHEL/CentOS 7 -* Fedora 25 ```4.x``` ```6.x``` ```7.x``` ```8.x``` ```9.x``` -* Fedora 26 ```6.x``` ```8.x``` ```9.x``` -* Fedora 27 ```8.x``` ```9.x``` - -#### `use_flags` - -The USE flags to use for the Node.js package on Gentoo systems. Defaults to -['npm', 'snapshot']. - -#### `package_provider` - -The package provider is set as the default for most distributions. You can override -this with the package_provider parameter to use an alternative - ## Limitations This module has received limited testing on: From 42da86530b654c2fd57cb7dd462e166d32ed82fd Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Sun, 17 Sep 2023 15:16:43 -0700 Subject: [PATCH 22/31] params: drop logic for EOL Debian-family OSes --- manifests/params.pp | 63 +++++++-------------------------------------- 1 file changed, 9 insertions(+), 54 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 1ee3b711..df5a17a2 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -21,60 +21,15 @@ case $facts['os']['family'] { 'Debian': { - if $facts['os']['release']['major'] =~ /^(9|10|11)$/ { - $debian_nodejs_dev_package_name = $facts['os']['release']['major'] ? { - '9' => 'nodejs-dev', - default => 'libnode-dev', - } - $debian_npm_package_name = $facts['os']['release']['major'] ? { - '9' => false, - default => 'npm', - } - $manage_package_repo = true - $nodejs_debug_package_name = 'nodejs-dbg' - $nodejs_dev_package_name = $debian_nodejs_dev_package_name - $nodejs_dev_package_ensure = 'absent' - $nodejs_package_name = 'nodejs' - $npm_package_ensure = 'absent' - $npm_package_name = $debian_npm_package_name - $npm_path = '/usr/bin/npm' - $repo_class = '::nodejs::repo::nodesource' - } - elsif $facts['os']['release']['full'] =~ /^1[68]\.04$/ { - $manage_package_repo = true - $nodejs_debug_package_name = 'nodejs-dbg' - $nodejs_dev_package_name = 'nodejs-dev' - $nodejs_dev_package_ensure = 'absent' - $nodejs_package_name = 'nodejs' - $npm_package_ensure = 'absent' - $npm_package_name = 'npm' - $npm_path = '/usr/bin/npm' - $repo_class = '::nodejs::repo::nodesource' - } - elsif $facts['os']['release']['full'] =~ /^20\.04$/ { - $manage_package_repo = true - $nodejs_debug_package_name = 'nodejs-dbg' - $nodejs_dev_package_name = 'libnode-dev' - $nodejs_dev_package_ensure = 'absent' - $nodejs_package_name = 'nodejs' - $npm_package_ensure = 'absent' - $npm_package_name = 'npm' - $npm_path = '/usr/bin/npm' - $repo_class = '::nodejs::repo::nodesource' - } - else { - warning("The ${module_name} module might not work on ${facts['os']['name']} ${facts['os']['release']['full']}. Sensible defaults will be attempted.") - $manage_package_repo = true - $nodejs_debug_package_name = 'nodejs-dbg' - $nodejs_dev_package_name = 'nodejs-dev' - $nodejs_dev_package_ensure = 'absent' - $nodejs_package_name = 'nodejs' - $npm_package_ensure = 'absent' - $npm_package_name = 'npm' - $npm_path = '/usr/bin/npm' - $repo_class = '::nodejs::repo::nodesource' - } - + $manage_package_repo = true + $nodejs_debug_package_name = 'nodejs-dbg' + $nodejs_dev_package_name = 'libnode-dev' + $nodejs_dev_package_ensure = 'absent' + $nodejs_package_name = 'nodejs' + $npm_package_ensure = 'absent' + $npm_package_name = 'npm' + $npm_path = '/usr/bin/npm' + $repo_class = '::nodejs::repo::nodesource' $package_provider = undef } 'RedHat': { From 303fa096d0860a9587038ea5f7ead9e833491f62 Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Sun, 17 Sep 2023 16:01:54 -0700 Subject: [PATCH 23/31] params: collapse identical RedHat-family cases --- manifests/params.pp | 45 +++++++++------------------------------------ 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index df5a17a2..255d3f70 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -33,42 +33,15 @@ $package_provider = undef } 'RedHat': { - if $facts['os']['release']['major'] =~ /^[789]$/ { - $manage_package_repo = true - $nodejs_debug_package_name = 'nodejs-debuginfo' - $nodejs_dev_package_name = 'nodejs-devel' - $nodejs_dev_package_ensure = 'absent' - $nodejs_package_name = 'nodejs' - $npm_package_ensure = 'absent' - $npm_package_name = 'npm' - $npm_path = '/usr/bin/npm' - $repo_class = '::nodejs::repo::nodesource' - } - elsif $facts['os']['name'] == 'Fedora' { - $manage_package_repo = true - $nodejs_debug_package_name = 'nodejs-debuginfo' - $nodejs_dev_package_name = 'nodejs-devel' - $nodejs_dev_package_ensure = 'absent' - $nodejs_package_name = 'nodejs' - $npm_package_ensure = 'absent' - $npm_package_name = 'npm' - $npm_path = '/usr/bin/npm' - $repo_class = '::nodejs::repo::nodesource' - } - elsif ($facts['os']['name'] == 'Amazon') { - $manage_package_repo = true - $nodejs_debug_package_name = 'nodejs-debuginfo' - $nodejs_dev_package_name = 'nodejs-devel' - $nodejs_dev_package_ensure = 'absent' - $nodejs_package_name = 'nodejs' - $npm_package_ensure = 'absent' - $npm_package_name = 'npm' - $npm_path = '/usr/bin/npm' - $repo_class = '::nodejs::repo::nodesource' - } - else { - fail("The ${module_name} module is not supported on ${facts['os']['name']} ${facts['os']['release']['full']}.") - } + $manage_package_repo = true + $nodejs_debug_package_name = 'nodejs-debuginfo' + $nodejs_dev_package_name = 'nodejs-devel' + $nodejs_dev_package_ensure = 'absent' + $nodejs_package_name = 'nodejs' + $npm_package_ensure = 'absent' + $npm_package_name = 'npm' + $npm_path = '/usr/bin/npm' + $repo_class = 'nodejs::repo::nodesource' $package_provider = undef } 'Suse': { From f98ff7a001cf382fc01ca75381deb7f45997715c Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Sun, 17 Sep 2023 16:03:11 -0700 Subject: [PATCH 24/31] remove obsolete top-level class syntax --- README.md | 2 +- manifests/npm/global_config_entry.pp | 2 +- manifests/params.pp | 2 +- spec/acceptance/class_spec.rb | 2 +- spec/classes/nodejs_spec.rb | 30 ++++++++++++------------ spec/defines/global_config_entry_spec.rb | 2 +- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index d648154d..55a1f172 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ Install Node.js and npm using the packages from EPEL: class { '::nodejs': nodejs_dev_package_ensure => installed, npm_package_ensure => installed, - repo_class => '::epel', + repo_class => 'epel', } ``` diff --git a/manifests/npm/global_config_entry.pp b/manifests/npm/global_config_entry.pp index 73d3101d..bcd2282a 100644 --- a/manifests/npm/global_config_entry.pp +++ b/manifests/npm/global_config_entry.pp @@ -49,7 +49,7 @@ if $nodejs::npm_package_ensure != 'absent' { $exec_require = "Package[${nodejs::npm_package_name}]" - } elsif $nodejs::repo_class == '::nodejs::repo::nodesource' { + } elsif $nodejs::repo_class == 'nodejs::repo::nodesource' { $exec_require = "Package[${nodejs::nodejs_package_name}]" } else { $exec_require = undef diff --git a/manifests/params.pp b/manifests/params.pp index 255d3f70..abeb4cb0 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -29,7 +29,7 @@ $npm_package_ensure = 'absent' $npm_package_name = 'npm' $npm_path = '/usr/bin/npm' - $repo_class = '::nodejs::repo::nodesource' + $repo_class = 'nodejs::repo::nodesource' $package_provider = undef } 'RedHat': { diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 5473251e..932b4260 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -36,7 +36,7 @@ let(:manifest) do <<-PUPPET class { 'nodejs': - repo_class => '::epel', + repo_class => 'epel', } PUPPET end diff --git a/spec/classes/nodejs_spec.rb b/spec/classes/nodejs_spec.rb index ea99ac7b..1ca51de9 100644 --- a/spec/classes/nodejs_spec.rb +++ b/spec/classes/nodejs_spec.rb @@ -77,16 +77,16 @@ end end - context 'and repo_class set to ::nodejs::repo::nodesource' do + context 'and repo_class set to nodejs::repo::nodesource' do let :params do default_params.merge!(repo_class: 'nodejs::repo::nodesource') end - it '::nodejs::repo::nodesource should be in the catalog' do + it 'nodejs::repo::nodesource should be in the catalog' do is_expected.to contain_class('nodejs::repo::nodesource') end - it '::nodejs::repo::nodesource::apt should be in the catalog' do + it 'nodejs::repo::nodesource::apt should be in the catalog' do is_expected.to contain_class('nodejs::repo::nodesource::apt') end end @@ -179,8 +179,8 @@ } end - it '::nodejs::repo::nodesource should not be in the catalog' do - is_expected.not_to contain_class('::nodejs::repo::nodesource') + it 'nodejs::repo::nodesource should not be in the catalog' do + is_expected.not_to contain_class('nodejs::repo::nodesource') end end @@ -376,16 +376,16 @@ end end - context 'and repo_class set to ::nodejs::repo::nodesource' do + context 'and repo_class set to nodejs::repo::nodesource' do let :params do default_params.merge!(repo_class: 'nodejs::repo::nodesource') end - it '::nodejs::repo::nodesource should be in the catalog' do + it 'nodejs::repo::nodesource should be in the catalog' do is_expected.to contain_class('nodejs::repo::nodesource') end - it '::nodejs::repo::nodesource::yum should be in the catalog' do + it 'nodejs::repo::nodesource::yum should be in the catalog' do is_expected.to contain_class('nodejs::repo::nodesource::yum') end @@ -544,8 +544,8 @@ } end - it '::nodejs::repo::nodesource should not be in the catalog' do - is_expected.not_to contain_class('::nodejs::repo::nodesource') + it 'nodejs::repo::nodesource should not be in the catalog' do + is_expected.not_to contain_class('nodejs::repo::nodesource') end end @@ -1363,16 +1363,16 @@ end end - context 'and repo_class set to ::nodejs::repo::nodesource' do + context 'and repo_class set to nodejs::repo::nodesource' do let :params do default_params.merge!(repo_class: 'nodejs::repo::nodesource') end - it '::nodejs::repo::nodesource should be in the catalog' do + it 'nodejs::repo::nodesource should be in the catalog' do is_expected.to contain_class('nodejs::repo::nodesource') end - it '::nodejs::repo::nodesource::yum should be in the catalog' do + it 'nodejs::repo::nodesource::yum should be in the catalog' do is_expected.to contain_class('nodejs::repo::nodesource::yum') end @@ -1501,8 +1501,8 @@ } end - it '::nodejs::repo::nodesource should not be in the catalog' do - is_expected.not_to contain_class('::nodejs::repo::nodesource') + it 'nodejs::repo::nodesource should not be in the catalog' do + is_expected.not_to contain_class('nodejs::repo::nodesource') end end diff --git a/spec/defines/global_config_entry_spec.rb b/spec/defines/global_config_entry_spec.rb index 77a99e26..fed654fb 100644 --- a/spec/defines/global_config_entry_spec.rb +++ b/spec/defines/global_config_entry_spec.rb @@ -106,7 +106,7 @@ class { 'nodejs': class { 'nodejs': nodejs_package_name => 'node-package-name', npm_package_ensure => absent, - repo_class => '::nodejs::repo::nodesource', + repo_class => 'nodejs::repo::nodesource', } PUPPET end From bb990d9ecc7ab0ba23e664b0dbf66fd1290e92e2 Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Sun, 17 Sep 2023 16:10:24 -0700 Subject: [PATCH 25/31] fix acceptance tests Don't care where the packages come from on RedHat. Test installing npm and the nodejs dev package on RedHat. Run the global_config_entry tests on all OSes, not just RedHat. Don't do redundant package checks within these contexts. Arrange the config entry and package tests near each other. --- spec/acceptance/class_spec.rb | 120 ++++++++++++++++------------------ 1 file changed, 58 insertions(+), 62 deletions(-) diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 932b4260..88935f6f 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -29,105 +29,101 @@ end end - context 'repo_class => epel', if: ((fact('os.family') == 'RedHat') && (fact('os.release.major') != '8')) do + context 'RedHat with repo_class => epel', if: fact('os.family') == 'RedHat' do include_examples 'cleanup' it_behaves_like 'an idempotent resource' do let(:manifest) do <<-PUPPET class { 'nodejs': - repo_class => 'epel', + nodejs_dev_package_ensure => installed, + npm_package_ensure => installed, + repo_class => 'epel', } PUPPET end end - describe package('nodejs') do - it { is_expected.to be_installed } - - it 'comes from the expected source' do - pending("This won't work until we have CentOS 7.4 because of dependency") - pkg_output = shell(pkg_cmd) - expect(pkg_output.stdout).to match 'epel' + %w[ + npm + nodejs + nodejs-devel + ].each do |pkg| + describe package(pkg) do + it { is_expected.to be_installed } end end + end - context 'set global_config_entry secret', if: fact('os.family') == 'RedHat' do - it_behaves_like 'an idempotent resource' do - let(:manifest) do - <<-PUPPET - class { 'nodejs': } - nodejs::npm::global_config_entry { '//path.to.registry/:_secret': - ensure => present, - value => 'cGFzc3dvcmQ=', - require => Package[nodejs], - } - PUPPET - end - end + context 'Debian distribution packages', if: fact('os.family') == 'Debian' do + include_examples 'cleanup' - describe package('nodejs') do - it { is_expected.to be_installed } + it_behaves_like 'an idempotent resource' do + let(:manifest) do + <<-PUPPET + class { 'nodejs': + manage_package_repo => false, + nodejs_dev_package_ensure => installed, + npm_package_ensure => installed, + } + PUPPET end + end - 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="' - end + %w[ + libnode-dev + npm + ].each do |pkg| + describe package(pkg) do + it { is_expected.to be_installed } end end + end - context 'set global_config_entry secret unquoted', if: fact('os.family') == 'RedHat' do - it_behaves_like 'an idempotent resource' do - let(:manifest) do - <<-PUPPET - class { 'nodejs': } - nodejs::npm::global_config_entry { '//path.to.registry/:_secret': - ensure => present, - value => 'cGFzc3dvcmQ', - require => Package[nodejs], - } - PUPPET - end - end + context 'set global_config_entry secret' do + include_examples 'cleanup' - describe package('nodejs') do - it { is_expected.to be_installed } + it_behaves_like 'an idempotent resource' do + let(:manifest) do + <<-PUPPET + class { 'nodejs': } + nodejs::npm::global_config_entry { '//path.to.registry/:_secret': + ensure => present, + value => 'cGFzc3dvcmQ=', + require => Package[nodejs], + } + PUPPET end + end - 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' - end + 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="' end end end - context 'native Debian packages' do + context 'set global_config_entry secret unquoted' do include_examples 'cleanup' it_behaves_like 'an idempotent resource' do let(:manifest) do <<-PUPPET - class { 'nodejs': - manage_package_repo => false, - nodejs_dev_package_ensure => installed, - npm_package_ensure => installed, + class { 'nodejs': } + nodejs::npm::global_config_entry { '//path.to.registry/:_secret': + ensure => present, + value => 'cGFzc3dvcmQ', + require => Package[nodejs], } PUPPET end end - if fact('os.family') == 'Debian' - %w[ - libnode-dev - npm - ].each do |pkg| - describe package(pkg) do - it { is_expected.to be_installed } - end + 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' end end end From be87721cd3edffc7d71843952531da0678c1d5e5 Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Sun, 17 Sep 2023 17:15:18 -0700 Subject: [PATCH 26/31] remove unit test code for EOL Debian and Ubuntu versions --- spec/classes/nodejs_spec.rb | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/spec/classes/nodejs_spec.rb b/spec/classes/nodejs_spec.rb index 1ca51de9..3c5d95e6 100644 --- a/spec/classes/nodejs_spec.rb +++ b/spec/classes/nodejs_spec.rb @@ -11,13 +11,6 @@ facts end - native_debian_devel_package = if (facts[:os]['name'] == 'Ubuntu' && Gem::Version.new(facts[:os]['release']['major']) >= Gem::Version.new('20.04')) || - (facts[:os]['name'] == 'Debian' && Gem::Version.new(facts[:os]['release']['major']) >= Gem::Version.new(10)) - 'libnode-dev' - else - 'nodejs-dev' - end - it 'the file resource root_npmrc should be in the catalog' do is_expected.to contain_file('root_npmrc').with( 'ensure' => 'file', @@ -73,7 +66,7 @@ it 'the nodejs and dev package resources should not be present' do is_expected.not_to contain_package('nodejs') - is_expected.not_to contain_package(native_debian_devel_package) + is_expected.not_to contain_package('libnode-dev') end end @@ -218,7 +211,7 @@ end it 'the nodejs development package should be installed' do - is_expected.to contain_package(native_debian_devel_package).with('ensure' => 'installed') + is_expected.to contain_package('libnode-dev').with('ensure' => 'installed') end end @@ -230,7 +223,7 @@ end it 'the nodejs development package should not be present' do - is_expected.to contain_package(native_debian_devel_package).with('ensure' => 'absent') + is_expected.to contain_package('libnode-dev').with('ensure' => 'absent') end end @@ -267,15 +260,8 @@ } end - # Debian 9 (stretch) doesn't have npm in the standard repositories (it has been backported though). - if facts[:os]['family'] == 'Debian' && facts[:os]['release']['major'] == '9' - it 'the npm package resource should not be present' do - is_expected.not_to contain_package('npm') - end - else - it 'the npm package should be installed' do - is_expected.to contain_package('npm').with('ensure' => 'installed') - end + it 'the npm package should be installed' do + is_expected.to contain_package('npm').with('ensure' => 'installed') end end @@ -286,15 +272,8 @@ } end - # Debian 9 (stretch) doesn't have npm in the standard repositories (it has been backported though). - if facts[:os]['family'] == 'Debian' && facts[:os]['release']['major'] == '9' - it 'the npm package resource should not be present' do - is_expected.not_to contain_package('npm') - end - else - it 'the npm package should be absent' do - is_expected.to contain_package('npm').with('ensure' => 'absent') - end + it 'the npm package should be absent' do + is_expected.to contain_package('npm').with('ensure' => 'absent') end end From f86c8895e330bdadcdea08689a6ec37396a2eedb Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Sun, 17 Sep 2023 17:17:36 -0700 Subject: [PATCH 27/31] nodejs_spec: fix formatting --- spec/classes/nodejs_spec.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/spec/classes/nodejs_spec.rb b/spec/classes/nodejs_spec.rb index 3c5d95e6..c28dff9f 100644 --- a/spec/classes/nodejs_spec.rb +++ b/spec/classes/nodejs_spec.rb @@ -369,11 +369,15 @@ end it 'the nodesource and nodesource-source repos should contain the right description and baseurl' do - is_expected.to contain_yumrepo('nodesource').with('baseurl' => repo_baseurl, - 'descr' => repo_descr) - - is_expected.to contain_yumrepo('nodesource-source').with('baseurl' => repo_source_baseurl, - 'descr' => repo_source_descr) + is_expected.to contain_yumrepo('nodesource').with( + 'baseurl' => repo_baseurl, + 'descr' => repo_descr + ) + + is_expected.to contain_yumrepo('nodesource-source').with( + 'baseurl' => repo_source_baseurl, + 'descr' => repo_source_descr + ) end end From 950a9b8339176377b08e8ce4c1fcb0b77e84f894 Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Sun, 17 Sep 2023 17:37:39 -0700 Subject: [PATCH 28/31] acceptance test cleanup: use `purged` instead of `absent` Due to Puppet's use of rpm --erase with ensure=>absent, it can't remove packages with reverse dependencies. Using ensure=>purged forces Puppet to use dnf to remove packages instead of rpm. --- spec/support/acceptance/shared_examples.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/support/acceptance/shared_examples.rb b/spec/support/acceptance/shared_examples.rb index e42eed16..ce231dcc 100644 --- a/spec/support/acceptance/shared_examples.rb +++ b/spec/support/acceptance/shared_examples.rb @@ -6,10 +6,10 @@ let(:manifest) do <<-PUPPET class { 'nodejs': - nodejs_debug_package_ensure => absent, - nodejs_dev_package_ensure => absent, - nodejs_package_ensure => absent, - npm_package_ensure => absent, + nodejs_debug_package_ensure => purged, + nodejs_dev_package_ensure => purged, + nodejs_package_ensure => purged, + npm_package_ensure => purged, repo_ensure => absent, } PUPPET From 900bdd037e92146f260c510bbab46fdf121ffe0d Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Mon, 18 Sep 2023 21:01:50 -0700 Subject: [PATCH 29/31] acceptance: don't try installing nodejs-devel on RedHat nodejs-devel is version 16.18, but nodejs is version 16.20, so the package management system won't allow them both to be installed. --- spec/acceptance/class_spec.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 88935f6f..617554ff 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -33,10 +33,19 @@ include_examples 'cleanup' it_behaves_like 'an idempotent resource' do + # nodejs-devel (from EPEL) is currently not installable alongside nodejs + # (from appstream) due to differing versions. + nodejs_dev_package_ensure = + if fact('os.release.major') == '9' + 'undef' + else + 'installed' + end + let(:manifest) do <<-PUPPET class { 'nodejs': - nodejs_dev_package_ensure => installed, + nodejs_dev_package_ensure => #{nodejs_dev_package_ensure}, npm_package_ensure => installed, repo_class => 'epel', } @@ -50,7 +59,10 @@ class { 'nodejs': nodejs-devel ].each do |pkg| describe package(pkg) do - it { is_expected.to be_installed } + it do + pending('nodejs-devel and nodejs not installable together on EL9') if fact('os.release.major') == '9' && pkg == 'nodejs-devel' + is_expected.to be_installed + end end end end From 048847ef8d10a2719952efa96a4fca7186729f3a Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Mon, 18 Sep 2023 21:29:10 -0700 Subject: [PATCH 30/31] README: Limitations section: refer to metadata.json --- README.md | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 55a1f172..b1270885 100644 --- a/README.md +++ b/README.md @@ -363,24 +363,7 @@ applied before the local installation of npm packages using `nodejs::npm`. ## Limitations -This module has received limited testing on: - -* CentOS/RHEL 7/8/9 -* Debian 9/10 -* Ubuntu 16.04/18.04/20.04 - -The following platforms should also work, but have not been tested: - -* Amazon Linux -* Archlinux -* Darwin -* Fedora -* FreeBSD -* Gentoo -* OpenBSD -* OpenSuse/SLES -* Ubilinux -* Windows +See [`metadata.json`](metadata.json) for supported operating systems. ### Module dependencies @@ -388,7 +371,7 @@ This modules uses `puppetlabs-apt` for the management of the NodeSource repository. If using an operating system of the Debian-based family, you will need to ensure that `puppetlabs-apt` version 4.4.0 or above is installed. -If using CentOS/RHEL 7 and you wish to install Node.js from EPEL rather +If using CentOS/RHEL and you wish to install Node.js from EPEL rather than from the NodeSource repository, you will need to ensure `puppet-epel` is installed and is applied before this module. From 3d8b2e938b528bede9598b4636dc3f2bf5389a85 Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Wed, 20 Sep 2023 20:52:25 -0700 Subject: [PATCH 31/31] acceptance tests: replace deprecated install_module_from_forge install_module_from_forge is from the deprecated gem https://github.com/voxpupuli/beaker-module_install_helper/ which was replaced by https://github.com/voxpupuli/beaker_puppet_helpers. --- .sync.yml | 2 +- spec/acceptance/class_spec.rb | 2 -- spec/spec_helper_acceptance.rb | 12 ++++++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.sync.yml b/.sync.yml index e295ca9c..4cf442c8 100644 --- a/.sync.yml +++ b/.sync.yml @@ -2,4 +2,4 @@ spec/spec_helper.rb: mock_with: ':mocha' spec/spec_helper_acceptance.rb: - unmanaged: false + unmanaged: true diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 617554ff..eda53722 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -6,10 +6,8 @@ case fact('os.family') when 'RedHat' pkg_cmd = 'yum info nodejs | grep "^From repo"' - install_module_from_forge('puppet-epel', '>= 3.0.0 < 4.0.0') when 'Debian' pkg_cmd = 'dpkg -s nodejs | grep "^Maintainer"' - install_module_from_forge('puppetlabs-apt', '>= 4.4.0 < 9.0.0') end context 'default parameters' do diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 2681792e..669ccaff 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,10 +1,14 @@ # frozen_string_literal: true -# Managed by modulesync - DO NOT EDIT -# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ - require 'voxpupuli/acceptance/spec_helper_acceptance' -configure_beaker(modules: :metadata) +configure_beaker do |host| + case fact('os.family') + when 'Debian' + install_puppet_module_via_pmt_on(host, 'puppetlabs-apt') + when 'RedHat' + install_puppet_module_via_pmt_on(host, 'puppet-epel') + end +end Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f }