From 6cffef40f8a645752911a68ce8ca63cf8401f5ca Mon Sep 17 00:00:00 2001 From: Steven Pritchard Date: Tue, 10 Oct 2023 11:33:36 -0500 Subject: [PATCH] [puppetsync] Updates for Puppet 8 (#65) These updates may include the following: * Update Gemfile * Add support for Puppet 8 * Drop support for Puppet 6 * Update module dependencies * Drop use of deprecated `validate_re()` * Add a workaround for rspec-puppet 4 --- CHANGELOG | 8 ++++++++ Gemfile | 34 +++++++++++++++++----------------- REFERENCE.md | 8 +++++++- manifests/useradd.pp | 7 +++---- metadata.json | 10 +++++----- spec/classes/useradd_spec.rb | 2 +- spec/spec_helper.rb | 2 +- 7 files changed, 42 insertions(+), 29 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0dcccfa..0ac7ebe 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,11 @@ +* Fri Oct 06 2023 Steven Pritchard - 0.9.0 +- [puppetsync] Updates for Puppet 8 + - These updates may include the following: + - Update Gemfile + - Add support for Puppet 8 + - Drop support for Puppet 6 + - Update module dependencies + * Wed Aug 23 2023 Steven Pritchard - 0.8.0 - Add AlmaLinux 8 support diff --git a/Gemfile b/Gemfile index 57fca16..e74c3da 100644 --- a/Gemfile +++ b/Gemfile @@ -4,28 +4,28 @@ # This file is automatically updated as part of a puppet module baseline. # The next baseline sync will overwrite any local changes made to this file. # ------------------------------------------------------------------------------ -gem_sources = ENV.fetch('GEM_SERVERS','https://rubygems.org').split(/[, ]+/) +gem_sources = ENV.fetch('GEM_SERVERS', 'https://rubygems.org').split(%r{[, ]+}) ENV['PDK_DISABLE_ANALYTICS'] ||= 'true' gem_sources.each { |gem_source| source gem_source } group :test do - puppet_version = ENV['PUPPET_VERSION'] || '~> 7' - major_puppet_version = puppet_version.scan(/(\d+)(?:\.|\Z)/).flatten.first.to_i - gem 'rake' - gem 'puppet', puppet_version - gem 'rspec' - gem 'rspec-puppet' + puppet_version = ENV.fetch('PUPPET_VERSION', ['>= 7', '< 9']) + major_puppet_version = Array(puppet_version).first.scan(%r{(\d+)(?:\.|\Z)}).flatten.first.to_i gem 'hiera-puppet-helper' - gem 'puppetlabs_spec_helper' gem 'metadata-json-lint' - gem 'puppet-strings' - gem 'puppet-lint-trailing_comma-check', :require => false - gem 'simp-rspec-puppet-facts', ENV['SIMP_RSPEC_PUPPET_FACTS_VERSION'] || '~> 3.1' - gem 'simp-rake-helpers', ENV['SIMP_RAKE_HELPERS_VERSION'] || ['>= 5.12.1', '< 6'] - gem( 'pdk', ENV['PDK_VERSION'] || '~> 2.0', :require => false) if major_puppet_version > 5 gem 'pathspec', '~> 0.2' if Gem::Requirement.create('< 2.6').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem('pdk', ENV.fetch('PDK_VERSION', ['>= 2.0', '< 4.0']), require: false) if major_puppet_version > 5 + gem 'puppet', puppet_version + gem 'puppetlabs_spec_helper' + gem 'puppet-lint-trailing_comma-check', require: false + gem 'puppet-strings' + gem 'rake' + gem 'rspec' + gem 'rspec-puppet' + gem 'simp-rake-helpers', ENV.fetch('SIMP_RAKE_HELPERS_VERSION', ['>= 5.21.0', '< 6']) + gem 'simp-rspec-puppet-facts', ENV.fetch('SIMP_RSPEC_PUPPET_FACTS_VERSION', '~> 3.7') end group :development do @@ -35,21 +35,21 @@ group :development do end group :system_tests do + gem 'bcrypt_pbkdf' gem 'beaker' gem 'beaker-rspec' - gem 'simp-beaker-helpers', ENV['SIMP_BEAKER_HELPERS_VERSION'] || ['>= 1.28.0', '< 2'] - gem 'bcrypt_pbkdf' + gem 'simp-beaker-helpers', ENV.fetch('SIMP_BEAKER_HELPERS_VERSION', ['>= 1.32.1', '< 2']) end # Evaluate extra gemfiles if they exist extra_gemfiles = [ - ENV['EXTRA_GEMFILE'] || '', + ENV.fetch('EXTRA_GEMFILE', ''), "#{__FILE__}.project", "#{__FILE__}.local", File.join(Dir.home, '.gemfile'), ] extra_gemfiles.each do |gemfile| if File.file?(gemfile) && File.readable?(gemfile) - eval(File.read(gemfile), binding) + eval(File.read(gemfile), binding) # rubocop:disable Security/Eval end end diff --git a/REFERENCE.md b/REFERENCE.md index c916b9e..58ff6ad 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -1301,7 +1301,13 @@ Default value: `35` ##### `expire` -Data type: `Optional[String]` +Data type: + +```puppet +Optional[ + Pattern[/^\d{4}-\d{2}-\d{2}$/] + ] +``` diff --git a/manifests/useradd.pp b/manifests/useradd.pp index 82d3fba..a32e8af 100644 --- a/manifests/useradd.pp +++ b/manifests/useradd.pp @@ -15,13 +15,13 @@ Integer $group = 100, Stdlib::AbsolutePath $home = '/home', Integer $inactive = 35, - Optional[String] $expire = undef, + Optional[ + Pattern[/^\d{4}-\d{2}-\d{2}$/] + ] $expire = undef, Stdlib::AbsolutePath $shell = '/bin/bash', Stdlib::AbsolutePath $skel = '/etc/skel', Boolean $create_mail_spool = true, ) { - if !empty($expire) { validate_re($expire,'^\d{4}-\d{2}-\d{2}$') } - file { '/etc/default/useradd': owner => 'root', group => 'root', @@ -29,4 +29,3 @@ content => template('useradd/etc/default/useradd.erb') } } - diff --git a/metadata.json b/metadata.json index 007cfc5..3ba2518 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "simp-useradd", - "version": "0.8.0", + "version": "0.9.0", "author": "SIMP Team", "summary": "A SIMP puppet module for managing settings regarding users and user creation", "license": "Apache-2.0", @@ -23,15 +23,15 @@ "dependencies": [ { "name": "simp/simplib", - "version_requirement": ">= 3.9.0 < 5.0.0" + "version_requirement": ">= 4.9.0 < 5.0.0" }, { "name": "puppetlabs/stdlib", - "version_requirement": ">= 8.0.0 < 9.0.0" + "version_requirement": ">= 8.0.0 < 10.0.0" }, { "name": "puppet/systemd", - "version_requirement": ">= 4.0.2 < 6.0.0" + "version_requirement": ">= 4.0.2 < 7.0.0" } ], "operatingsystem_support": [ @@ -72,7 +72,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 6.22.1 < 8.0.0" + "version_requirement": ">= 7.0.0 < 9.0.0" } ] } diff --git a/spec/classes/useradd_spec.rb b/spec/classes/useradd_spec.rb index 738f5d4..09dd7c0 100644 --- a/spec/classes/useradd_spec.rb +++ b/spec/classes/useradd_spec.rb @@ -50,7 +50,7 @@ it { expect { is_expected.to compile - }.to raise_error(/"#{exp}" does not match/) + }.to raise_error(/got '#{exp}'/) } end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4b32264..5137490 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -99,7 +99,7 @@ def set_hieradata(hieradata) c.mock_with :mocha c.module_path = File.join(fixture_path, 'modules') - c.manifest_dir = File.join(fixture_path, 'manifests') + c.manifest_dir = File.join(fixture_path, 'manifests') if c.respond_to?(:manifest_dir) c.hiera_config = File.join(fixture_path,'hieradata','hiera.yaml')