diff --git a/.gitignore b/.gitignore index 2767022c..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 @@ -25,3 +25,4 @@ .project .envrc /inventory.yaml +/spec/fixtures/litmus_inventory.yaml diff --git a/.pdkignore b/.pdkignore index e6215cd0..fe5cdba3 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 @@ -25,18 +25,26 @@ .project .envrc /inventory.yaml -/appveyor.yml +/spec/fixtures/litmus_inventory.yaml /.fixtures.yml /Gemfile /.gitattributes +/.github/ /.gitignore -/.gitlab-ci.yml /.pdkignore +/.puppet-lint.rc /Rakefile /rakelib/ /.rspec -/.rubocop.yml -/.travis.yml +/..yml /.yardopts /spec/ /.vscode/ +/.sync.yml +/.devcontainer/ +/.*.yml +/pdk.yaml +/.pmtignore +/.git* +/.editorconfig +/provision.yaml diff --git a/.puppet-lint.rc b/.puppet-lint.rc index cc96ece0..b4372aaf 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1 +1,5 @@ --relative +--no-parameter_types-check +--no-parameter_documentation-check +--no-documentation-check +--no-140chars-check diff --git a/.rubocop.yml b/.rubocop.yml index 5307849e..f653becb 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,12 +1,12 @@ --- require: +- rubocop-performance - rubocop-rspec -- rubocop-i18n AllCops: DisplayCopNames: true - TargetRubyVersion: '2.1' + TargetRubyVersion: '2.6' Include: - - "./**/*.rb" + - "**/*.rb" Exclude: - bin/* - ".vendor/**/*" @@ -18,16 +18,10 @@ AllCops: - "**/Puppetfile" - "**/Vagrantfile" - "**/Guardfile" -Metrics/LineLength: + NewCops: enable +Layout/LineLength: Description: People have wide screens, use them. Max: 200 -GetText: - Enabled: false -GetText/DecorateString: - Description: We don't want to decorate test output. - Exclude: - - spec/**/* - Enabled: false RSpec/BeforeAfterAll: Description: Beware of using after(:all) as it may cause state to leak between tests. A necessary evil in acceptance testing. @@ -36,14 +30,13 @@ RSpec/BeforeAfterAll: RSpec/HookArgument: Description: Prefer explicit :each argument, matching existing module's style EnforcedStyle: each +RSpec/DescribeSymbol: + Exclude: + - spec/unit/facter/**/*.rb Style/BlockDelimiters: Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to be consistent then. EnforcedStyle: braces_for_chaining -Style/BracesAroundHashParameters: - Description: Braces are required by Ruby 2.7. Cop removed from RuboCop v0.80.0. - See https://github.com/rubocop-hq/rubocop/pull/7643 - Enabled: true Style/ClassAndModuleChildren: Description: Compact style reduces the required amount of indentation. EnforcedStyle: compact @@ -72,7 +65,7 @@ Style/TrailingCommaInArguments: Description: Prefer always trailing comma on multiline argument lists. This makes diffs, and re-ordering nicer. EnforcedStyleForMultiline: comma -Style/TrailingCommaInLiteral: +Style/TrailingCommaInArrayLiteral: Description: Prefer always trailing comma on multiline literals. This makes diffs, and re-ordering nicer. EnforcedStyleForMultiline: comma @@ -87,26 +80,176 @@ Style/Documentation: - spec/**/* Style/WordArray: EnforcedStyle: brackets +Performance/AncestorsInclude: + Enabled: true +Performance/BigDecimalWithNumericArgument: + Enabled: true +Performance/BlockGivenWithExplicitBlock: + Enabled: true +Performance/CaseWhenSplat: + Enabled: true +Performance/ConstantRegexp: + Enabled: true +Performance/MethodObjectAsBlock: + Enabled: true +Performance/RedundantSortBlock: + Enabled: true +Performance/RedundantStringChars: + Enabled: true +Performance/ReverseFirst: + Enabled: true +Performance/SortReverse: + Enabled: true +Performance/Squeeze: + Enabled: true +Performance/StringInclude: + Enabled: true +Performance/Sum: + Enabled: true Style/CollectionMethods: Enabled: true Style/MethodCalledOnDoEndBlock: Enabled: true Style/StringMethods: Enabled: true -GetText/DecorateFunctionMessage: +Bundler/GemFilename: Enabled: false -GetText/DecorateStringFormattingUsingInterpolation: +Bundler/InsecureProtocolSource: Enabled: false -GetText/DecorateStringFormattingUsingPercent: +Capybara/CurrentPathExpectation: + Enabled: false +Capybara/VisibilityMatcher: + Enabled: false +Gemspec/DuplicatedAssignment: + Enabled: false +Gemspec/OrderedDependencies: + Enabled: false +Gemspec/RequiredRubyVersion: + Enabled: false +Gemspec/RubyVersionGlobalsUsage: + Enabled: false +Layout/ArgumentAlignment: + Enabled: false +Layout/BeginEndAlignment: + Enabled: false +Layout/ClosingHeredocIndentation: + Enabled: false +Layout/EmptyComment: + Enabled: false +Layout/EmptyLineAfterGuardClause: + Enabled: false +Layout/EmptyLinesAroundArguments: + Enabled: false +Layout/EmptyLinesAroundAttributeAccessor: Enabled: false Layout/EndOfLine: Enabled: false -Layout/IndentHeredoc: +Layout/FirstArgumentIndentation: + Enabled: false +Layout/HashAlignment: + Enabled: false +Layout/HeredocIndentation: + Enabled: false +Layout/LeadingEmptyLines: + Enabled: false +Layout/SpaceAroundMethodCallOperator: + Enabled: false +Layout/SpaceInsideArrayLiteralBrackets: + Enabled: false +Layout/SpaceInsideReferenceBrackets: + Enabled: false +Lint/BigDecimalNew: + Enabled: false +Lint/BooleanSymbol: + Enabled: false +Lint/ConstantDefinitionInBlock: + Enabled: false +Lint/DeprecatedOpenSSLConstant: + Enabled: false +Lint/DisjunctiveAssignmentInConstructor: + Enabled: false +Lint/DuplicateElsifCondition: + Enabled: false +Lint/DuplicateRequire: + Enabled: false +Lint/DuplicateRescueException: + Enabled: false +Lint/EmptyConditionalBody: + Enabled: false +Lint/EmptyFile: + Enabled: false +Lint/ErbNewArguments: + Enabled: false +Lint/FloatComparison: + Enabled: false +Lint/HashCompareByIdentity: + Enabled: false +Lint/IdentityComparison: + Enabled: false +Lint/InterpolationCheck: + Enabled: false +Lint/MissingCopEnableDirective: + Enabled: false +Lint/MixedRegexpCaptureTypes: + Enabled: false +Lint/NestedPercentLiteral: + Enabled: false +Lint/NonDeterministicRequireOrder: + Enabled: false +Lint/OrderedMagicComments: + Enabled: false +Lint/OutOfRangeRegexpRef: + Enabled: false +Lint/RaiseException: + Enabled: false +Lint/RedundantCopEnableDirective: + Enabled: false +Lint/RedundantRequireStatement: + Enabled: false +Lint/RedundantSafeNavigation: + Enabled: false +Lint/RedundantWithIndex: + Enabled: false +Lint/RedundantWithObject: + Enabled: false +Lint/RegexpAsCondition: + Enabled: false +Lint/ReturnInVoidContext: + Enabled: false +Lint/SafeNavigationConsistency: + Enabled: false +Lint/SafeNavigationWithEmpty: + Enabled: false +Lint/SelfAssignment: + Enabled: false +Lint/SendWithMixinArgument: + Enabled: false +Lint/ShadowedArgument: + Enabled: false +Lint/StructNewOverride: + Enabled: false +Lint/ToJSON: + Enabled: false +Lint/TopLevelReturnWithArgument: + Enabled: false +Lint/TrailingCommaInAttributeDeclaration: + Enabled: false +Lint/UnreachableLoop: + Enabled: false +Lint/UriEscapeUnescape: + Enabled: false +Lint/UriRegexp: + Enabled: false +Lint/UselessMethodDefinition: + Enabled: false +Lint/UselessTimes: Enabled: false Metrics/AbcSize: Enabled: false Metrics/BlockLength: Enabled: false +Metrics/BlockNesting: + Enabled: false Metrics/ClassLength: Enabled: false Metrics/CyclomaticComplexity: @@ -119,19 +262,463 @@ Metrics/ParameterLists: Enabled: false Metrics/PerceivedComplexity: Enabled: false +Migration/DepartmentName: + Enabled: false +Naming/AccessorMethodName: + Enabled: false +Naming/BlockParameterName: + Enabled: false +Naming/HeredocDelimiterCase: + Enabled: false +Naming/HeredocDelimiterNaming: + Enabled: false +Naming/MemoizedInstanceVariableName: + Enabled: false +Naming/MethodParameterName: + Enabled: false +Naming/RescuedExceptionsVariableName: + Enabled: false +Naming/VariableNumber: + Enabled: false +Performance/BindCall: + Enabled: false +Performance/DeletePrefix: + Enabled: false +Performance/DeleteSuffix: + Enabled: false +Performance/InefficientHashSearch: + Enabled: false +Performance/UnfreezeString: + Enabled: false +Performance/UriDefaultParser: + Enabled: false +RSpec/Be: + Enabled: false +RSpec/Capybara/FeatureMethods: + Enabled: false +RSpec/ContainExactly: + Enabled: false +RSpec/ContextMethod: + Enabled: false +RSpec/ContextWording: + Enabled: false RSpec/DescribeClass: Enabled: false +RSpec/EmptyHook: + Enabled: false +RSpec/EmptyLineAfterExample: + Enabled: false +RSpec/EmptyLineAfterExampleGroup: + Enabled: false +RSpec/EmptyLineAfterHook: + Enabled: false RSpec/ExampleLength: Enabled: false -RSpec/MessageExpectation: +RSpec/ExampleWithoutDescription: + Enabled: false +RSpec/ExpectChange: + Enabled: false +RSpec/ExpectInHook: + Enabled: false +RSpec/FactoryBot/AttributeDefinedStatically: + Enabled: false +RSpec/FactoryBot/CreateList: + Enabled: false +RSpec/FactoryBot/FactoryClassName: + Enabled: false +RSpec/HooksBeforeExamples: + Enabled: false +RSpec/ImplicitBlockExpectation: + Enabled: false +RSpec/ImplicitSubject: + Enabled: false +RSpec/LeakyConstantDeclaration: + Enabled: false +RSpec/LetBeforeExamples: + Enabled: false +RSpec/MatchArray: + Enabled: false +RSpec/MissingExampleGroupArgument: Enabled: false RSpec/MultipleExpectations: Enabled: false +RSpec/MultipleMemoizedHelpers: + Enabled: false +RSpec/MultipleSubjects: + Enabled: false RSpec/NestedGroups: Enabled: false -Style/AsciiComments: +RSpec/PredicateMatcher: + Enabled: false +RSpec/ReceiveCounts: + Enabled: false +RSpec/ReceiveNever: + Enabled: false +RSpec/RepeatedExampleGroupBody: + Enabled: false +RSpec/RepeatedExampleGroupDescription: + Enabled: false +RSpec/RepeatedIncludeExample: + Enabled: false +RSpec/ReturnFromStub: + Enabled: false +RSpec/SharedExamples: + Enabled: false +RSpec/StubbedMock: + Enabled: false +RSpec/UnspecifiedException: + Enabled: false +RSpec/VariableDefinition: + Enabled: false +RSpec/VoidExpect: + Enabled: false +RSpec/Yield: + Enabled: false +Security/Open: + Enabled: false +Style/AccessModifierDeclarations: + Enabled: false +Style/AccessorGrouping: + Enabled: false +Style/BisectedAttrAccessor: + Enabled: false +Style/CaseLikeIf: + Enabled: false +Style/ClassEqualityComparison: + Enabled: false +Style/ColonMethodDefinition: + Enabled: false +Style/CombinableLoops: + Enabled: false +Style/CommentedKeyword: + Enabled: false +Style/Dir: + Enabled: false +Style/DoubleCopDisableDirective: + Enabled: false +Style/EmptyBlockParameter: + Enabled: false +Style/EmptyLambdaParameter: + Enabled: false +Style/Encoding: + Enabled: false +Style/EvalWithLocation: + Enabled: false +Style/ExpandPathArguments: + Enabled: false +Style/ExplicitBlockArgument: + Enabled: false +Style/ExponentialNotation: + Enabled: false +Style/FloatDivision: + Enabled: false +Style/FrozenStringLiteralComment: + Enabled: false +Style/GlobalStdStream: + Enabled: false +Style/HashAsLastArrayItem: + Enabled: false +Style/HashLikeCase: + Enabled: false +Style/HashTransformKeys: + Enabled: false +Style/HashTransformValues: Enabled: false Style/IfUnlessModifier: Enabled: false +Style/KeywordParametersOrder: + Enabled: false +Style/MinMax: + Enabled: false +Style/MixinUsage: + Enabled: false +Style/MultilineWhenThen: + Enabled: false +Style/NegatedUnless: + Enabled: false +Style/NumericPredicate: + Enabled: false +Style/OptionalBooleanParameter: + Enabled: false +Style/OrAssignment: + Enabled: false +Style/RandomWithOffset: + Enabled: false +Style/RedundantAssignment: + Enabled: false +Style/RedundantCondition: + Enabled: false +Style/RedundantConditional: + Enabled: false +Style/RedundantFetchBlock: + Enabled: false +Style/RedundantFileExtensionInRequire: + Enabled: false +Style/RedundantRegexpCharacterClass: + Enabled: false +Style/RedundantRegexpEscape: + Enabled: false +Style/RedundantSelfAssignment: + Enabled: false +Style/RedundantSort: + Enabled: false +Style/RescueStandardError: + Enabled: false +Style/SingleArgumentDig: + Enabled: false +Style/SlicingWithRange: + Enabled: false +Style/SoleNestedConditional: + Enabled: false +Style/StderrPuts: + Enabled: false +Style/StringConcatenation: + Enabled: false +Style/Strip: + Enabled: false Style/SymbolProc: Enabled: false +Style/TrailingBodyOnClass: + Enabled: false +Style/TrailingBodyOnMethodDefinition: + Enabled: false +Style/TrailingBodyOnModule: + Enabled: false +Style/TrailingCommaInHashLiteral: + Enabled: false +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 c6ff6c37..31e39a46 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,14 +1,23 @@ -Gemfile: - required: - ':system_tests': - - gem: 'puppet-module-posix-system-r#{minor_version}' - platforms: ruby - - gem: 'puppet-module-win-system-r#{minor_version}' - platforms: - - mswin - - mingw - - x64_mingw - - gem: 'nokogiri' - platforms: ruby - - gem: 'serverspec' - platforms: ruby +--- +.rubocop.yml: + default_configs: + AllCops: + NewCops: enable +.pdkignore: + paths: + - /.*.yml + - /pdk.yaml + - /.pmtignore + - /.git* + - /.editorconfig + - /provision.yaml +Rakefile: + default_disabled_lint_checks: + - relative + - parameter_types + - parameter_documentation + - documentation + - 140chars +spec/spec_helper.rb: + coverage_report: true + minimum_code_coverage_percentage: 100 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0aaaef2b..00000000 --- a/.travis.yml +++ /dev/null @@ -1,53 +0,0 @@ ---- -os: linux -dist: xenial -language: ruby -cache: bundler -before_install: - - bundle -v - - rm -f Gemfile.lock - - "# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner" - - "# See https://github.com/puppetlabs/pdk-templates/commit/705154d5c437796b821691b707156e1b056d244f for an example of how this was used" - - "# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set" - - '[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION' - - gem --version - - bundle -v -script: - - 'bundle exec rake $CHECK' -bundler_args: --without system_tests -rvm: - - 2.5.7 -stages: - - static - - spec - - acceptance - - - if: tag =~ ^v\d - name: deploy -jobs: - fast_finish: true - include: - - - env: CHECK="check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint" - stage: static - - - env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec - rvm: 2.4.5 - stage: spec - - - env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec - rvm: 2.5.7 - stage: spec - - - env: PUPPET_GEM_VERSION="~> 7.0" CHECK=parallel_spec - rvm: 2.7.2 - stage: spec - - - env: DEPLOY_TO_FORGE=yes - stage: deploy -branches: - only: - - master - - /^v\d/ -notifications: - email: false diff --git a/Gemfile b/Gemfile index 0d3a975d..ca0e773e 100644 --- a/Gemfile +++ b/Gemfile @@ -13,27 +13,37 @@ def location_for(place_or_version, fake_version = nil) end end -ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments -minor_version = ruby_version_segments[0..1].join('.') - group :development do - gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') - gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') - gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') - gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') - gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - 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 "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-posix-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby] - gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby] - gem "puppet-module-win-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-win-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw] + 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 "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 "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.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] end group :system_tests do - gem "puppet-module-posix-system-r#{minor_version}", '~> 0.5', require: false, platforms: [:ruby] - gem "puppet-module-win-system-r#{minor_version}", '~> 0.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "nokogiri", require: false, platforms: [:ruby] - gem "serverspec", require: false, platforms: [:ruby] + gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] + gem "serverspec", '~> 2.41', 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'] @@ -50,16 +60,6 @@ gems['puppet'] = location_for(puppet_version) gems['facter'] = location_for(facter_version) if facter_version gems['hiera'] = location_for(hiera_version) if hiera_version -if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)} - # If we're using a Puppet gem on Windows which handles its own win32-xxx gem - # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445). - gems['win32-dir'] = ['<= 0.4.9', require: false] - gems['win32-eventlog'] = ['<= 0.6.5', require: false] - gems['win32-process'] = ['<= 0.7.5', require: false] - gems['win32-security'] = ['<= 0.2.5', require: false] - gems['win32-service'] = ['0.8.8', require: false] -end - gems.each do |gem_name, gem_params| gem gem_name, *gem_params end diff --git a/Rakefile b/Rakefile index cb7ed0cc..1763bb6a 100644 --- a/Rakefile +++ b/Rakefile @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? +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 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? -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' def changelog_user return unless Rake.application.top_level_tasks.include? "changelog" @@ -41,8 +41,13 @@ def changelog_future_release end PuppetLint.configuration.send('disable_relative') +PuppetLint.configuration.send('disable_parameter_types') +PuppetLint.configuration.send('disable_parameter_documentation') +PuppetLint.configuration.send('disable_documentation') +PuppetLint.configuration.send('disable_140chars') -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}" @@ -52,7 +57,7 @@ if Bundler.rubygems.find_name('github_changelog_generator').any? 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; GO LABEL THEM" + config.merge_prefix = "### UNCATEGORIZED PRS; LABEL THEM ON GITHUB" config.configure_sections = { "Changed" => { "prefix" => "### Changed", @@ -60,11 +65,11 @@ if Bundler.rubygems.find_name('github_changelog_generator').any? }, "Added" => { "prefix" => "### Added", - "labels" => ["feature", "enhancement"], + "labels" => ["enhancement", "feature"], }, "Fixed" => { "prefix" => "### Fixed", - "labels" => ["bugfix"], + "labels" => ["bug", "documentation", "bugfix"], }, } end @@ -72,16 +77,15 @@ else desc 'Generate a Changelog from GitHub' task :changelog do raise <= Gem::Version.new('2.2.2')" + version: '~> 1.15' + condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0')" EOM end end diff --git a/lib/puppet/util/puppetdb_validator.rb b/lib/puppet/util/puppetdb_validator.rb index 8cd360d0..5cb966b7 100644 --- a/lib/puppet/util/puppetdb_validator.rb +++ b/lib/puppet/util/puppetdb_validator.rb @@ -63,6 +63,6 @@ def attempt_connection end rescue StandardError => e log_error(e.message) - return false + false end end diff --git a/manifests/database/default_read_grant.pp b/manifests/database/default_read_grant.pp index 80d798b1..fea87f96 100644 --- a/manifests/database/default_read_grant.pp +++ b/manifests/database/default_read_grant.pp @@ -1,12 +1,12 @@ # Private class. Grant read permissions to $database_read_only_username by default, for new tables created by # $database_username. -define puppetdb::database::default_read_grant( +define puppetdb::database::default_read_grant ( String $database_name, String $schema, String $database_username, String $database_read_only_username, ) { - postgresql_psql {"grant default select permission for ${database_read_only_username}": + postgresql_psql { "grant default select permission for ${database_read_only_username}": db => $database_name, command => "ALTER DEFAULT PRIVILEGES FOR USER \"${database_username}\" @@ -23,7 +23,7 @@ AND nspname = '${schema}'", } - postgresql_psql {"grant default usage permission for ${database_read_only_username}": + postgresql_psql { "grant default usage permission for ${database_read_only_username}": db => $database_name, command => "ALTER DEFAULT PRIVILEGES FOR USER \"${database_username}\" @@ -40,7 +40,7 @@ AND nspname = '${schema}'", } - postgresql_psql {"grant default execute permission for ${database_read_only_username}": + postgresql_psql { "grant default execute permission for ${database_read_only_username}": db => $database_name, command => "ALTER DEFAULT PRIVILEGES FOR USER \"${database_username}\" diff --git a/manifests/database/postgresql.pp b/manifests/database/postgresql.pp index 62da6464..00f8c42b 100644 --- a/manifests/database/postgresql.pp +++ b/manifests/database/postgresql.pp @@ -19,14 +19,13 @@ $read_database_password = $puppetdb::params::read_database_password, $read_database_host = $puppetdb::params::read_database_host ) inherits puppetdb::params { - if $manage_server { - class { '::postgresql::globals': + class { 'postgresql::globals': manage_package_repo => $manage_package_repo, version => $postgres_version, } # get the pg server up and running - class { '::postgresql::server': + class { 'postgresql::server': ip_mask_allow_all_users => '0.0.0.0/0', listen_addresses => $listen_addresses, port => scanf($database_port, '%i')[0], @@ -35,7 +34,7 @@ # We need to create the ssl connection for the read user, when # manage_database is set to true, or when read_database_host is defined. # Otherwise we don't create it. - if $manage_database or $read_database_host != undef{ + if $manage_database or $read_database_host != undef { $create_read_user_rule = true } else { $create_read_user_rule = false @@ -52,15 +51,14 @@ postgresql_ssl_key_path => $postgresql_ssl_key_path, postgresql_ssl_cert_path => $postgresql_ssl_cert_path, postgresql_ssl_ca_cert_path => $postgresql_ssl_ca_cert_path, - create_read_user_rule => $create_read_user_rule + create_read_user_rule => $create_read_user_rule, } } # Only install pg_trgm extension, if database it is actually managed by the module if $manage_database { - # get the pg contrib to use pg_trgm extension - class { '::postgresql::server::contrib': } + class { 'postgresql::server::contrib': } postgresql::server::extension { 'pg_trgm': database => $database_name, @@ -97,7 +95,7 @@ read_database_username => $read_database_username, database_name => $database_name, password_hash => postgresql::postgresql_password($read_database_username, $read_database_password), - database_owner => $database_username + database_owner => $database_username, } -> postgresql_psql { "grant ${read_database_username} role to ${database_username}": diff --git a/manifests/database/postgresql_ssl_rules.pp b/manifests/database/postgresql_ssl_rules.pp index 56b48395..a217d612 100644 --- a/manifests/database/postgresql_ssl_rules.pp +++ b/manifests/database/postgresql_ssl_rules.pp @@ -13,7 +13,7 @@ address => '0.0.0.0/0', auth_method => 'cert', order => 0, - auth_option => "map=${identity_map_key} clientcert=1" + auth_option => "map=${identity_map_key} clientcert=1", } postgresql::server::pg_hba_rule { "Allow certificate mapped connections to ${database_name} as ${database_username} (ipv6)": @@ -23,7 +23,7 @@ address => '::0/0', auth_method => 'cert', order => 0, - auth_option => "map=${identity_map_key} clientcert=1" + auth_option => "map=${identity_map_key} clientcert=1", } postgresql::server::pg_ident_rule { "Map the SSL certificate of the server as a ${database_username} user": diff --git a/manifests/database/ssl_configuration.pp b/manifests/database/ssl_configuration.pp index 0d2473c6..a5c085e5 100644 --- a/manifests/database/ssl_configuration.pp +++ b/manifests/database/ssl_configuration.pp @@ -31,25 +31,25 @@ postgresql::server::config_entry { 'ssl': ensure => present, value => 'on', - require => [File['postgres private key'], File['postgres public key']] + require => [File['postgres private key'], File['postgres public key']], } postgresql::server::config_entry { 'ssl_cert_file': ensure => present, value => "${postgresql::server::datadir}/server.crt", - require => [File['postgres private key'], File['postgres public key']] + require => [File['postgres private key'], File['postgres public key']], } postgresql::server::config_entry { 'ssl_key_file': ensure => present, value => "${postgresql::server::datadir}/server.key", - require => [File['postgres private key'], File['postgres public key']] + require => [File['postgres private key'], File['postgres public key']], } postgresql::server::config_entry { 'ssl_ca_file': ensure => present, value => $postgresql_ssl_ca_cert_path, - require => [File['postgres private key'], File['postgres public key']] + require => [File['postgres private key'], File['postgres public key']], } puppetdb::database::postgresql_ssl_rules { "Configure postgresql ssl rules for ${database_username}": diff --git a/manifests/globals.pp b/manifests/globals.pp index d28304a8..f703db60 100644 --- a/manifests/globals.pp +++ b/manifests/globals.pp @@ -3,10 +3,8 @@ $version = 'present', $database = 'postgres', Stdlib::Absolutepath $puppet_confdir = $settings::confdir, - ) { - +) { if !(fact('os.family') in ['RedHat', 'Suse', 'Archlinux', 'Debian', 'OpenBSD', 'FreeBSD']) { fail("${module_name} does not support your osfamily ${fact('os.family')}") } - } diff --git a/manifests/init.pp b/manifests/init.pp index c999441d..5160ed6b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -91,8 +91,7 @@ Integer[1] $dlo_max_age = $puppetdb::params::dlo_max_age, Optional[Stdlib::Absolutepath] $java_bin = $puppetdb::params::java_bin, ) inherits puppetdb::params { - - class { '::puppetdb::server': + class { 'puppetdb::server': listen_address => $listen_address, listen_port => $listen_port, disable_cleartext => $disable_cleartext, @@ -176,14 +175,15 @@ } if ($database == 'postgres') { - $database_before = str2bool($database_validate) ? { - false => Class['::puppetdb::server'], - default => [Class['::puppetdb::server'], - Class['::puppetdb::server::validate_db']], + false => Class['puppetdb::server'], + default => [ + Class['puppetdb::server'], + Class['puppetdb::server::validate_db'] + ], } - class { '::puppetdb::database::postgresql': + class { 'puppetdb::database::postgresql': listen_addresses => $database_listen_address, database_name => $database_name, puppetdb_server => $puppetdb_server, @@ -201,7 +201,7 @@ read_database_username => $read_database_username, read_database_password => $read_database_password, read_database_host => $read_database_host, - before => $database_before + before => $database_before, } } } diff --git a/manifests/master/config.pp b/manifests/master/config.pp index 7463ed3e..eb9fb1d9 100644 --- a/manifests/master/config.pp +++ b/manifests/master/config.pp @@ -2,14 +2,14 @@ class puppetdb::master::config ( $puppetdb_server = fact('networking.fqdn'), $puppetdb_port = defined(Class['puppetdb']) ? { - true => $::puppetdb::disable_ssl ? { + true => $puppetdb::disable_ssl ? { true => 8080, default => 8081, }, default => 8081, }, $puppetdb_disable_ssl = defined(Class['puppetdb']) ? { - true => $::puppetdb::disable_ssl, + true => $puppetdb::disable_ssl, default => false, }, $masterless = $puppetdb::params::masterless, @@ -30,7 +30,6 @@ $test_url = $puppetdb::params::test_url, $restart_puppet = true, ) inherits puppetdb::params { - # **WARNING**: Ugly hack to work around a yum bug with metadata parsing. This # should not be copied, replicated or even looked at. In short, never rename # your packages... @@ -66,7 +65,6 @@ } if ($strict_validation) { - # Validate the puppetdb connection. If we can't connect to puppetdb then we # *must* not perform the other configuration steps, or else @@ -192,5 +190,4 @@ Class['puppetdb::master::report_processor'] ~> Service[$puppet_service_name] } } - } diff --git a/manifests/master/puppetdb_conf.pp b/manifests/master/puppetdb_conf.pp index a3dd72fc..3cf8d706 100644 --- a/manifests/master/puppetdb_conf.pp +++ b/manifests/master/puppetdb_conf.pp @@ -12,8 +12,7 @@ /(puppetdb-terminus)/ => true, default => false, }, - ) inherits puppetdb::params { - +) inherits puppetdb::params { Ini_setting { ensure => present, section => 'main', diff --git a/manifests/master/report_processor.pp b/manifests/master/report_processor.pp index f97130bd..4002d596 100644 --- a/manifests/master/report_processor.pp +++ b/manifests/master/report_processor.pp @@ -5,7 +5,6 @@ $masterless = $puppetdb::params::masterless, $enable = false ) inherits puppetdb::params { - if $masterless { $puppet_conf_section = 'main' } else { diff --git a/manifests/master/routes.pp b/manifests/master/routes.pp index fcdda80a..87435b06 100644 --- a/manifests/master/routes.pp +++ b/manifests/master/routes.pp @@ -5,7 +5,6 @@ $masterless = $puppetdb::params::masterless, $routes = undef, ) inherits puppetdb::params { - if $masterless { $routes_real = { 'apply' => { @@ -16,8 +15,8 @@ 'facts' => { 'terminus' => 'facter', 'cache' => 'puppetdb_apply', - } - } + }, + }, } } elsif $routes { $routes_real = $routes @@ -32,8 +31,8 @@ 'facts' => { 'terminus' => 'puppetdb', 'cache' => $default_fact_cache, - } - } + }, + }, } } diff --git a/manifests/master/storeconfigs.pp b/manifests/master/storeconfigs.pp index cb46cc09..a547e517 100644 --- a/manifests/master/storeconfigs.pp +++ b/manifests/master/storeconfigs.pp @@ -5,7 +5,6 @@ $masterless = $puppetdb::params::masterless, $enable = true, ) inherits puppetdb::params { - if $masterless { $puppet_conf_section = 'main' } else { diff --git a/manifests/params.pp b/manifests/params.pp index a57afa7f..f813596e 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -208,7 +208,7 @@ $certificate_whitelist_file = "${etcdir}/certificate-whitelist" # the default is free access for now - $certificate_whitelist = [ ] + $certificate_whitelist = [] # change to this to only allow access by the puppet master by default: #$certificate_whitelist = [ $::servername ] diff --git a/manifests/server.pp b/manifests/server.pp index b9def8af..6ec90c88 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -81,7 +81,6 @@ Integer[1] $dlo_max_age = $puppetdb::params::dlo_max_age, Optional[Stdlib::Absolutepath] $java_bin = $puppetdb::params::java_bin, ) inherits puppetdb::params { - # Apply necessary suffix if zero is specified. # Can we drop this in the next major release? if $node_ttl == '0' { @@ -263,21 +262,21 @@ if $postgresql_ssl_on { exec { $ssl_key_pk8_path: - path => [ '/opt/puppetlabs/puppet/bin', $facts['path'] ], + path => ['/opt/puppetlabs/puppet/bin', $facts['path']], command => "openssl pkcs8 -topk8 -inform PEM -outform DER -in ${ssl_key_path} -out ${ssl_key_pk8_path} -nocrypt", # Generate a .pk8 key if one doesn't exist or is older than the .pem input. # NOTE: bash file time checks, like -ot, can't always discern sub-second # differences. onlyif => "test ! -e '${ssl_key_pk8_path}' -o '${ssl_key_pk8_path}' -ot '${ssl_key_path}'", - before => File[$ssl_key_pk8_path] + before => File[$ssl_key_pk8_path], } file { $ssl_key_pk8_path: - ensure => present, + ensure => file, owner => $puppetdb_user, group => $puppetdb_group, mode => '0600', - notify => Service[$puppetdb_service] + notify => Service[$puppetdb_service], } } @@ -324,7 +323,7 @@ setting => 'JAVA_ARGS', require => Package[$puppetdb_package], notify => Service[$puppetdb_service], - })) + })) } else { ini_setting { 'java_args': ensure => present, @@ -357,14 +356,14 @@ # https://puppet.com/docs/puppetdb/5.2/maintain_and_tune.html#clean-up-the-dead-letter-office systemd::unit_file { 'puppetdb-dlo-cleanup.service': content => epp("${module_name}/puppetdb-DLO-cleanup.service.epp", { - 'puppetdb_user' => $puppetdb_user, - 'puppetdb_group' => $puppetdb_group, - 'vardir' => $vardir, - 'dlo_max_age' => $dlo_max_age + 'puppetdb_user' => $puppetdb_user, + 'puppetdb_group' => $puppetdb_group, + 'vardir' => $vardir, + 'dlo_max_age' => $dlo_max_age }), } -> systemd::unit_file { 'puppetdb-dlo-cleanup.timer': - content => epp("${module_name}/puppetdb-DLO-cleanup.timer.epp", {'cleanup_timer_interval' => $cleanup_timer_interval }), + content => epp("${module_name}/puppetdb-DLO-cleanup.timer.epp", { 'cleanup_timer_interval' => $cleanup_timer_interval }), enable => true, active => true, } diff --git a/manifests/server/command_processing.pp b/manifests/server/command_processing.pp index 6d05e562..7a3cd2a3 100644 --- a/manifests/server/command_processing.pp +++ b/manifests/server/command_processing.pp @@ -6,7 +6,6 @@ $temp_usage = $puppetdb::params::temp_usage, $confdir = $puppetdb::params::confdir, ) inherits puppetdb::params { - $config_ini = "${confdir}/config.ini" # Set the defaults diff --git a/manifests/server/database.pp b/manifests/server/database.pp index 12dff9ff..d541a1e4 100644 --- a/manifests/server/database.pp +++ b/manifests/server/database.pp @@ -30,7 +30,6 @@ $ssl_key_pk8_path = $puppetdb::params::ssl_key_pk8_path, $ssl_ca_cert_path = $puppetdb::params::ssl_ca_cert_path ) inherits puppetdb::params { - if str2bool($database_validate) { # Validate the database connection. If we can't connect, we want to fail # and skip the rest of the configuration, so that we don't leave puppetdb @@ -69,15 +68,13 @@ path => $database_ini, ensure => present, section => 'database', - require => $ini_setting_require + require => $ini_setting_require, } if $database == 'embedded' { - $classname = 'org.hsqldb.jdbcDriver' $subprotocol = 'hsqldb' $subname = "file:${database_embedded_path};hsqldb.tx=mvcc;sql.syntax_pgs=true" - } elsif $database == 'postgres' { $classname = 'org.postgresql.Driver' $subprotocol = 'postgresql' @@ -91,8 +88,7 @@ $subname_default = "//${database_host}:${database_port}/${database_name}${database_suffix}" - if $postgresql_ssl_on and !empty($jdbc_ssl_properties) - { + if $postgresql_ssl_on and !empty($jdbc_ssl_properties) { fail("Variables 'postgresql_ssl_on' and 'jdbc_ssl_properties' can not be used at the same time!") } diff --git a/manifests/server/global.pp b/manifests/server/global.pp index f03f281f..874601a8 100644 --- a/manifests/server/global.pp +++ b/manifests/server/global.pp @@ -4,7 +4,6 @@ $confdir = $puppetdb::params::confdir, $puppetdb_group = $puppetdb::params::puppetdb_group, ) inherits puppetdb::params { - $config_ini = "${confdir}/config.ini" file { $config_ini: diff --git a/manifests/server/jetty.pp b/manifests/server/jetty.pp index ea050faf..bb155ec3 100644 --- a/manifests/server/jetty.pp +++ b/manifests/server/jetty.pp @@ -17,7 +17,6 @@ $puppetdb_user = $puppetdb::params::puppetdb_user, $puppetdb_group = $puppetdb::params::puppetdb_group, ) inherits puppetdb::params { - $jetty_ini = "${confdir}/jetty.ini" file { $jetty_ini: @@ -70,7 +69,6 @@ } if $ssl_protocols { - ini_setting { 'puppetdb_sslprotocols': ensure => $ssl_setting_ensure, setting => 'ssl-protocols', @@ -79,7 +77,6 @@ } if $cipher_suites { - ini_setting { 'puppetdb_cipher-suites': ensure => $ssl_setting_ensure, setting => 'cipher-suites', diff --git a/manifests/server/puppetdb.pp b/manifests/server/puppetdb.pp index 54fa4d2d..b77e48a9 100644 --- a/manifests/server/puppetdb.pp +++ b/manifests/server/puppetdb.pp @@ -7,7 +7,6 @@ $puppetdb_user = $puppetdb::params::puppetdb_user, $puppetdb_group = $puppetdb::params::puppetdb_group, ) inherits puppetdb::params { - $puppetdb_ini = "${confdir}/puppetdb.ini" file { $puppetdb_ini: @@ -31,7 +30,7 @@ } # accept connections only from puppet master - ini_setting {'puppetdb-connections-from-master-only': + ini_setting { 'puppetdb-connections-from-master-only': ensure => $certificate_whitelist_setting_ensure, section => 'puppetdb', setting => 'certificate-whitelist', diff --git a/manifests/server/read_database.pp b/manifests/server/read_database.pp index 688a74fe..e3407b7d 100644 --- a/manifests/server/read_database.pp +++ b/manifests/server/read_database.pp @@ -22,7 +22,6 @@ $ssl_key_pk8_path = $puppetdb::params::ssl_key_pk8_path, $ssl_ca_cert_path = $puppetdb::params::ssl_ca_cert_path ) inherits puppetdb::params { - if $read_database_host != undef { if str2bool($database_validate) { # Validate the database connection. If we can't connect, we want to fail @@ -78,18 +77,17 @@ $subname_default = "//${read_database_host}:${read_database_port}/${read_database_name}${database_suffix}" - if $postgresql_ssl_on and !empty($jdbc_ssl_properties) - { + if $postgresql_ssl_on and !empty($jdbc_ssl_properties) { fail("Variables 'postgresql_ssl_on' and 'jdbc_ssl_properties' can not be used at the same time!") } if $postgresql_ssl_on { $subname = @("EOT"/L) - ${subname_default}?\ - ssl=true&sslfactory=org.postgresql.ssl.LibPQFactory&\ - sslmode=verify-full&sslrootcert=${ssl_ca_cert_path}&\ - sslkey=${ssl_key_pk8_path}&sslcert=${ssl_cert_path}\ - | EOT + ${subname_default}?\ + ssl=true&sslfactory=org.postgresql.ssl.LibPQFactory&\ + sslmode=verify-full&sslrootcert=${ssl_ca_cert_path}&\ + sslkey=${ssl_key_pk8_path}&sslcert=${ssl_cert_path}\ + | EOT } else { $subname = $subname_default } diff --git a/manifests/server/validate_db.pp b/manifests/server/validate_db.pp index cf2e5b41..faa06410 100644 --- a/manifests/server/validate_db.pp +++ b/manifests/server/validate_db.pp @@ -8,7 +8,6 @@ $database_name = $puppetdb::params::database_name, $jdbc_ssl_properties = $puppetdb::params::jdbc_ssl_properties, ) inherits puppetdb::params { - # We don't need any validation for the embedded database, presumably. if ( $database == 'postgres' and diff --git a/manifests/server/validate_read_db.pp b/manifests/server/validate_read_db.pp index d857676d..bbf19986 100644 --- a/manifests/server/validate_read_db.pp +++ b/manifests/server/validate_read_db.pp @@ -8,7 +8,6 @@ $database_name = $puppetdb::params::database_name, $jdbc_ssl_properties = $puppetdb::params::jdbc_ssl_properties, ) inherits puppetdb::params { - # Currently we only support postgres if ( $database == 'postgres' and diff --git a/metadata.json b/metadata.json index 9c222262..a9d3d359 100644 --- a/metadata.json +++ b/metadata.json @@ -78,11 +78,11 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 4.10.0 < 9.0.0" + "version_requirement": ">= 7.0.0 < 9.0.0" } ], "description": "Module for installing/configuring PuppetDB", - "pdk-version": "1.18.0", - "template-url": "https://github.com/puppetlabs/pdk-templates#1.18.0", - "template-ref": "tags/1.18.0-0-g095317c" + "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/pdk.yaml b/pdk.yaml new file mode 100644 index 00000000..4bef4bd0 --- /dev/null +++ b/pdk.yaml @@ -0,0 +1,2 @@ +--- +ignore: [] diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb index a17cb9c9..f50db3ec 100644 --- a/spec/acceptance/basic_spec.rb +++ b/spec/acceptance/basic_spec.rb @@ -7,7 +7,7 @@ # No point diagnosing any more if the module wasn't copied properly shell('ls /etc/puppetlabs/code/modules/puppetdb') do |r| r.exit_code.should be_zero - r.stdout.should =~ %r{metadata\.json} + r.stdout.should contain 'metadata.json' r.stderr.should == '' end end diff --git a/spec/default_facts.yml b/spec/default_facts.yml index f777abfc..3346c394 100644 --- a/spec/default_facts.yml +++ b/spec/default_facts.yml @@ -2,7 +2,8 @@ # # Facts specified here will override the values provided by rspec-puppet-facts. --- -ipaddress: "172.16.254.254" -ipaddress6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" +networking: + ip: "172.16.254.254" + ip6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" + mac: "AA:AA:AA:AA:AA:AA" is_pe: false -macaddress: "AA:AA:AA:AA:AA:AA" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d3778cac..61df2940 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,9 @@ # frozen_string_literal: true +RSpec.configure do |c| + c.mock_with :rspec +end + require 'puppetlabs_spec_helper/module_spec_helper' require 'rspec-puppet-facts' @@ -21,8 +25,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 @@ -42,6 +46,19 @@ end c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] c.after(:suite) do + RSpec::Puppet::Coverage.report!(100) + end + + # Filter backtrace noise + backtrace_exclusion_patterns = [ + %r{spec_helper}, + %r{gems}, + ] + + if c.respond_to?(:backtrace_exclusion_patterns) + c.backtrace_exclusion_patterns = backtrace_exclusion_patterns + elsif c.respond_to?(:backtrace_clean_patterns) + c.backtrace_clean_patterns = backtrace_exclusion_patterns end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 0b734325..e664ea74 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -60,11 +60,11 @@ def build_url(platform) end hosts.each do |host| - if host['platform'] =~ %r{debian} + if host['platform'].include? 'debian' on host, 'echo \'export PATH=/var/lib/gems/1.8/bin/:${PATH}\' >> ~/.bashrc' end # install_puppet - if host['platform'] =~ %r{el-(5|6|7|8)} + if host['platform'].match? %r{el-(5|6|7|8)} relver = Regexp.last_match(1) on host, "rpm -ivh #{build_url('el')}#{relver}.noarch.rpm" on host, 'yum install -y puppetserver' @@ -77,11 +77,11 @@ def build_url(platform) on host, 'dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm' on host, 'dnf -qy module disable postgresql' end - elsif host['platform'] =~ %r{fedora-(\d+)} + elsif host['platform'].match? %r{fedora-(\d+)} relver = Regexp.last_match(1) on host, "rpm -ivh #{build_url('fedora')}#{relver}.noarch.rpm" on host, 'yum install -y puppetserver' - elsif host['platform'] =~ %r{(ubuntu|debian)} + elsif host['platform'].match? %r{(ubuntu|debian)} unless host.check_for_package 'curl' on host, 'apt-get install -y curl' end @@ -121,7 +121,7 @@ def build_url(platform) 'puppet7' end install_puppet_agent_on(hosts, opts) unless ENV['BEAKER_provision'] == 'no' -install_ca_certs unless ENV['PUPPET_INSTALL_TYPE'] =~ %r{pe}i +install_ca_certs unless ENV['PUPPET_INSTALL_TYPE'].match? %r{pe}i install_module_on(hosts) install_module_dependencies_on(hosts) @@ -129,7 +129,7 @@ def build_url(platform) # Readable test descriptions c.formatter = :documentation hosts.each do |host| - if host[:platform] =~ %r{el-7-x86_64} && host[:hypervisor] =~ %r{docker} + if host[:platform].include?('el-7-x86_64') && host[:hypervisor].include?('docker') on(host, "sed -i '/nodocs/d' /etc/yum.conf") end end