diff --git a/.fixtures.yml b/.fixtures.yml index 5c67151b0..439569681 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -4,6 +4,4 @@ fixtures: "cron_core": "https://github.com/puppetlabs/puppetlabs-cron_core.git" "facts": "https://github.com/puppetlabs/puppetlabs-facts.git" "provision": "https://github.com/puppetlabs/provision.git" - puppet_agent: - repo: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git' - ref: v4.21.0 + "puppet_agent": "https://github.com/puppetlabs/puppetlabs-puppet_agent.git" diff --git a/.puppet-lint.rc b/.puppet-lint.rc index f01626d45..e7fe02efc 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1,3 +1,11 @@ +--fail-on-warnings --relative +--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 --no-anchor_resource-check --no-params_empty_string_assignment-check diff --git a/.rubocop.yml b/.rubocop.yml index 1b2b97111..fca0437aa 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,7 +6,7 @@ require: AllCops: NewCops: enable DisplayCopNames: true - TargetRubyVersion: '2.6' + TargetRubyVersion: 3.1 Include: - "**/*.rb" Exclude: diff --git a/Gemfile b/Gemfile index 2d8e1608b..be41c6273 100644 --- a/Gemfile +++ b/Gemfile @@ -14,34 +14,35 @@ 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", '~> 2.1', 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 "rspec-puppet-facts", '~> 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.9', require: false - gem "puppet-debugger", '~> 1.0', require: false + gem "puppet-debugger", '~> 1.6', 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 "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "rexml", '>= 3.3.9', require: false + gem "bigdecimal", '< 3.2.2', require: false, platforms: [:mswin, :mingw, :x64_mingw] end group :development, :release_prep do gem "puppet-strings", '~> 4.0', require: false - gem "puppetlabs_spec_helper", '~> 7.0', require: false + gem "puppetlabs_spec_helper", '~> 8.0', require: false end group :system_tests do - gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] + gem "puppet_litmus", '~> 2.0', require: false, platforms: [:ruby, :x64_mingw] if !ENV['PUPPET_FORGE_TOKEN'].to_s.empty? + gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] if ENV['PUPPET_FORGE_TOKEN'].to_s.empty? gem "CFPropertyList", '< 3.0.7', require: false, platforms: [:mswin, :mingw, :x64_mingw] gem "serverspec", '~> 2.41', require: false end @@ -52,12 +53,20 @@ hiera_version = ENV['HIERA_GEM_VERSION'] gems = {} -gems['puppet'] = location_for(puppet_version) +puppet_version = ENV.fetch('PUPPET_GEM_VERSION', nil) +facter_version = ENV.fetch('FACTER_GEM_VERSION', nil) +hiera_version = ENV.fetch('HIERA_GEM_VERSION', nil) -# 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 32f4fa9e1..e5ee87d8b 100644 --- a/Rakefile +++ b/Rakefile @@ -9,3 +9,11 @@ require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings' PuppetLint.configuration.send('disable_relative') PuppetLint.configuration.send('disable_anchor_resource') PuppetLint.configuration.send('disable_params_empty_string_assignment') +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/lib/puppet/provider/mysql.rb b/lib/puppet/provider/mysql.rb index e539d9b9c..55e088df2 100644 --- a/lib/puppet/provider/mysql.rb +++ b/lib/puppet/provider/mysql.rb @@ -141,7 +141,7 @@ def self.mysql_caller(text_of_sql, type) mysql_raw([defaults_file, '-NBe', text_of_sql].flatten.compact).scrub end else - raise Puppet::Error, _("#mysql_caller: Unrecognised type '%{type}'" % { type: type }) + raise Puppet::Error, _("#mysql_caller: Unrecognised type '%{type}'" % { type: }) end end diff --git a/lib/puppet/provider/mysql_database/mysql.rb b/lib/puppet/provider/mysql_database/mysql.rb index 04d95bf76..2b2f1a925 100644 --- a/lib/puppet/provider/mysql_database/mysql.rb +++ b/lib/puppet/provider/mysql_database/mysql.rb @@ -13,7 +13,7 @@ def self.instances k, v = line.split(%r{\s}) attributes[k] = v end - new(name: name, + new(name:, ensure: :present, charset: attributes['character_set_database'], collate: attributes['collation_database']) diff --git a/lib/puppet/provider/mysql_grant/mysql.rb b/lib/puppet/provider/mysql_grant/mysql.rb index 20af17151..9413f0a09 100644 --- a/lib/puppet/provider/mysql_grant/mysql.rb +++ b/lib/puppet/provider/mysql_grant/mysql.rb @@ -99,7 +99,7 @@ def self.instances instance_configs[name] = { privileges: sorted_privileges, - table: table, + table:, user: "#{user}@#{host}", options: options.uniq } @@ -108,7 +108,7 @@ def self.instances instances = [] instance_configs.map do |name, config| instances << new( - name: name, + name:, ensure: :present, privileges: config[:privileges], table: config[:table], diff --git a/lib/puppet/provider/mysql_login_path/inifile.rb b/lib/puppet/provider/mysql_login_path/inifile.rb index 98d23f04e..e0bddfb2f 100644 --- a/lib/puppet/provider/mysql_login_path/inifile.rb +++ b/lib/puppet/provider/mysql_login_path/inifile.rb @@ -30,7 +30,7 @@ class Error < StandardError; end def self.load(filename, opts = {}) return unless File.file? filename - new(opts.merge(filename: filename)) + new(opts.merge(filename:)) end # Get and set the filename diff --git a/lib/puppet/provider/mysql_login_path/mysql_login_path.rb b/lib/puppet/provider/mysql_login_path/mysql_login_path.rb index 76ac829c6..52cf79e58 100644 --- a/lib/puppet/provider/mysql_login_path/mysql_login_path.rb +++ b/lib/puppet/provider/mysql_login_path/mysql_login_path.rb @@ -59,7 +59,7 @@ def mysql_config_editor_cmd(context, uid, *args) Puppet::Util::Execution.execute( args, failonfail: true, - uid: uid, + uid:, custom_environment: { 'HOME' => homedir }, ) end @@ -70,7 +70,7 @@ def my_print_defaults_cmd(context, uid, *args) Puppet::Util::Execution.execute( args, failonfail: true, - uid: uid, + uid:, custom_environment: { 'HOME' => homedir }, ) end diff --git a/lib/puppet/provider/mysql_plugin/mysql.rb b/lib/puppet/provider/mysql_plugin/mysql.rb index 82db9f941..3e3d500c0 100644 --- a/lib/puppet/provider/mysql_plugin/mysql.rb +++ b/lib/puppet/provider/mysql_plugin/mysql.rb @@ -9,7 +9,7 @@ def self.instances mysql_caller('show plugins', 'regular').split("\n").map do |line| name, _status, _type, library, _license = line.split(%r{\t}) - new(name: name, + new(name:, ensure: :present, soname: library) end diff --git a/lib/puppet/provider/mysql_user/mysql.rb b/lib/puppet/provider/mysql_user/mysql.rb index b552a5620..7ab636bd8 100644 --- a/lib/puppet/provider/mysql_user/mysql.rb +++ b/lib/puppet/provider/mysql_user/mysql.rb @@ -34,7 +34,7 @@ def self.instances # https://jira.mariadb.org/browse/MDEV-16238 https://jira.mariadb.org/browse/MDEV-16774 @password = @authentication_string end - new(name: name, + new(name:, ensure: :present, password_hash: @password, plugin: @plugin, diff --git a/metadata.json b/metadata.json index b1aac9944..843c5a973 100644 --- a/metadata.json +++ b/metadata.json @@ -14,77 +14,21 @@ } ], "operatingsystem_support": [ - { - "operatingsystem": "RedHat", - "operatingsystemrelease": [ - "7", - "8", - "9" - ] - }, - { - "operatingsystem": "CentOS", - "operatingsystemrelease": [ - "7", - "8" - ] - }, - { - "operatingsystem": "OracleLinux", - "operatingsystemrelease": [ - "7" - ] - }, - { - "operatingsystem": "Debian", - "operatingsystemrelease": [ - "10", - "11", - "12" - ] - }, - { - "operatingsystem": "Scientific", - "operatingsystemrelease": [ - "7" - ] - }, - { - "operatingsystem": "SLES", - "operatingsystemrelease": [ - "12", - "15" - ] - }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ - "18.04", - "20.04", - "22.04" - ] - }, - { - "operatingsystem": "Rocky", - "operatingsystemrelease": [ - "8" - ] - }, - { - "operatingsystem": "AlmaLinux", - "operatingsystemrelease": [ - "8" + "24.04" ] } ], "requirements": [ { "name": "puppet", - "version_requirement": ">= 7.0.0 < 9.0.0" + "version_requirement": ">= 8.0.0 < 9.0.0" } ], "description": "MySQL module", + "pdk-version": "3.5.0 (ga43db72)", "template-url": "https://github.com/puppetlabs/pdk-templates#main", - "template-ref": "tags/3.2.0.4-0-g5d17ec1", - "pdk-version": "3.2.0" + "template-ref": "heads/main-0-g11c0f3d" } diff --git a/spec/spec_helper_acceptance_local.rb b/spec/spec_helper_acceptance_local.rb index cb41c5d98..c80f4ebfa 100644 --- a/spec/spec_helper_acceptance_local.rb +++ b/spec/spec_helper_acceptance_local.rb @@ -32,6 +32,10 @@ def ubuntu_2204? os[:family] == 'ubuntu' && os[:release].to_f == 22.04 end +def ubuntu_2404? + os[:family] == 'ubuntu' && os[:release].to_f == 24.04 +end + def sles_15? os[:family] == 'sles' && os[:release].to_i == 15 end @@ -41,7 +45,7 @@ def debian_12? end def charset - @charset ||= (debian_12? || ubuntu_2204? || sles_15?) ? 'utf8mb3' : 'utf8' + @charset ||= (ubuntu_2404? || debian_12? || ubuntu_2204? || sles_15?) ? 'utf8mb3' : 'utf8' end def get_db_cmd diff --git a/tasks/export.rb b/tasks/export.rb index 7688633ae..0abf6ce2b 100755 --- a/tasks/export.rb +++ b/tasks/export.rb @@ -12,7 +12,7 @@ def get(file, database, user, password) cmd_string << " --password=#{password}" unless password.nil? cmd_string << " > #{file}" unless file.nil? stdout, stderr, status = Open3.capture3(cmd_string) - raise Puppet::Error, _("stderr: '%{stderr}'" % { stderr: stderr }) if status != 0 + raise Puppet::Error, _("stderr: '%{stderr}'" % { stderr: }) if status != 0 { status: stdout.strip } end diff --git a/tasks/sql.rb b/tasks/sql.rb index aeeec5bea..5b7a317ee 100755 --- a/tasks/sql.rb +++ b/tasks/sql.rb @@ -11,7 +11,7 @@ def get(sql, database, user, password) cmd << "--user=#{user}" unless user.nil? cmd << "--password=#{password}" unless password.nil? stdout, stderr, status = Open3.capture3(*cmd) - raise Puppet::Error, _("stderr: '%{stderr}'" % { stderr: stderr }) if status != 0 + raise Puppet::Error, _("stderr: '%{stderr}'" % { stderr: }) if status != 0 { status: stdout.strip } end