From 61b5a748297b3126eaf9720ab8e654a70f5037ed Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Wed, 10 Jan 2024 11:27:49 -0800 Subject: [PATCH 1/2] Update to PDK template 3.0.1 This commit updates this module from PDK template 2.7.5 to 3.0.1. In addition to the boilerplate changes, this commit also: - Updates the "auto release" GitHub Action to "release prep," reflecting upstream change (puppetlabs/pdk-templates@c3f57b7). - Removes the github_changelog_generator and concurrent-ruby gems, which were previously needed for the release process but are no longer necessary in newer release processes in the PDK template. - Disables the puppet_url_without_modules lint check in sync.yml. - Adds the Vox acceptance Rake task to .sync.yml. --- .../{auto_release.yml => release_prep.yml} | 2 +- .gitignore | 2 +- .pdkignore | 9 +- .puppet-lint.rc | 1 + .rubocop.yml | 218 +++++++++++++++++- .sync.yml | 17 +- .vscode/extensions.json | 6 + Gemfile | 28 ++- Rakefile | 15 +- metadata.json | 6 +- spec/classes/puppet_agent_spec.rb | 4 +- spec/spec_helper.rb | 5 +- 12 files changed, 264 insertions(+), 49 deletions(-) rename .github/workflows/{auto_release.yml => release_prep.yml} (94%) create mode 100644 .vscode/extensions.json diff --git a/.github/workflows/auto_release.yml b/.github/workflows/release_prep.yml similarity index 94% rename from .github/workflows/auto_release.yml rename to .github/workflows/release_prep.yml index 501dc1ce..bb0b7acc 100644 --- a/.github/workflows/auto_release.yml +++ b/.github/workflows/release_prep.yml @@ -1,4 +1,4 @@ -name: "Auto release" +name: "Release Prep" on: workflow_dispatch: diff --git a/.gitignore b/.gitignore index 988dcbbe..3f155121 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,7 @@ /log/ /pkg/ /spec/fixtures/manifests/ -/spec/fixtures/modules/ +/spec/fixtures/modules/* /tmp/ /vendor/ /convert_report.txt diff --git a/.pdkignore b/.pdkignore index c538bea8..862847a7 100644 --- a/.pdkignore +++ b/.pdkignore @@ -16,7 +16,7 @@ /log/ /pkg/ /spec/fixtures/manifests/ -/spec/fixtures/modules/ +/spec/fixtures/modules/* /tmp/ /vendor/ /convert_report.txt @@ -26,20 +26,17 @@ .envrc /inventory.yaml /spec/fixtures/litmus_inventory.yaml -/appveyor.yml -/.editorconfig /.fixtures.yml /Gemfile /.gitattributes +/.github/ /.gitignore -/.gitlab-ci.yml /.pdkignore /.puppet-lint.rc /Rakefile /rakelib/ /.rspec -/.rubocop.yml -/.travis.yml +/..yml /.yardopts /spec/ /.vscode/ diff --git a/.puppet-lint.rc b/.puppet-lint.rc index cc96ece0..02505e80 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1 +1,2 @@ --relative +--no-puppet_url_without_modules-check diff --git a/.rubocop.yml b/.rubocop.yml index f033404f..5f872545 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,7 +4,7 @@ require: - rubocop-rspec AllCops: DisplayCopNames: true - TargetRubyVersion: '2.5' + TargetRubyVersion: '2.6' Include: - "**/*.rb" Exclude: @@ -37,6 +37,8 @@ Style/BlockDelimiters: be consistent then. EnforcedStyle: braces_for_chaining Style/ClassAndModuleChildren: + Description: Compact style reduces the required amount of indentation. + EnforcedStyle: compact Enabled: false Style/EmptyElse: Description: Enforce against empty else clauses, but allow `nil` for clarity. @@ -114,8 +116,14 @@ Style/MethodCalledOnDoEndBlock: Enabled: true Style/StringMethods: Enabled: true +Bundler/GemFilename: + Enabled: false Bundler/InsecureProtocolSource: Enabled: false +Capybara/CurrentPathExpectation: + Enabled: false +Capybara/VisibilityMatcher: + Enabled: false Gemspec/DuplicatedAssignment: Enabled: false Gemspec/OrderedDependencies: @@ -290,11 +298,9 @@ Performance/UriDefaultParser: Enabled: false RSpec/Be: Enabled: false -RSpec/Capybara/CurrentPathExpectation: - Enabled: false RSpec/Capybara/FeatureMethods: Enabled: false -RSpec/Capybara/VisibilityMatcher: +RSpec/ContainExactly: Enabled: false RSpec/ContextMethod: Enabled: false @@ -334,6 +340,8 @@ RSpec/LeakyConstantDeclaration: Enabled: false RSpec/LetBeforeExamples: Enabled: false +RSpec/MatchArray: + Enabled: false RSpec/MissingExampleGroupArgument: Enabled: false RSpec/MultipleExpectations: @@ -376,8 +384,6 @@ Style/AccessModifierDeclarations: Enabled: false Style/AccessorGrouping: Enabled: false -Style/AsciiComments: - Enabled: false Style/BisectedAttrAccessor: Enabled: false Style/CaseLikeIf: @@ -488,35 +494,235 @@ Style/TrailingMethodEndStatement: Enabled: false Style/UnpackFirst: Enabled: false +Capybara/MatchStyle: + Enabled: false +Capybara/NegationMatcher: + Enabled: false +Capybara/SpecificActions: + Enabled: false +Capybara/SpecificFinders: + Enabled: false +Capybara/SpecificMatcher: + Enabled: false +Gemspec/DeprecatedAttributeAssignment: + Enabled: false +Gemspec/DevelopmentDependencies: + Enabled: false +Gemspec/RequireMFA: + Enabled: false +Layout/LineContinuationLeadingSpace: + Enabled: false +Layout/LineContinuationSpacing: + Enabled: false +Layout/LineEndStringConcatenationIndentation: + Enabled: false +Layout/SpaceBeforeBrackets: + Enabled: false +Lint/AmbiguousAssignment: + Enabled: false +Lint/AmbiguousOperatorPrecedence: + Enabled: false +Lint/AmbiguousRange: + Enabled: false +Lint/ConstantOverwrittenInRescue: + Enabled: false +Lint/DeprecatedConstants: + Enabled: false Lint/DuplicateBranch: Enabled: false +Lint/DuplicateMagicComment: + Enabled: false Lint/DuplicateRegexpCharacterClassElement: Enabled: false Lint/EmptyBlock: Enabled: false Lint/EmptyClass: Enabled: false +Lint/EmptyInPattern: + Enabled: false +Lint/IncompatibleIoSelectWithFiberScheduler: + Enabled: false +Lint/LambdaWithoutLiteralBlock: + Enabled: false Lint/NoReturnInBeginEndBlocks: Enabled: false +Lint/NonAtomicFileOperation: + Enabled: false +Lint/NumberedParameterAssignment: + Enabled: false +Lint/OrAssignmentToConstant: + Enabled: false +Lint/RedundantDirGlobSort: + Enabled: false +Lint/RefinementImportMethods: + Enabled: false +Lint/RequireRangeParentheses: + Enabled: false +Lint/RequireRelativeSelfPath: + Enabled: false +Lint/SymbolConversion: + Enabled: false Lint/ToEnumArguments: Enabled: false +Lint/TripleQuotes: + Enabled: false Lint/UnexpectedBlockArity: Enabled: false Lint/UnmodifiedReduceAccumulator: Enabled: false +Lint/UselessRescue: + Enabled: false +Lint/UselessRuby2Keywords: + Enabled: false +Metrics/CollectionLiteralLength: + Enabled: false +Naming/BlockForwarding: + Enabled: false Performance/CollectionLiteralInLoop: Enabled: false +Performance/ConcurrentMonotonicTime: + Enabled: false +Performance/MapCompact: + Enabled: false +Performance/RedundantEqualityComparisonBlock: + Enabled: false +Performance/RedundantSplitRegexpArgument: + Enabled: false +Performance/StringIdentifierArgument: + Enabled: false +RSpec/BeEq: + Enabled: false +RSpec/BeNil: + Enabled: false +RSpec/ChangeByZero: + Enabled: false +RSpec/ClassCheck: + Enabled: false +RSpec/DuplicatedMetadata: + Enabled: false +RSpec/ExcessiveDocstringSpacing: + Enabled: false +RSpec/FactoryBot/ConsistentParenthesesStyle: + Enabled: false +RSpec/FactoryBot/FactoryNameStyle: + Enabled: false +RSpec/FactoryBot/SyntaxMethods: + Enabled: false +RSpec/IdenticalEqualityAssertion: + Enabled: false +RSpec/NoExpectationExample: + Enabled: false +RSpec/PendingWithoutReason: + Enabled: false +RSpec/Rails/AvoidSetupHook: + Enabled: false +RSpec/Rails/HaveHttpStatus: + Enabled: false +RSpec/Rails/InferredSpecType: + Enabled: false +RSpec/Rails/MinitestAssertions: + Enabled: false +RSpec/Rails/TravelAround: + Enabled: false +RSpec/RedundantAround: + Enabled: false +RSpec/SkipBlockInsideExample: + Enabled: false +RSpec/SortMetadata: + Enabled: false +RSpec/SubjectDeclaration: + Enabled: false +RSpec/VerifiedDoubleReference: + Enabled: false +Security/CompoundHash: + Enabled: false +Security/IoMethods: + Enabled: false Style/ArgumentsForwarding: Enabled: false +Style/ArrayIntersect: + Enabled: false Style/CollectionCompact: Enabled: false +Style/ComparableClamp: + Enabled: false +Style/ConcatArrayLiterals: + Enabled: false +Style/DirEmpty: + Enabled: false Style/DocumentDynamicEvalDefinition: Enabled: false +Style/EmptyHeredoc: + Enabled: false +Style/EndlessMethod: + Enabled: false +Style/EnvHome: + Enabled: false +Style/FetchEnvVar: + Enabled: false +Style/FileEmpty: + Enabled: false +Style/FileRead: + Enabled: false +Style/FileWrite: + Enabled: false +Style/HashConversion: + Enabled: false +Style/HashExcept: + Enabled: false +Style/IfWithBooleanLiteralBranches: + Enabled: false +Style/InPatternThen: + Enabled: false +Style/MagicCommentFormat: + Enabled: false +Style/MapCompactWithConditionalBlock: + Enabled: false +Style/MapToHash: + Enabled: false +Style/MapToSet: + Enabled: false +Style/MinMaxComparison: + Enabled: false +Style/MultilineInPatternThen: + Enabled: false Style/NegatedIfElseCondition: Enabled: false +Style/NestedFileDirname: + Enabled: false Style/NilLambda: Enabled: false +Style/NumberedParameters: + Enabled: false +Style/NumberedParametersLimit: + Enabled: false +Style/ObjectThen: + Enabled: false +Style/OpenStructUse: + Enabled: false +Style/OperatorMethodCall: + Enabled: false +Style/QuotedSymbols: + Enabled: false Style/RedundantArgument: Enabled: false +Style/RedundantConstantBase: + Enabled: false +Style/RedundantDoubleSplatHashBraces: + Enabled: false +Style/RedundantEach: + Enabled: false +Style/RedundantHeredocDelimiterQuotes: + Enabled: false +Style/RedundantInitialize: + Enabled: false +Style/RedundantSelfAssignmentBranch: + Enabled: false +Style/RedundantStringEscape: + Enabled: false +Style/SelectByRegexp: + Enabled: false +Style/StringChars: + Enabled: false Style/SwapValues: Enabled: false diff --git a/.sync.yml b/.sync.yml index 2f3ef267..d67689f1 100644 --- a/.sync.yml +++ b/.sync.yml @@ -28,11 +28,7 @@ Gemfile: - gem: beaker-puppet from_env: BEAKER_PUPPET_VERSION version: '~> 1.22' - - gem: github_changelog_generator - version: '= 1.16.4' - gem: beaker-module_install_helper - - gem: concurrent-ruby - version: '= 1.1.10' - gem: beaker-puppet_install_helper - gem: nokogiri - gem: 'bolt' @@ -46,19 +42,26 @@ Gemfile: ":system_tests": - gem: voxpupuli-acceptance version: '~> 1.0' + appveyor.yml: delete: true .travis.yml: delete: true -.github/workflows/auto_release.yml: - unmanaged: false .github/workflows/release.yml: unmanaged: false +.github/workflows/release_prep.yml: + unmanaged: false .gitlab-ci.yml: delete: true spec/default_facts.yml: delete: true spec/spec_helper.rb: unmanaged: true +# puppet_url_without modules check in puppet-lint assumes any puppet:/// URL is +# using the module mount. pe_packages is a custom mount and doesn't need +# modules. Rakefile: - changelog_since_tag: 'v4.13.0' + extra_disabled_lint_checks: + - puppet_url_without_modules + requires: + - voxpupuli/acceptance/rake diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..2f1e4f73 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "puppet.puppet-vscode", + "rebornix.Ruby" + ] +} diff --git a/Gemfile b/Gemfile index 36e9aacb..40d56771 100644 --- a/Gemfile +++ b/Gemfile @@ -19,20 +19,22 @@ group :development do 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 "voxpupuli-puppet-lint-plugins", '~> 4.0', require: false + 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 "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false gem "facterdb", '~> 1.18', require: false - gem "metadata-json-lint", '>= 2.0.2', '< 4.0.0', require: false - gem "puppetlabs_spec_helper", '~> 5.0', 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 "dependency_checker", '~> 0.2', require: false + 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 "puppet-debugger", '~> 1.0', require: false - gem "rubocop", '= 1.6.1', require: false - gem "rubocop-performance", '= 1.9.1', require: false - gem "rubocop-rspec", '= 2.0.1', require: false + gem "rubocop", '= 1.48.1', require: false + gem "rubocop-performance", '= 1.16.0', require: false + gem "rubocop-rspec", '= 2.19.0', require: false + gem "puppet-strings", '~> 4.0', require: false gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 4.30') gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.9') @@ -41,9 +43,7 @@ group :development do gem "beaker-hostgenerator" gem "beaker-rspec" gem "beaker-puppet", *location_for(ENV['BEAKER_PUPPET_VERSION'] || '~> 1.22') - gem "github_changelog_generator", '= 1.16.4', require: false gem "beaker-module_install_helper", require: false - gem "concurrent-ruby", '= 1.1.10', require: false gem "beaker-puppet_install_helper", require: false gem "nokogiri", require: false gem "bolt", '~> 3.0', require: false if ENV["GEM_BOLT"] @@ -51,9 +51,13 @@ group :development do gem "async", '~> 1.30', require: false end group :system_tests do - gem "serverspec", '~> 2.41', require: false - gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] - gem "voxpupuli-acceptance", '~> 1.0' + gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] + gem "serverspec", '~> 2.41', require: false + gem "voxpupuli-acceptance", '~> 1.0', require: false +end +group :release_prep do + gem "puppet-strings", '~> 4.0', require: false + gem "puppetlabs_spec_helper", '~> 6.0', require: false end puppet_version = ENV['PUPPET_GEM_VERSION'] diff --git a/Rakefile b/Rakefile index f5d84bed..fac9fb85 100644 --- a/Rakefile +++ b/Rakefile @@ -1,18 +1,13 @@ # frozen_string_literal: true require 'bundler' -require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? +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 Bundler.rubygems.find_name('github_changelog_generator').any? -require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any? +require 'github_changelog_generator/task' if Gem.loaded_specs.key? 'github_changelog_generator' +require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings' require 'voxpupuli/acceptance/rake' -# puppet_url_without modules check in puppet-lint assumes any puppet:/// URL is -# using the module mount. pe_packages is a custom mount and doesn't need -# modules. -PuppetLint.configuration.send('disable_puppet_url_without_modules') - def changelog_user return unless Rake.application.top_level_tasks.include? "changelog" returnVal = nil || JSON.load(File.read('metadata.json'))['author'] @@ -47,14 +42,14 @@ def changelog_future_release end PuppetLint.configuration.send('disable_relative') +PuppetLint.configuration.send('disable_puppet_url_without_modules') -if Bundler.rubygems.find_name('github_changelog_generator').any? +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.since_tag = "v4.13.0" 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)." diff --git a/metadata.json b/metadata.json index 5181658a..4410c45c 100644 --- a/metadata.json +++ b/metadata.json @@ -75,7 +75,7 @@ "version_requirement": ">= 5.0.0 < 9.0.0" } ], - "pdk-version": "3.0.0", - "template-url": "https://github.com/puppetlabs/pdk-templates#2.7.5", - "template-ref": "tags/2.7.5-0-ge5b0114" + "pdk-version": "3.0.1", + "template-url": "https://github.com/puppetlabs/pdk-templates#3.0.1", + "template-ref": "tags/3.0.1-0-gd13288a" } diff --git a/spec/classes/puppet_agent_spec.rb b/spec/classes/puppet_agent_spec.rb index eadc5eff..943c0791 100644 --- a/spec/classes/puppet_agent_spec.rb +++ b/spec/classes/puppet_agent_spec.rb @@ -203,7 +203,9 @@ def global_facts(facts, os) context 'package_version is same as master when set to auto' do let(:params) { { package_version: 'auto' } } - let(:node_params) { { serverversion: '7.6.5' } } + let(:facts) do + global_facts(facts, os).merge(serverversion: '7.6.5') + end before :each do allow(Puppet::FileSystem).to receive(:exist?).and_call_original diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index aa08bfc1..2f64f1d1 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -22,8 +22,8 @@ next unless File.exist?(f) && File.readable?(f) && File.size?(f) begin - default_facts.merge!(YAML.safe_load(File.read(f), [], [], true)) - rescue => e + default_facts.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 end @@ -43,6 +43,7 @@ end c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] c.after(:suite) do + RSpec::Puppet::Coverage.report!(0) end # Filter backtrace noise From ad4b749a47f4a6eaf6bdd4658171db1ccf3dad5b Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Wed, 10 Jan 2024 11:39:46 -0800 Subject: [PATCH 2/2] Rubocop fixes This commit addresses Rubocop offenses from: - Performance/StringInclude - Style/TernaryParentheses --- acceptance/helpers.rb | 4 ++-- spec/classes/puppet_agent_spec.rb | 14 +++++++------- spec/spec_helper_acceptance.rb | 2 +- task_spec/spec/acceptance/init_spec.rb | 8 ++++---- tasks/facts_diff.rb | 2 +- tasks/run.rb | 4 ++-- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/acceptance/helpers.rb b/acceptance/helpers.rb index 66f1863d..f56cdab0 100644 --- a/acceptance/helpers.rb +++ b/acceptance/helpers.rb @@ -334,7 +334,7 @@ def wait_for_installation_pid(host) return end - unless %r{windows}.match?(host['platform']) + unless host['platform'].include?('windows') step '(Agent) waiting for upgrade pid file to be created...' do retry_on(host, "cat #{upgrade_pidfile}", { max_retries: 5, retry_interval: 2 }) end @@ -355,7 +355,7 @@ def remove_installed_agent(host) end step "Teardown: (Agent) Uninstall the puppet-agent package on agent #{host_to_info_s(host)}" do - if %r{windows}.match?(host['platform']) + if host['platform'].include?('windows') install_dir = on(host, 'facter.bat env_windows_installdir').output.tr('\\', '/').chomp scp_to(host, "#{SUPPORTING_FILES}/uninstall.ps1", 'uninstall.ps1') on(host, 'rm -rf C:/ProgramData/PuppetLabs') diff --git a/spec/classes/puppet_agent_spec.rb b/spec/classes/puppet_agent_spec.rb index 943c0791..bdf47f1c 100644 --- a/spec/classes/puppet_agent_spec.rb +++ b/spec/classes/puppet_agent_spec.rb @@ -26,7 +26,7 @@ def redhat_familly_supported_os def global_facts(facts, os) facts.merge( - if %r{sles}.match?(os) + if os.include?('sles') { is_pe: true, env_temp_variable: '/tmp', @@ -36,17 +36,17 @@ def global_facts(facts, os) { env_temp_variable: '/tmp', } - elsif %r{solaris}.match?(os) + elsif os.include?('solaris') { is_pe: true, puppet_agent_pid: 298, } - elsif %r{aix}.match?(os) + elsif os.include?('aix') { is_pe: true, platform_tag: "aix-#{AIX_VERSION[facts.dig(:os, 'release', 'major')]}-power", } - elsif %r{windows}.match?(os) + elsif os.include?('windows') { puppet_agent_appdata: 'C:\\ProgramData', puppet_confdir: 'C:\\ProgramData\\Puppetlabs\\puppet\\etc', @@ -291,7 +291,7 @@ def global_facts(facts, os) end let(:expected_package_install_options) do - if %r{aix}.match?(os) + if os.include?('aix') ['--ignoreos', 'OPTION1=value1', 'OPTION2=value2'] else ['OPTION1=value1', 'OPTION2=value2'] @@ -307,7 +307,7 @@ def global_facts(facts, os) it { is_expected.to contain_package('puppet-agent') .with_install_options(expected_package_install_options) } end - if %r{solaris-10}.match?(os) + if os.include?('solaris-10') it do is_expected.to contain_exec('solaris_install script') .with_command( @@ -349,7 +349,7 @@ def global_facts(facts, os) it { is_expected.to contain_package('puppet-agent').with_ensure(package_version) } end - unless %r{windows}.match?(os) + unless os.include?('windows') unless %r{sles|solaris|aix}.match?(os) it { is_expected.to contain_class('puppet_agent::service').that_requires('Class[puppet_agent::configure]') } end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 73783b93..bafa5704 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -130,7 +130,7 @@ def teardown_puppet_on(host) clean_repo = '' end - if %r{windows}.match?(host['platform']) + if host['platform'].include?('windows') install_dir = on(host, 'facter.bat env_windows_installdir').output.tr('\\', '/').chomp scp_to host, "#{TEST_FILES}/uninstall.ps1", 'uninstall.ps1' on host, 'rm -rf C:/ProgramData/PuppetLabs' diff --git a/task_spec/spec/acceptance/init_spec.rb b/task_spec/spec/acceptance/init_spec.rb index 26558e22..31af1b26 100644 --- a/task_spec/spec/acceptance/init_spec.rb +++ b/task_spec/spec/acceptance/init_spec.rb @@ -19,7 +19,7 @@ def bolt_config def bolt_inventory host_data = hosts_to_inventory host_data['targets'].each do |node_data| - node_data['config']['winrm']['connect-timeout'] = 120 if %r{win}.match?(target_platform) + node_data['config']['winrm']['connect-timeout'] = 120 if target_platform.include?('win') end host_data @@ -97,7 +97,7 @@ def log_output_errors(result) # extra request is needed on windows hosts # this will fail with "execution expired" - run_task('puppet_agent::version', 'target', {}) if %r{win}.match?(target_platform) + run_task('puppet_agent::version', 'target', {}) if target_platform.include?('win') # Test the agent isn't already installed and that the version task works results = run_task('puppet_agent::version', 'target', {}) @@ -131,7 +131,7 @@ def log_output_errors(result) end # Check that puppet agent service has been stopped due to 'stop_service' parameter set to true - service = if %r{win}.match?(target_platform) + service = if target_platform.include?('win') run_command('c:/"program files"/"puppet labs"/puppet/bin/puppet resource service puppet', 'target') else run_command('/opt/puppetlabs/bin/puppet resource service puppet', 'target') @@ -190,7 +190,7 @@ def log_output_errors(result) end # Puppet Agent can't be upgraded on Windows nodes while 'puppet agent' service or 'pxp-agent' service are running - if %r{win}.match?(target_platform) + if target_platform.include?('win') # Try to upgrade from puppet6 to puppet7 but fail due to puppet agent service already running results = run_task('puppet_agent::install', 'target', { 'collection' => 'puppet7', 'version' => 'latest' }) results.each do |res| diff --git a/tasks/facts_diff.rb b/tasks/facts_diff.rb index 4582dd10..2980fcda 100755 --- a/tasks/facts_diff.rb +++ b/tasks/facts_diff.rb @@ -49,7 +49,7 @@ def run run_result = Puppet::Util::Execution.execute(command, options) minified_run_result = run_result.delete("\n").delete(' ') - minified_run_result == '{}' ? 'No differences found' : run_result + (minified_run_result == '{}') ? 'No differences found' : run_result end private diff --git a/tasks/run.rb b/tasks/run.rb index 664bd860..95e55c08 100755 --- a/tasks/run.rb +++ b/tasks/run.rb @@ -138,11 +138,11 @@ def config_print(*keys) end def noop(params) - params['noop'] == true ? '--noop' : '' + (params['noop'] == true) ? '--noop' : '' end def environment(params) - params['environment'].length > 1 ? "--environment=#{params['environment']}" : '' + (params['environment'].length > 1) ? "--environment=#{params['environment']}" : '' end # Attempts to run the Puppet agent, returning the mtime for the last run report