diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 66cc2e09..c0df4a6f 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -8,7 +8,7 @@ jobs: name: 'Syntax validation' runs-on: ubuntu-latest timeout-minutes: 10 - container: puppet/pdk:3.0.0.0 + container: puppet/pdk:3.4.0.1.55.g4519dd0 steps: - uses: actions/checkout@v4 - name: Run static validations @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 # container: puppet/puppet-dev-tools:4.x - container: puppet/pdk:3.0.0.0 + container: puppet/pdk:3.4.0.1.55.g4519dd0 steps: - uses: actions/checkout@v4 - name: Run unit tests on Puppet 8 @@ -39,7 +39,7 @@ jobs: name: 'Unit tests Legacy Puppet' runs-on: ubuntu-latest timeout-minutes: 60 - container: puppet/puppet-dev-tools:4.x + container: puppet/pdk:3.4.0.1.55.g4519dd0 steps: - uses: actions/checkout@v4 - name: Run unit tests on Puppet 6 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a7946591..aff7e919 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,16 +14,16 @@ jobs: name: 'Deploy to forge' runs-on: ubuntu-latest if: github.repository_owner == 'example42' - container: puppet/pdk:2.6.1.0 + container: puppet/pdk:3.4.0.1.55.g4519dd0 steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: "PDK Build" - uses: docker://puppet/pdk:2.6.1.0 + uses: docker://puppet/pdk:3.4.0.1.55.g4519dd0 with: args: 'build' - name: "Push to Forge" - uses: docker://puppet/pdk:2.6.1.0 + uses: docker://puppet/pdk:3.4.0.1.55.g4519dd0 with: args: 'release publish --forge-token ${{ secrets.PUPPET_FORGE_API_KEY }} --force' diff --git a/.gitignore b/.gitignore index 3f155121..2803e566 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ /spec/fixtures/modules/* /tmp/ /vendor/ +/.vendor/ /convert_report.txt /update_report.txt .DS_Store @@ -26,3 +27,9 @@ .envrc /inventory.yaml /spec/fixtures/litmus_inventory.yaml +.resource_types +.modules +.task_cache.json +.plan_cache.json +.rerun.json +bolt-debug.log diff --git a/.pdkignore b/.pdkignore index 584438f9..84684be6 100644 --- a/.pdkignore +++ b/.pdkignore @@ -19,6 +19,7 @@ /spec/fixtures/modules/* /tmp/ /vendor/ +/.vendor/ /convert_report.txt /update_report.txt .DS_Store @@ -26,9 +27,16 @@ .envrc /inventory.yaml /spec/fixtures/litmus_inventory.yaml +.resource_types +.modules +.task_cache.json +.plan_cache.json +.rerun.json +bolt-debug.log /.fixtures.yml /Gemfile /.gitattributes +/.github/ /.gitignore /.pdkignore /.puppet-lint.rc diff --git a/.puppet-lint.rc b/.puppet-lint.rc index bcb46ccf..9e15c6e0 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1,2 +1,9 @@ +--fail-on-warnings --relative ---no-parameter_documentation-check +--no-80chars-check +--no-140chars-check +--no-class_inherits_from_params_class-check +--no-autoloader_layout-check +--no-documentation-check +--no-single_quote_string_with_variables-check +--ignore-paths=.vendor/**/*.pp,.bundle/**/*.pp,pkg/**/*.pp,spec/**/*.pp,tests/**/*.pp,types/**/*.pp,vendor/**/*.pp diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 2f1e4f73..6da8d472 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,6 +1,6 @@ { "recommendations": [ "puppet.puppet-vscode", - "rebornix.Ruby" + "Shopify.ruby-lsp" ] } diff --git a/CHANGELOG.md b/CHANGELOG.md index 4157d62c..f5318fdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## Changelog +## Release 1.1.1 + +- A few more puppet 8 fixes +- Actions updates + ## Release 1.1.0 - More updates for full Puppet 8 compatibility diff --git a/Gemfile b/Gemfile index eb45bfe5..18df10ec 100644 --- a/Gemfile +++ b/Gemfile @@ -14,46 +14,53 @@ def location_for(place_or_version, fake_version = nil) end group :development do - gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.5.1', require: false if Gem::Requirement.create(['>= 3.0.0', '< 3.0.5']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "json", '= 2.6.1', require: false if Gem::Requirement.create(['>= 3.1.0', '< 3.1.3']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "json", '= 2.6.3', require: false if Gem::Requirement.create(['>= 3.2.0', '< 4.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "racc", '~> 1.4.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "deep_merge", '~> 1.2.2', require: false gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false - gem "facterdb", '~> 1.18', require: false - gem "metadata-json-lint", '~> 3.0', require: false - gem "puppetlabs_spec_helper", '~> 6.0', require: false - gem "rspec-puppet-facts", '~> 2.0', require: false - gem "codecov", '~> 0.2', require: false + gem "facterdb", '~> 2.1', require: false if Gem::Requirement.create(['< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "facterdb", '~> 3.0', require: false if Gem::Requirement.create(['>= 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "metadata-json-lint", '~> 4.0', require: false + gem "json-schema", '< 5.1.1', require: false + gem "rspec-puppet-facts", '~> 4.0', require: false if Gem::Requirement.create(['< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "rspec-puppet-facts", '~> 5.0', require: false if Gem::Requirement.create(['>= 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "dependency_checker", '~> 1.0.0', require: false gem "parallel_tests", '= 3.12.1', require: false gem "pry", '~> 0.10', require: false - gem "simplecov-console", '~> 0.5', require: false + gem "simplecov-console", '~> 0.9', require: false gem "puppet-debugger", '~> 1.0', require: false - gem "rubocop", '= 1.48.1', require: false + gem "rubocop", '~> 1.50.0', require: false gem "rubocop-performance", '= 1.16.0', require: false gem "rubocop-rspec", '= 2.19.0', require: false - gem "puppet-strings", '~> 2.0', require: false gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] end -#group :system_tests do -# gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] -# gem "serverspec", '~> 2.41', require: false -#end - -puppet_version = ENV['PUPPET_GEM_VERSION'] -facter_version = ENV['FACTER_GEM_VERSION'] -hiera_version = ENV['HIERA_GEM_VERSION'] +group :development, :release_prep do + gem "puppet-strings", '~> 4.0', require: false + gem "puppetlabs_spec_helper", '~> 8.0', require: false + gem "puppet-blacksmith", '~> 7.0', require: false +end +group :system_tests do + gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] + gem "CFPropertyList", '< 3.0.7', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "serverspec", '~> 2.41', require: false +end gems = {} +puppet_version = ENV.fetch('PUPPET_GEM_VERSION', nil) +facter_version = ENV.fetch('FACTER_GEM_VERSION', nil) +hiera_version = ENV.fetch('HIERA_GEM_VERSION', nil) -gems['puppet'] = location_for(puppet_version) - -# If facter or hiera versions have been specified via the environment -# variables +# If PUPPET_FORGE_TOKEN is set then use authenticated source for both puppet and facter, since facter is a transitive dependency of puppet +# Otherwise, do as before and use location_for to fetch gems from the default source +if !ENV['PUPPET_FORGE_TOKEN'].to_s.empty? + gems['puppet'] = ['~> 8.11', { require: false, source: 'https://rubygems-puppetcore.puppet.com' }] + gems['facter'] = ['~> 4.11', { require: false, source: 'https://rubygems-puppetcore.puppet.com' }] +else + gems['puppet'] = location_for(puppet_version) + gems['facter'] = location_for(facter_version) if facter_version +end -gems['facter'] = location_for(facter_version) if facter_version gems['hiera'] = location_for(hiera_version) if hiera_version gems.each do |gem_name, gem_params| diff --git a/Rakefile b/Rakefile index 74415a96..31b59305 100644 --- a/Rakefile +++ b/Rakefile @@ -4,85 +4,15 @@ require 'bundler' require 'puppet_litmus/rake_tasks' if Gem.loaded_specs.key? 'puppet_litmus' require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-syntax/tasks/puppet-syntax' -require 'github_changelog_generator/task' if Gem.loaded_specs.key? 'github_changelog_generator' require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings' -def changelog_user - return unless Rake.application.top_level_tasks.include? "changelog" - returnVal = nil || JSON.load(File.read('metadata.json'))['author'] - raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil? - puts "GitHubChangelogGenerator user:#{returnVal}" - returnVal -end - -def changelog_project - return unless Rake.application.top_level_tasks.include? "changelog" - - returnVal = nil - returnVal ||= begin - metadata_source = JSON.load(File.read('metadata.json'))['source'] - metadata_source_match = metadata_source && metadata_source.match(%r{.*\/([^\/]*?)(?:\.git)?\Z}) - - metadata_source_match && metadata_source_match[1] - end - - raise "unable to find the changelog_project in .sync.yml or calculate it from the source in metadata.json" if returnVal.nil? - - puts "GitHubChangelogGenerator project:#{returnVal}" - returnVal -end - -def changelog_future_release - return unless Rake.application.top_level_tasks.include? "changelog" - returnVal = "v%s" % JSON.load(File.read('metadata.json'))['version'] - raise "unable to find the future_release (version) in metadata.json" if returnVal.nil? - puts "GitHubChangelogGenerator future_release:#{returnVal}" - returnVal -end - PuppetLint.configuration.send('disable_relative') - - -if Gem.loaded_specs.key? 'github_changelog_generator' - GitHubChangelogGenerator::RakeTask.new :changelog do |config| - raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil? - config.user = "#{changelog_user}" - config.project = "#{changelog_project}" - config.future_release = "#{changelog_future_release}" - config.exclude_labels = ['maintenance'] - config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)." - config.add_pr_wo_labels = true - config.issues = false - config.merge_prefix = "### UNCATEGORIZED PRS; LABEL THEM ON GITHUB" - config.configure_sections = { - "Changed" => { - "prefix" => "### Changed", - "labels" => ["backwards-incompatible"], - }, - "Added" => { - "prefix" => "### Added", - "labels" => ["enhancement", "feature"], - }, - "Fixed" => { - "prefix" => "### Fixed", - "labels" => ["bug", "documentation", "bugfix"], - }, - } - end -else - desc 'Generate a Changelog from GitHub' - task :changelog do - raise < 1.15' - condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0')" -EOM - end -end +PuppetLint.configuration.send('disable_80chars') +PuppetLint.configuration.send('disable_140chars') +PuppetLint.configuration.send('disable_class_inherits_from_params_class') +PuppetLint.configuration.send('disable_autoloader_layout') +PuppetLint.configuration.send('disable_documentation') +PuppetLint.configuration.send('disable_single_quote_string_with_variables') +PuppetLint.configuration.fail_on_warnings = true +PuppetLint.configuration.ignore_paths = [".vendor/**/*.pp", ".bundle/**/*.pp", "pkg/**/*.pp", "spec/**/*.pp", "tests/**/*.pp", "types/**/*.pp", "vendor/**/*.pp"] diff --git a/docs/proxy.md b/docs/proxy.md index 6e5a453e..1907a742 100644 --- a/docs/proxy.md +++ b/docs/proxy.md @@ -15,8 +15,8 @@ and manage proxy settings with: password: xxx # Optional no_proxy: - localhost - - "%{::domain}" - - "%{::fqdn}" + - "%{facts.networking.domain}" + - "%{facts.networking.fqdn}" scheme: http You can customise the components for which proxy should be configured, here are the default params: diff --git a/manifests/init.pp b/manifests/init.pp index a061fce0..795e0cff 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -82,7 +82,7 @@ # password: xxx # Optional # no_proxy: # - localhost -# - "%{::domain}" +# - "%{facts.networking.domain}" # scheme: http # # @example Define arbitrary resources, with some defaults diff --git a/manifests/puppet/postrun.pp b/manifests/puppet/postrun.pp index 43b9eb82..884ffdad 100644 --- a/manifests/puppet/postrun.pp +++ b/manifests/puppet/postrun.pp @@ -21,7 +21,7 @@ noop($noop_value) } - $manage_content = tp_content($content, $template, $epp) + $manage_content = tp::content($content, $template, $epp) File { owner => 'root', diff --git a/manifests/services/init_script.pp b/manifests/services/init_script.pp index 52b21813..ef6f923e 100644 --- a/manifests/services/init_script.pp +++ b/manifests/services/init_script.pp @@ -12,7 +12,7 @@ Optional[String] $service_ensure = undef, Variant[Undef,Boolean,String] $service_enable = undef, ) { - $manage_content = tp_content($content, $template, $epp) + $manage_content = tp::content($content, $template, $epp) file { "/etc/init.d/${title}": ensure => $ensure, content => $manage_content, diff --git a/manifests/services/systemd_script.pp b/manifests/services/systemd_script.pp index 323320c9..9a53369f 100644 --- a/manifests/services/systemd_script.pp +++ b/manifests/services/systemd_script.pp @@ -16,7 +16,7 @@ Optional[String] $systemd_after = 'network.target', # lint:ignore:optional_default Optional[String] $systemd_before = undef, ) { - $manage_content = tp_content($content, $template, $epp) + $manage_content = tp::content($content, $template, $epp) file { $path: ensure => $ensure, content => $manage_content, diff --git a/manifests/tools/create_dir.pp b/manifests/tools/create_dir.pp index cb7a0c57..065f7602 100644 --- a/manifests/tools/create_dir.pp +++ b/manifests/tools/create_dir.pp @@ -12,16 +12,12 @@ Optional[String] $group = undef, Optional[Stdlib::Filemode] $mode = undef, Stdlib::AbsolutePath $path = $title, + Optional[String] $command_provider = undef, ) { $mkdir_command = $facts['os']['family'] ? { 'windows' => "New-Item -ItemType Directory -Force -Path '${path}'", default => "mkdir -p '${path}'", } - $command_provider = $facts['os']['family'] ? { - 'windows' => 'powershell', - default => undef, - } - exec { "Create directory ${title}": command => $mkdir_command, path => $facts['path'], diff --git a/metadata.json b/metadata.json index 9abe5696..aaafaf4b 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "example42-psick", - "version": "1.1.0", + "version": "1.1.1", "author": "Example42", "summary": "Psick: the infrastructure module.", "license": "Apache-2.0", @@ -29,25 +29,25 @@ { "operatingsystem": "RedHat", "operatingsystemrelease": [ - "6", "7", - "8" + "8", + "9" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ - "6", "7", - "8" + "8", + "9" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ - "6", "7", - "8" + "8", + "9" ] }, { @@ -60,8 +60,6 @@ { "operatingsystem": "Debian", "operatingsystemrelease": [ - "8", - "9", "10", "11", "12" @@ -73,7 +71,8 @@ "16.04", "18.04", "20.04", - "22.04" + "22.04", + "24.04" ] }, { @@ -90,10 +89,13 @@ { "name": "puppet", "version_requirement": ">= 4.5.0 < 9.0.0" + }, + { + "name": "openvox", + "version_requirement": ">= 7.0.0 < 9.0.0" } ], - "description": "Psick Puppet module. A single module to manage an extendable Puppet infrastructure", - "pdk-version": "3.0.0", + "pdk-version": "3.4.0", "template-url": "https://github.com/puppetlabs/pdk-templates#main", - "template-ref": "heads/main-0-g1cc0d22" + "template-ref": "heads/main-0-g05d2de4" } diff --git a/spec/fixtures/hiera.yaml b/spec/fixtures/hiera.yaml index fdc82195..94084f65 100644 --- a/spec/fixtures/hiera.yaml +++ b/spec/fixtures/hiera.yaml @@ -4,6 +4,6 @@ :yaml: :datadir: './spec/fixtures/hieradata' :hierarchy: - - '%{::clientcert}' + - '%{trusted.certname}' - 'common' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6820cebe..ae7c1f68 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -25,7 +25,8 @@ next unless File.exist?(f) && File.readable?(f) && File.size?(f) begin - default_facts.merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true)) + require 'deep_merge' + default_facts.deep_merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true)) rescue StandardError => e RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" end @@ -33,7 +34,7 @@ # read default_facts and merge them over what is provided by facterdb default_facts.each do |fact, value| - add_custom_fact fact, value + add_custom_fact fact, value, merge_facts: true end RSpec.configure do |c|