diff --git a/.gitignore b/.gitignore index d67bb69c..e8202815 100644 --- a/.gitignore +++ b/.gitignore @@ -11,11 +11,15 @@ /bin/ /doc/ /Gemfile.local +/Gemfile.lock /junit/ /log/ /pkg/ +/spec/fixtures/manifests/ +/spec/fixtures/modules/* /tmp/ /vendor/ +/.vendor/ /convert_report.txt /update_report.txt spec/fixtures @@ -33,3 +37,11 @@ environments/**/.vagrant .kitchen .vscode + +/spec/fixtures/litmus_inventory.yaml +.resource_types +.modules +.task_cache.json +.plan_cache.json +.rerun.json +bolt-debug.log diff --git a/.pdkignore b/.pdkignore index 12313396..a9d5282b 100644 --- a/.pdkignore +++ b/.pdkignore @@ -16,30 +16,43 @@ /log/ /pkg/ /spec/fixtures/manifests/ -/spec/fixtures/modules/ +/spec/fixtures/modules/* /tmp/ /vendor/ +/.vendor/ /convert_report.txt /update_report.txt .DS_Store .project .envrc /inventory.yaml -/appveyor.yml +/spec/fixtures/litmus_inventory.yaml +.resource_types +.modules +.task_cache.json +.plan_cache.json +.rerun.json +bolt-debug.log /.fixtures.yml /Gemfile /.gitattributes +/.github/ /.gitignore /.gitlab-ci.yml + /.pdkignore +/.puppet-lint.rc /Rakefile /rakelib/ /.rspec /.rubocop.yml /.travis.yml +/..yml /.yardopts /spec/ /.vscode/ +/.sync.yml +/.devcontainer/ /.github/ /.circleci/ /.pre-commit-config.yaml diff --git a/.puppet-lint.rc b/.puppet-lint.rc index 6856ecf3..6b2238bd 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1,3 +1,12 @@ +--fail-on-warnings --relative +--no-80chars-check --no-140chars-check ---fail-on-warnings +--no-class_inherits_from_params_class-check +--no-autoloader_layout-check +--no-parameter_documentation-check +--no-single_quote_string_with_variables-check +--no-params_empty_string_assignment-check +--no-lookup_in_parameter-check +--no-top_scope_facts-check +--ignore-paths=.vendor/**/*.pp,.bundle/**/*.pp,pkg/**/*.pp,spec/**/*.pp,tests/**/*.pp,types/**/*.pp,vendor/**/*.pp diff --git a/.rspec b/.rspec new file mode 100644 index 00000000..16f9cdb0 --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--color +--format documentation diff --git a/.rubocop.yml b/.rubocop.yml index c2c01dd6..21b82b99 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,12 +1,13 @@ --- require: +- rubocop-performance - rubocop-rspec -- rubocop-i18n AllCops: + NewCops: enable DisplayCopNames: true - TargetRubyVersion: '2.1' + TargetRubyVersion: '2.6' Include: - - "./**/*.rb" + - "**/*.rb" Exclude: - bin/* - ".vendor/**/*" @@ -18,16 +19,9 @@ AllCops: - "**/Puppetfile" - "**/Vagrantfile" - "**/Guardfile" -Metrics/LineLength: +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,6 +30,9 @@ 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. @@ -68,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 @@ -83,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 +Bundler/InsecureProtocolSource: + Enabled: false +Capybara/CurrentPathExpectation: Enabled: false -GetText/DecorateStringFormattingUsingInterpolation: +Capybara/VisibilityMatcher: Enabled: false -GetText/DecorateStringFormattingUsingPercent: +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: @@ -115,25 +262,469 @@ 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/SymbolProc: +Style/KeywordParametersOrder: + Enabled: false +Style/MinMax: + Enabled: false +Style/MixinUsage: + Enabled: false +Style/MultilineWhenThen: + Enabled: false +Style/NegatedUnless: Enabled: false Style/NumericPredicate: Enabled: false -Layout/FirstHashElementLineBreak: - Enabled: true -Style/EmptyLiteral: +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/DuplicateMatchPattern: + 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/DataInheritance: + 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/RedundantLineContinuation: + 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/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..6da8d472 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "puppet.puppet-vscode", + "Shopify.ruby-lsp" + ] +} diff --git a/.yardopts b/.yardopts new file mode 100644 index 00000000..29c933bc --- /dev/null +++ b/.yardopts @@ -0,0 +1 @@ +--markup markdown diff --git a/Gemfile b/Gemfile index d803173f..980c57a1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,58 +1,87 @@ -source "https://rubygems.org" +source ENV['GEM_SOURCE'] || 'https://rubygems.org' -ruby_version = Gem::Version.new(RUBY_VERSION.dup) +def location_for(place_or_version, fake_version = nil) + git_url_regex = %r{\A(?(https?|git)[:@][^#]*)(#(?.*))?} + file_url_regex = %r{\Afile:\/\/(?.*)} -# Each version of Puppet recommends a specific version of Ruby. Try to fetch the Puppet version that -# matches our Ruby (unless PUPPET_VERSION is defined). -matching_puppet_version = ruby_version > Gem::Version.new('2.5') ? (ruby_version > Gem::Version.new('2.7') ? '7.0.0' : '6.0.1') : '4.10.2' -puppet_version = ENV.fetch('PUPPET_VERSION', matching_puppet_version) -gem "puppet", "~> #{puppet_version}" - -ruby_version_segments = ruby_version.segments -minor_version = ruby_version_segments[0..1].join('.') + if place_or_version && (git_url = place_or_version.match(git_url_regex)) + [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact + elsif place_or_version && (file_url = place_or_version.match(file_url_regex)) + ['>= 0', { path: File.expand_path(file_url[:path]), require: false }] + else + [place_or_version, { require: false }] + end +end group :development do - gem "rake", "~> 12.3.3" if ruby_version < Gem::Version.new('2.6.0') # last version for ruby < 2.6 - gem "semantic_puppet", '= 1.0.4' - gem "xmlrpc" if ruby_version >= Gem::Version.new('2.3') - gem "concurrent-ruby", '= 1.1.10' if Gem::Requirement.create([' >= 6.9.0', '<7.25.0']).satisfied_by?(Gem::Version.new(puppet_version)) # Add this beucause until Puppet 7.25 concurrent-ruby 1.22 break puppet - gem "ruby-pwsh", '~> 0.3.0', platforms: [:mswin, :mingw, :x64_mingw] - gem "fast_gettext", '1.1.0', require: false if ruby_version < Gem::Version.new('2.1.0') - gem "fast_gettext", require: false if ruby_version >= Gem::Version.new('2.1.0') - gem "json_pure", '<= 2.0.1', require: false if ruby_version < Gem::Version.new('2.0.0') - gem "json", '= 1.8.1', require: false if ruby_version == Gem::Version.new('2.1.9') - gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(ruby_version) - gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(ruby_version) - gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "librarian-puppet", '<= 4.0.1' + 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 "metadata-json-lint", '~> 4.0', require: false + gem "rspec-puppet-facts", '~> 4.0', 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.9', require: false + gem "puppet-debugger", '~> 1.0', 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 "io-console", '= 0.7.2', require: false + gem "bcrypt_pbkdf", '= 1.0.1', require: false + gem "librarian-puppet", '~> 5.0' gem "kitchen-puppet" gem "kitchen-docker" gem "kitchen-verifier-serverspec" + gem "rexml", '>= 3.0.0', '< 3.2.7', require: false gem "mixlib-shellout", "~> 2.2.7", platforms: [:ruby] - gem "rubocop-i18n", "~> 1.2.0" - gem "rubocop-rspec", "~> 1.16.0" + gem "test-kitchen", '~> 3.7.0' +end +group :development, :release_prep do + gem "puppet-strings", '~> 4.0', require: false + gem "puppetlabs_spec_helper", '~> 8.0', require: false + gem "puppet-blacksmith", '~> 7.0', require: false +end +group :system_tests do + gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] + gem "CFPropertyList", '< 3.0.7', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "serverspec", '~> 2.41', require: false +end - # https://github.com/ffi/ffi/issues/1103 (pin only for Ruby >= 2.5 as this version is not compatible below. ffi 1.17 is not compatible with Ruby 2.5: https://github.com/ffi/ffi/issues/1103) - if ruby_version >= Gem::Version.new('2.5') - gem "ffi", "= 1.16.3", platforms: [:ruby] - else - gem "ffi", require: false, platforms: [:mswin, :mingw, :x64_mingw] - end +puppet_version = ENV['PUPPET_GEM_VERSION'] +facter_version = ENV['FACTER_GEM_VERSION'] +hiera_version = ENV['HIERA_GEM_VERSION'] - if ruby_version >= Gem::Version.new('2.3') - gem "test-kitchen", '~> 2.5.4' - gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby] - gem "puppet-module-posix-dev-r#{minor_version}", require: false, platforms: [:ruby] - gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-win-dev-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] - else - gem "test-kitchen", '~> 1.16.0' - gem "puppetlabs_spec_helper", "~> 2.14.1" - gem "puppet-lint", "~> 2.4.2" - gem "metadata-json-lint", "~> 1.2.2" - gem "puppet-syntax", "~> 2.5.0" - gem "rspec-puppet", "~> 2.6.9" - gem "rubocop", "~> 0.49.1" - gem "artifactory", "~> 2.8.2" +gems = {} + +gems['puppet'] = location_for(puppet_version) + +# If facter or hiera versions have been specified via the environment +# variables + +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| + gem gem_name, *gem_params +end + +# Evaluate Gemfile.local and ~/.gemfile if they exist +extra_gemfiles = [ + "#{__FILE__}.local", + File.join(Dir.home, '.gemfile'), +] + +extra_gemfiles.each do |gemfile| + if File.file?(gemfile) && File.readable?(gemfile) + eval(File.read(gemfile), binding) end end +# vim: syntax=ruby diff --git a/Gemfile.lock b/Gemfile.lock index 07fddbc5..0f9b97e4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,34 +1,31 @@ GEM remote: https://rubygems.org/ specs: - CFPropertyList (2.3.6) - activesupport (6.1.6.1) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - zeitwerk (~> 2.3) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) + CFPropertyList (3.0.6) + rexml + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) ansi (1.5.0) ast (2.4.2) awesome_print (1.9.2) - aws-eventstream (1.2.0) - aws-partitions (1.609.0) - aws-sdk-core (3.131.3) - aws-eventstream (~> 1, >= 1.0.2) - aws-partitions (~> 1, >= 1.525.0) - aws-sigv4 (~> 1.1) + aws-eventstream (1.3.0) + aws-partitions (1.1027.0) + aws-sdk-core (3.214.0) + aws-eventstream (~> 1, >= 1.3.0) + aws-partitions (~> 1, >= 1.992.0) + aws-sigv4 (~> 1.9) jmespath (~> 1, >= 1.6.1) - aws-sdk-ec2 (1.323.0) - aws-sdk-core (~> 3, >= 3.127.0) - aws-sigv4 (~> 1.1) - aws-sigv4 (1.5.1) + aws-sdk-ec2 (1.498.0) + aws-sdk-core (~> 3, >= 3.210.0) + aws-sigv4 (~> 1.5) + aws-sigv4 (1.10.1) aws-eventstream (~> 1, >= 1.0.2) - bcrypt_pbkdf (1.1.0) - bindata (2.4.10) - bolt (3.24.0) - CFPropertyList (~> 2.2) + base64 (0.2.0) + bcrypt_pbkdf (1.0.1-x64-mingw32) + bigdecimal (3.1.8) + bindata (2.5.0) + bolt (4.0.0) + CFPropertyList (>= 2.2) addressable (~> 2.5) aws-sdk-ec2 (~> 1) concurrent-ruby (~> 1.0) @@ -37,433 +34,466 @@ GEM jwt (~> 2.2) logging (~> 2.2) minitar (~> 0.6) - net-scp (~> 1.2) - net-ssh (>= 4.0, < 7.0) + net-scp (>= 1.2, < 5.0) + net-ssh (>= 4.0, < 8.0) net-ssh-krb (~> 0.5) - orchestrator_client (~> 0.5) + orchestrator_client (~> 0.7) puppet (>= 6.18.0) puppet-resource_api (>= 1.8.1) - puppet-strings (~> 2.3) - puppetfile-resolver (~> 0.5) - r10k (~> 3.10) + puppet-strings (>= 2.3.0, < 5.0) + puppetfile-resolver (>= 0.6.2, < 1.0) + r10k (>= 3.10, < 5) ruby_smb (~> 1.0) terminal-table (~> 3.0) winrm (~> 2.0) winrm-fs (~> 1.3) - builder (3.2.4) - codecov (0.2.5) - colorize - json - simplecov + builder (3.3.0) + chef-utils (18.6.2) + concurrent-ruby coderay (1.1.3) colored2 (3.1.2) - colorize (0.8.1) - concurrent-ruby (1.1.10) - connection_pool (2.2.5) - cri (2.15.11) + concurrent-ruby (1.3.4) + connection_pool (2.4.1) + cri (2.15.12) deep_merge (1.2.2) - dependency_checker (0.2.0) + dependency_checker (1.0.1) parallel - puppet_forge (~> 2.2) - rake (~> 12.3) + puppet_forge (>= 2.2, < 6.0) + rake (~> 13.0) semantic_puppet (~> 1.0) - diff-lcs (1.5.0) - docile (1.4.0) - docker-api (2.2.0) - excon (>= 0.47.0) + diff-lcs (1.5.1) + docile (1.4.1) + docker-api (2.4.0) + excon (>= 0.64.0) multi_json - domain_name (0.5.20190701) - unf (>= 0.0.5, < 1.0.0) - ed25519 (1.2.4) - equatable (0.7.0) - erubi (1.10.0) - excon (0.92.4) - facter (4.2.10) + domain_name (0.6.20240107) + ed25519 (1.3.0) + erubi (1.13.1) + excon (1.2.2) + facter (4.10.0) hocon (~> 1.3) - thor (>= 1.0.1, < 2.0) - facterdb (1.19.0) + thor (>= 1.0.1, < 1.3) + facterdb (2.1.0) facter (< 5.0.0) - jgrep - faraday (0.17.4) - multipart-post (>= 1.2, < 3) - faraday_middleware (0.14.0) - faraday (>= 0.7.4, < 1.0) - fast_gettext (1.1.2) + jgrep (~> 1.5, >= 1.5.4) + faraday (2.12.2) + faraday-net_http (>= 2.0, < 3.5) + json + logger + faraday-follow_redirects (0.3.0) + faraday (>= 1, < 3) + faraday-net_http (3.4.0) + net-http (>= 0.5.0) + faraday-net_http_persistent (2.3.0) + faraday (~> 2.5) + net-http-persistent (>= 4.0.4, < 5) + fast_gettext (2.4.0) + prime ffi (1.16.3) - ffi-compiler (1.0.1) - ffi (>= 1.0.0) - rake - gettext (3.2.9) + ffi-win32-extensions (1.0.4) + ffi + forwardable (1.3.3) + getoptlong (0.2.1) + gettext (3.5.0) + erubi locale (>= 2.0.5) + prime + racc text (>= 1.3.0) - gettext-setup (0.34) - fast_gettext (~> 1.1.0) - gettext (>= 3.0.2, < 3.3.0) + gettext-setup (1.1.0) + fast_gettext (~> 2.1) + gettext (~> 3.4) locale gssapi (1.3.1) ffi (>= 1.0.1) - gyoku (1.3.1) + gyoku (1.4.0) builder (>= 2.1.2) - hiera (3.9.0) - hiera-eyaml (3.3.0) + rexml (~> 3.0) + hiera-eyaml (3.4.0) highline optimist - highline (2.0.3) - hirb (0.7.3) - hocon (1.3.1) - honeycomb-beeline (2.11.0) - libhoney (>= 1.14.2) - http (4.4.1) - addressable (~> 2.3) - http-cookie (~> 1.0) - http-form_data (~> 2.2) - http-parser (~> 1.2.0) + highline (3.1.1) + reline + hocon (1.4.0) http-accept (1.7.0) - http-cookie (1.0.5) + http-cookie (1.0.8) domain_name (~> 0.5) - http-form_data (2.3.0) - http-parser (1.2.3) - ffi-compiler (>= 1.0, < 2.0) httpclient (2.8.3) - i18n (1.12.0) - concurrent-ruby (~> 1.0) + io-console (0.7.2) jgrep (1.5.4) - jmespath (1.6.1) - json (2.6.2) - json-schema (2.8.1) - addressable (>= 2.4) - jwt (2.2.3) - kitchen-docker (2.11.0) + jmespath (1.6.2) + json (2.6.3) + json-schema (5.1.1) + addressable (~> 2.8) + bigdecimal (~> 3.1) + jwt (2.9.3) + base64 + kitchen-docker (3.0.0) test-kitchen (>= 1.0.0) - kitchen-puppet (3.5.2) + kitchen-puppet (3.7.0) librarian-puppet (>= 3.0) net-ssh (>= 3) test-kitchen (>= 1.4) - kitchen-verifier-serverspec (0.7.1) + kitchen-verifier-serverspec (0.7.2) net-ssh (>= 3) test-kitchen (>= 1.4) - libhoney (2.2.0) - addressable (~> 2.0) - excon - http (>= 2.0, < 6.0) - librarian-puppet (3.0.1) + librarian-puppet (5.0.0) librarianp (>= 0.6.3) - puppet_forge (~> 2.1) + puppet_forge (>= 2.1, < 5) rsync - librarianp (1.1.1) + librarianp (1.1.2) thor (~> 1.0) - license-acceptance (1.0.19) + license-acceptance (2.1.13) pastel (~> 0.7) - tomlrb (~> 1.2) - tty-box (~> 0.3) - tty-prompt (~> 0.18) + tomlrb (>= 1.2, < 3.0) + tty-box (~> 0.6) + tty-prompt (~> 0.20) little-plugger (1.1.4) - locale (2.1.3) + locale (2.1.4) log4r (1.1.10) - logging (2.3.0) + logger (1.6.4) + logging (2.4.0) little-plugger (~> 1.1) multi_json (~> 1.14) - metaclass (0.0.4) - metadata-json-lint (2.4.0) - json-schema (~> 2.8) + metadata-json-lint (4.1.0) + json-schema (>= 2.8, < 6.0) + semantic_puppet (~> 1.0) spdx-licenses (~> 1.0) - method_source (0.8.2) - mime-types (3.4.1) + method_source (1.1.0) + mime-types (3.6.0) + logger mime-types-data (~> 3.2015) - mime-types-data (3.2022.0105) - minitar (0.9) - minitest (5.16.2) - mixlib-install (3.12.16) + mime-types-data (3.2024.1203) + minitar (0.12.1) + mixlib-install (3.12.30) mixlib-shellout mixlib-versioning thor - mixlib-shellout (2.2.7) + mixlib-shellout (3.3.4-universal-mingw32) + chef-utils + ffi-win32-extensions (~> 1.0.3) + win32-process (~> 0.9) + wmi-lite (~> 1.0) mixlib-versioning (1.2.12) - mocha (1.1.0) - metaclass (~> 0.0.1) + mocha (2.7.1) + ruby2_keywords (>= 0.0.5) molinillo (0.8.0) multi_json (1.15.0) - multipart-post (2.1.1) - necromancer (0.5.1) - net-http-persistent (4.0.1) + net-http (0.6.0) + uri + net-http-persistent (4.0.5) connection_pool (~> 2.2) - net-scp (1.2.1) - net-ssh (>= 2.6.5) - net-ssh (6.1.0) + net-scp (4.0.0) + net-ssh (>= 2.6.5, < 8.0.0) + net-ssh (7.3.0) net-ssh-gateway (2.0.0) net-ssh (>= 4.0.0) net-ssh-krb (0.5.1) gssapi (~> 1.3.0) net-ssh (>= 2.0) - net-telnet (0.1.1) + net-telnet (0.2.0) netrc (0.11.0) - nori (2.6.0) - optimist (3.0.1) - orchestrator_client (0.5.4) - faraday (~> 0.17.4) - net-http-persistent - parallel (1.20.1) - parallel_tests (2.14.2) + nori (2.7.1) + bigdecimal + optimist (3.2.0) + orchestrator_client (0.7.1) + faraday (>= 1.4, < 3.0) + faraday-net_http_persistent (>= 1.0, < 3.0) + parallel (1.26.3) + parallel_tests (3.12.1) parallel - parser (2.7.2.0) + parser (3.3.6.0) ast (~> 2.4.1) - pastel (0.7.4) - equatable (~> 0.6) + racc + pastel (0.8.0) tty-color (~> 0.5) - pathspec (1.0.0) + pathspec (2.1.0) pluginator (1.5.0) - powerpack (0.1.3) - pry (0.10.4) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) - public_suffix (4.0.7) - puppet (7.0.0) + prime (0.1.3) + forwardable + singleton + pry (0.15.0) + coderay (~> 1.1) + method_source (~> 1.0) + public_suffix (6.0.1) + puppet (8.10.0-x64-mingw32) concurrent-ruby (~> 1.0) deep_merge (~> 1.0) - facter (> 2.0.1, < 5) - fast_gettext (~> 1.1) - hiera (>= 3.2.1, < 4) + facter (>= 4.3.0, < 5) + fast_gettext (>= 2.1, < 4) + ffi (>= 1.15.5, < 1.17.0, != 1.16.2, != 1.16.1, != 1.16.0) + getoptlong (~> 0.2.0) locale (~> 2.1) - multi_json (~> 1.10) + minitar (~> 0.9) + multi_json (~> 1.13) puppet-resource_api (~> 1.5) + scanf (~> 1.0) semantic_puppet (~> 1.0) - puppet-blacksmith (6.1.1) - puppet-modulebuilder (~> 0.2) + puppet-blacksmith (7.1.0) + puppet-modulebuilder (~> 1.0) rest-client (~> 2.0) - puppet-debugger (1.2.0) + puppet-debugger (1.4.0) awesome_print (~> 1.7) bundler facterdb (>= 0.4.0) pluginator (~> 1.5.0) - puppet (>= 5.5) + puppet (>= 6) rb-readline (>= 0.5.5) table_print (>= 1.0.0) - tty-pager (~> 0.13.0) - puppet-lint (2.5.2) - puppet-module-posix-default-r2.7 (1.1.1) - puppet-module-posix-dev-r2.7 (0.5.3) - activesupport (~> 6.0) - bcrypt_pbkdf (~> 1.0) - codecov (>= 0.2, < 0.2.6) - concurrent-ruby (!= 1.1.6) - dependency_checker (~> 0.2) - ed25519 (~> 1.2) - facterdb (>= 0.8.1, < 2.0.0) - gettext-setup (~> 0.26) - metadata-json-lint (>= 2.0.2, < 3.0.0) - mocha (>= 1.0.0, < 1.2.0) - parallel_tests (>= 2.14.1, < 2.14.3) - pry (~> 0.10.4) - puppet-blacksmith (~> 6.0) - puppet-debugger (~> 1.0) - puppet-lint (>= 2.3.0, < 3.0.0) - puppet-resource_api (~> 1.8) - puppet-strings (~> 2.0) - puppet-syntax (>= 2.4.1, < 3.0.0) - puppet_litmus (>= 0.4.0, < 1.0.0) - puppet_pot_generator (~> 1.0) - puppetlabs_spec_helper (>= 2.9.0, < 3.0.0) - rainbow (~> 2.0) - rspec-puppet (>= 2.3.2, < 3.0.0) - rspec-puppet-facts (>= 1.10.0, < 3) - rspec_junit_formatter (~> 0.2) - rubocop (~> 0.49.0) - rubocop-i18n (~> 1.2.0) - rubocop-rspec (~> 1.16.0) - serverspec (~> 2.41) - simplecov (< 0.19.0) - simplecov-console (~> 0.4.2) - specinfra (= 2.82.2) - puppet-modulebuilder (0.3.0) + tty-pager (~> 0.14) + puppet-lint (4.2.4) + puppet-lint-absolute_classname-check (4.0.0) + puppet-lint (>= 3.0, < 5) + puppet-lint-anchor-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-file_ensure-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-leading_zero-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-lookup_in_parameter-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-manifest_whitespace-check (0.3.0) + puppet-lint (>= 1.0, < 5) + puppet-lint-optional_default-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-param-docs (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-param-types (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-params_empty_string-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-resource_reference_syntax (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-strict_indent-check (3.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-topscope-variable-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-trailing_comma-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-unquoted_string-check (3.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-variable_contains_upcase (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-version_comparison-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-modulebuilder (1.1.0) minitar (~> 0.9) - pathspec (>= 0.2.1, < 2.0.0) - puppet-resource_api (1.8.14) + pathspec (>= 0.2.1, < 3.0.0) + puppet-resource_api (1.9.0) hocon (>= 1.0) - puppet-strings (2.9.0) - rgen - yard (~> 0.9.5) - puppet-syntax (2.6.1) - puppet (>= 5) - rake - puppet_forge (2.3.4) - faraday (>= 0.9.0, < 0.18.0, != 0.13.1) - faraday_middleware (>= 0.9.0, < 0.15.0) - gettext-setup (~> 0.11) + puppet-strings (4.1.3) + rgen (~> 0.9) + yard (~> 0.9, < 0.9.37) + puppet-syntax (4.1.1) + puppet (>= 7, < 9) + rake (~> 13.1) + puppet_forge (4.1.0) + faraday (~> 2.0) + faraday-follow_redirects (~> 0.3.0) minitar semantic_puppet (~> 1.0) - puppet_litmus (0.34.0) - bolt (>= 2.0.1, < 4.0.0) + puppet_litmus (1.6.1) + bolt (~> 4.0) docker-api (>= 1.34, < 3.0.0) - honeycomb-beeline parallel - puppet-modulebuilder (>= 0.2.1, < 1.0.0) + puppet-modulebuilder (>= 0.3.0) retryable (~> 3.0) rspec - rspec_honeycomb_formatter tty-spinner (>= 0.5.0, < 1.0.0) - puppet_pot_generator (1.0.1) - puppet - puppetfile-resolver (0.6.2) + puppetfile-resolver (0.6.3) molinillo (~> 0.6) semantic_puppet (~> 1.0) - puppetlabs_spec_helper (2.16.0) - mocha (~> 1.0) - pathspec (>= 0.2.1, < 1.1.0) - puppet-lint (~> 2.0) - puppet-syntax (>= 2.0, < 4) - rspec-puppet (~> 2.0) - r10k (3.15.0) + puppetlabs_spec_helper (8.0.0) + mocha (>= 1.0, < 3) + pathspec (>= 0.2, < 3) + puppet-lint (~> 4.0) + puppet-syntax (~> 4.1, >= 4.1.1) + rspec-github (~> 2.0) + rspec-puppet (~> 5.0) + r10k (4.1.0) colored2 (= 3.1.2) cri (>= 2.15.10) - fast_gettext (>= 1.1.0, < 3.0.0) - gettext (>= 3.0.2, < 4.0.0) - gettext-setup (~> 0.24) - jwt (~> 2.2.3) + gettext-setup (>= 0.24, < 2.0) + jwt (>= 2.2.3, < 3) log4r (= 1.1.10) minitar (~> 0.9) multi_json (~> 1.10) - puppet_forge (>= 2.3.0) - rainbow (2.2.2) - rake - rake (12.3.3) + puppet_forge (>= 4.1, < 6) + racc (1.8.1) + rainbow (3.1.1) + rake (13.2.1) rb-readline (0.5.5) - rest-client (2.1.0) + regexp_parser (2.9.3) + reline (0.6.0) + io-console (~> 0.5) + rest-client (2.1.0-x64-mingw32) + ffi (~> 1.9) http-accept (>= 1.7.0, < 2.0) http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) retryable (3.0.5) - rgen (0.9.0) - rspec (3.11.0) - rspec-core (~> 3.11.0) - rspec-expectations (~> 3.11.0) - rspec-mocks (~> 3.11.0) - rspec-core (3.11.0) - rspec-support (~> 3.11.0) - rspec-expectations (3.11.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-its (1.3.0) - rspec-core (>= 3.0.0) - rspec-expectations (>= 3.0.0) - rspec-mocks (3.11.1) + rexml (3.2.6) + rgen (0.9.1) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.2) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-puppet (2.12.0) - rspec - rspec-puppet-facts (2.0.5) - facter - facterdb (>= 0.5.0) - puppet - rspec-support (3.11.0) - rspec_honeycomb_formatter (0.2.1) - honeycomb-beeline + rspec-support (~> 3.13.0) + rspec-github (2.4.0) rspec-core (~> 3.0) - rspec_junit_formatter (0.5.1) - rspec-core (>= 2, < 4, != 2.12.0) + rspec-its (2.0.0) + rspec-core (>= 3.13.0) + rspec-expectations (>= 3.13.0) + rspec-mocks (3.13.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-puppet (5.0.0) + rspec (~> 3.0) + rspec-puppet-facts (4.0.0) + deep_merge (~> 1.2) + facter (< 5) + facterdb (~> 2.1) + puppet (>= 7, < 9) + rspec-support (3.13.2) rsync (1.0.9) - rubocop (0.49.1) + rubocop (1.50.2) + json (~> 2.3) parallel (~> 1.10) - parser (>= 2.3.3.1, < 3.0) - powerpack (~> 0.1) - rainbow (>= 1.99.1, < 3.0) + parser (>= 3.2.0.0) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) - rubocop-i18n (1.2.0) - rubocop (~> 0.49.0) - rubocop-rspec (1.16.0) - rubocop (>= 0.49.0) - ruby-progressbar (1.11.0) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.37.0) + parser (>= 3.3.1.0) + rubocop-capybara (2.21.0) + rubocop (~> 1.41) + rubocop-performance (1.16.0) + rubocop (>= 1.7.0, < 2.0) + rubocop-ast (>= 0.4.0) + rubocop-rspec (2.19.0) + rubocop (~> 1.33) + rubocop-capybara (~> 2.17) + ruby-progressbar (1.13.0) + ruby2_keywords (0.0.5) ruby_smb (1.1.0) bindata rubyntlm windows_error - rubyntlm (0.6.3) + rubyntlm (0.6.5) + base64 rubyzip (2.3.2) - semantic_puppet (1.0.4) - serverspec (2.42.0) + scanf (1.0.0) + semantic_puppet (1.1.0) + serverspec (2.42.3) multi_json rspec (~> 3.0) rspec-its specinfra (~> 2.72) sfl (2.3) - simplecov (0.18.5) + simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) - simplecov-console (0.4.2) + simplecov_json_formatter (~> 0.1) + simplecov-console (0.9.2) ansi - hirb simplecov - simplecov-html (0.12.3) - slop (3.6.0) + terminal-table + simplecov-html (0.13.1) + simplecov_json_formatter (0.1.4) + singleton (0.3.0) spdx-licenses (1.3.0) - specinfra (2.82.2) + specinfra (2.91.0) + base64 net-scp net-ssh (>= 2.7) - net-telnet (= 0.1.1) + net-telnet sfl - strings (0.1.8) - strings-ansi (~> 0.1) - unicode-display_width (~> 1.5) + strings (0.2.1) + strings-ansi (~> 0.2) + unicode-display_width (>= 1.5, < 3.0) unicode_utils (~> 1.4) strings-ansi (0.2.0) table_print (1.5.7) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) - test-kitchen (2.5.4) + test-kitchen (3.7.0) bcrypt_pbkdf (~> 1.0) + chef-utils (>= 16.4.35) ed25519 (~> 1.2) - license-acceptance (~> 1.0, >= 1.0.11) + license-acceptance (>= 1.0.11, < 3.0) mixlib-install (~> 3.6) mixlib-shellout (>= 1.2, < 4.0) - net-scp (>= 1.1, < 4.0) - net-ssh (>= 2.9, < 7.0) + net-scp (>= 1.1, < 5.0) + net-ssh (>= 2.9, < 8.0) net-ssh-gateway (>= 1.2, < 3.0) thor (>= 0.19, < 2.0) winrm (~> 2.0) winrm-elevated (~> 1.0) winrm-fs (~> 1.1) text (1.3.1) - thor (1.1.0) - tomlrb (1.3.0) - tty-box (0.5.0) - pastel (~> 0.7.2) - strings (~> 0.1.6) + thor (1.2.2) + tomlrb (2.0.3) + tty-box (0.7.0) + pastel (~> 0.8) + strings (~> 0.2.0) tty-cursor (~> 0.7) tty-color (0.6.0) tty-cursor (0.7.1) - tty-pager (0.13.0) - strings (~> 0.1.8) + tty-pager (0.14.0) + strings (~> 0.2.0) tty-screen (~> 0.8) - tty-prompt (0.21.0) - necromancer (~> 0.5.0) - pastel (~> 0.7.0) - tty-reader (~> 0.7.0) - tty-reader (0.7.0) + tty-prompt (0.23.1) + pastel (~> 0.8) + tty-reader (~> 0.8) + tty-reader (0.9.0) tty-cursor (~> 0.7) - tty-screen (~> 0.7) - wisper (~> 2.0.0) - tty-screen (0.8.1) + tty-screen (~> 0.8) + wisper (~> 2.0) + tty-screen (0.8.2) tty-spinner (0.9.3) tty-cursor (~> 0.7) - tzinfo (2.0.5) - concurrent-ruby (~> 1.0) - unf (0.1.4) - unf_ext - unf_ext (0.0.8.2) - unicode-display_width (1.7.0) + unicode-display_width (2.6.0) unicode_utils (1.4.0) - webrick (1.7.0) - windows_error (0.1.4) - winrm (2.3.6) + uri (1.0.2) + voxpupuli-puppet-lint-plugins (5.0.0) + puppet-lint (~> 4.0) + puppet-lint-absolute_classname-check (~> 4.0) + puppet-lint-anchor-check (~> 2.0) + puppet-lint-file_ensure-check (~> 2.0) + puppet-lint-leading_zero-check (~> 2.0) + puppet-lint-lookup_in_parameter-check (~> 2.0) + puppet-lint-manifest_whitespace-check (~> 0.3, < 1.0.0) + puppet-lint-optional_default-check (~> 2.0) + puppet-lint-param-docs (~> 2.0) + puppet-lint-param-types (~> 2.0) + puppet-lint-params_empty_string-check (~> 2.0) + puppet-lint-resource_reference_syntax (~> 2.0) + puppet-lint-strict_indent-check (~> 3.0) + puppet-lint-topscope-variable-check (~> 2.0) + puppet-lint-trailing_comma-check (~> 2.0) + puppet-lint-unquoted_string-check (~> 3.0) + puppet-lint-variable_contains_upcase (~> 2.0) + puppet-lint-version_comparison-check (~> 2.0) + win32-process (0.10.0) + ffi (>= 1.0.0) + windows_error (0.1.5) + winrm (2.3.9) builder (>= 2.1.2) erubi (~> 1.8) gssapi (~> 1.2) gyoku (~> 1.0) httpclient (~> 2.2, >= 2.2.0.2) logging (>= 1.6.1, < 3.0) - nori (~> 2.0) + nori (~> 2.0, >= 2.7.1) + rexml (~> 3.0) rubyntlm (~> 0.6.0, >= 0.6.3) winrm-elevated (1.2.3) erubi (~> 1.8) @@ -475,36 +505,44 @@ GEM rubyzip (~> 2.0) winrm (~> 2.0) wisper (2.0.1) - xmlrpc (0.3.2) - webrick - yard (0.9.28) - webrick (~> 1.7.0) - zeitwerk (2.6.0) + wmi-lite (1.0.7) + yard (0.9.36) PLATFORMS - ruby + x64-mingw32 DEPENDENCIES - concurrent-ruby (= 1.1.10) - fast_gettext - ffi (= 1.16.3) + CFPropertyList (< 3.0.7) + bcrypt_pbkdf (= 1.0.1) + deep_merge (~> 1.2.2) + dependency_checker (~> 1.0.0) + facterdb (~> 2.1) + io-console (= 0.7.2) + json (= 2.6.3) kitchen-docker kitchen-puppet kitchen-verifier-serverspec - librarian-puppet (<= 4.0.1) + librarian-puppet (~> 5.0) + metadata-json-lint (~> 4.0) mixlib-shellout (~> 2.2.7) - puppet (~> 7.0.0) - puppet-module-posix-default-r2.7 - puppet-module-posix-dev-r2.7 - puppet-module-win-default-r2.7 - puppet-module-win-dev-r2.7 + parallel_tests (= 3.12.1) + pry (~> 0.10) + puppet (= 8.10.0) + puppet-blacksmith (~> 7.0) + puppet-debugger (~> 1.0) + puppet-strings (~> 4.0) + puppet_litmus (~> 1.0) + puppetlabs_spec_helper (~> 8.0) rb-readline (= 0.5.5) - rubocop-i18n (~> 1.2.0) - rubocop-rspec (~> 1.16.0) - ruby-pwsh (~> 0.3.0) - semantic_puppet (= 1.0.4) - test-kitchen (~> 2.5.4) - xmlrpc + rexml (>= 3.0.0, < 3.2.7) + rspec-puppet-facts (~> 4.0) + rubocop (~> 1.50.0) + rubocop-performance (= 1.16.0) + rubocop-rspec (= 2.19.0) + serverspec (~> 2.41) + simplecov-console (~> 0.9) + test-kitchen (~> 3.7.0) + voxpupuli-puppet-lint-plugins (~> 5.0) BUNDLED WITH - 1.17.3 + 2.4.13 diff --git a/Rakefile b/Rakefile index 7c1fd16d..130ff70e 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,10 @@ +# frozen_string_literal: true + +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-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings' require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? require 'puppet-lint/tasks/puppet-lint' require 'rubocop/rake_task' @@ -13,6 +18,16 @@ exclude_paths = [ PuppetLint.configuration.ignore_paths = exclude_paths PuppetSyntax.exclude_paths = exclude_paths +PuppetLint.configuration.send('disable_relative') +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"] + desc "Run syntax, lint, and spec tests." task :test => [ 'syntax', diff --git a/environments/etc/manifests/site.pp b/environments/etc/manifests/site.pp index 78fde18d..dc594938 100644 --- a/environments/etc/manifests/site.pp +++ b/environments/etc/manifests/site.pp @@ -1,9 +1,8 @@ node default { - class { 'datadog_agent': api_key => 'somenonnullapikeythats32charlong', agent_extra_options => { - use_http => true, + use_http => true, }, # Hostname is necessary for Agent to start up properly in container since 7.40.0 # https://github.com/DataDog/datadog-agent/issues/14152#issuecomment-1301842615 @@ -24,5 +23,4 @@ username => 'status', password => 'hunter1', } - } diff --git a/functions/tag6.pp b/functions/tag6.pp index 8e63a1c1..8c02abbf 100644 --- a/functions/tag6.pp +++ b/functions/tag6.pp @@ -9,7 +9,7 @@ function datadog_agent::tag6( ) { if $tag_names =~ Array { $tags = $tag_names.reduce([]) |$_tags , $tag| { - concat($_tags, datadog_agent::tag6($tag, $lookup_fact, $lookup_table)) + concat($_tags, datadog_agent::tag6($tag, $lookup_fact, $lookup_table)) } } else { if $lookup_fact =~ String { diff --git a/lib/puppet/reports/datadog_reports.rb b/lib/puppet/reports/datadog_reports.rb index 56ee3528..75aefea2 100644 --- a/lib/puppet/reports/datadog_reports.rb +++ b/lib/puppet/reports/datadog_reports.rb @@ -137,7 +137,7 @@ def process facts = Puppet::Node::Facts.indirection.find(host).values facts_tags = REPORT_FACT_TAGS.map { |name| "#{name}:#{facts.dig(*name.split('.'))}" } - trusted_facts = (Puppet.lookup(:trusted_information) { Hash.new }).to_h + trusted_facts = (Puppet.lookup(:trusted_information) { {} }).to_h trusted_fact_tags = REPORT_TRUSTED_FACT_TAGS.map { |name| "#{name}:#{trusted_facts.dig(*name.split('.'))}" } dog_tags = facts_tags + trusted_fact_tags diff --git a/manifests/init.pp b/manifests/init.pp index 0d622015..d41ade49 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -284,8 +284,8 @@ Boolean $collect_gce_tags = false, Boolean $collect_instance_metadata = true, Array $tags = [], - $integrations = {}, - $hiera_integrations = false, + Hash $integrations = {}, + Boolean $hiera_integrations = false, Boolean $hiera_tags = false, Array $facts_to_tags = [], Array $trusted_facts_to_tags = [], @@ -297,16 +297,16 @@ Array $dogstreams = [], String $log_level = 'info', Boolean $log_to_syslog = true, - $service_ensure = 'running', - $service_enable = true, + String $service_ensure = 'running', + Boolean $service_enable = true, Boolean $manage_repo = true, Boolean $manage_dogapi_gem = true, Boolean $manage_install = true, Optional[Boolean] $datadog_installer_enabled = undef, - $hostname_extraction_regex = undef, + String $hostname_extraction_regex = undef, Boolean $hostname_fqdn = false, Variant[Stdlib::Port, Pattern[/^\d*$/]] $dogstatsd_port = 8125, - $dogstatsd_socket = '', + String $dogstatsd_socket = '', Array $report_fact_tags = [], Array $report_trusted_fact_tags = [], String $statsd_forward_host = '', @@ -319,7 +319,7 @@ Variant[Stdlib::Port, Pattern[/^\d*$/]] $graphite_listen_port = '', String $extra_template = '', String $ganglia_host = '', - $ganglia_port = 8651, + Integer $ganglia_port = 8651, Boolean $skip_ssl_validation = false, Boolean $skip_apt_key_trusting = false, Boolean $use_curl_http_client = false, @@ -355,8 +355,8 @@ Optional[Integer] $agent_major_version = undef, Optional[String] $conf_dir = undef, Boolean $conf_dir_purge = $datadog_agent::params::conf_dir_purge, - $dd_group = $datadog_agent::params::dd_group, - $dd_groups = $datadog_agent::params::dd_groups, + String $dd_group = $datadog_agent::params::dd_group, + Any $dd_groups = $datadog_agent::params::dd_groups, Boolean $apm_enabled = $datadog_agent::params::apm_default_enabled, String $apm_env = 'none', Boolean $apm_non_local_traffic = false, @@ -368,7 +368,7 @@ Boolean $scrub_args = $datadog_agent::params::process_default_scrub_args, Array $custom_sensitive_words = $datadog_agent::params::process_default_custom_words, Boolean $logs_enabled = $datadog_agent::params::logs_enabled, - $logs_open_files_limit = $datadog_agent::params::logs_open_files_limit, + Integer $logs_open_files_limit = $datadog_agent::params::logs_open_files_limit, Boolean $container_collect_all = $datadog_agent::params::container_collect_all, Hash[String[1], Data] $agent_extra_options = {}, Optional[String] $agent_repo_uri = undef, @@ -391,7 +391,6 @@ Optional[Enum['host', 'docker', 'all']] $apm_instrumentation_enabled = undef, Optional[Array[String]] $apm_instrumentation_libraries = undef, ) inherits datadog_agent::params { - #In this regex, version '1:6.15.0~rc.1-1' would match as $1='1:', $2='6', $3='15', $4='0', $5='~rc.1', $6='1' if $agent_version != 'latest' and $agent_version =~ /([0-9]+:)?([0-9]+)\.([0-9]+)\.([0-9]+)((?:~|-)[^0-9\s-]+[^-\s]*)?(?:-([0-9]+))?/ { $_agent_major_version = 0 + $2 # Cast to integer @@ -411,7 +410,7 @@ if $facts['os']['release']['full'] =~ /^6(.[0-9])?/ and $agent_version == 'latest' { notice("datadog-agent ${_agent_major_version}.51 is the last supported version on CentOS 6. Installing ${_agent_major_version}.51 now") $agent_full_version='7.51.1' - } elsif $facts['os']['release']['full'] =~ /^6(.[0-9])?/ and $_agent_minor_version != undef and $_agent_minor_version > 51 { + } elsif $facts['os']['release']['full'] =~ /^6(.[0-9])?/ and $_agent_minor_version != undef and versioncmp($_agent_minor_version, '51') > 0 { fail("datadog-agent ${_agent_major_version}.51 is the last supported version on CentOS 6.") } else { $agent_full_version = $agent_version @@ -420,7 +419,7 @@ default: { $agent_full_version = $agent_version } } - if $_agent_major_version != 5 and $_agent_major_version != 6 and $_agent_major_version != 7 { + if versioncmp($_agent_major_version, '5') != 0 and versioncmp($_agent_major_version, '6') != 0 and versioncmp($_agent_major_version, '7') != 0 { fail("agent_major_version must be either 5, 6 or 7, not ${_agent_major_version}") } @@ -431,7 +430,7 @@ } if $conf_dir == undef { - if $_agent_major_version == 5 { + if versioncmp($_agent_major_version, '5') == 0 { $_conf_dir = $datadog_agent::params::legacy_conf_dir } else { $_conf_dir = $datadog_agent::params::conf_dir @@ -441,13 +440,13 @@ } if $hiera_tags { - $local_tags = lookup({ 'name' => 'datadog_agent::tags', 'merge' => 'unique', 'default_value' => []}) + $local_tags = lookup({ 'name' => 'datadog_agent::tags', 'merge' => 'unique', 'default_value' => [] }) } else { $local_tags = $tags } if $hiera_integrations { - $local_integrations = lookup({ 'name' => 'datadog_agent::integrations', 'default_value' => {}}) + $local_integrations = lookup({ 'name' => 'datadog_agent::integrations', 'default_value' => {} }) } else { $local_integrations = $integrations } @@ -655,14 +654,13 @@ } } - if $_agent_major_version == 5 { - + if versioncmp($_agent_major_version, '5') == 0 { if ($facts['os']['name'] == 'Windows') { fail('Installation of agent 5 with puppet is not supported on Windows') } if !empty($agent_extra_options) { - notify { 'Setting agent_extra_options has no effect with Agent 5': } + notify { 'Setting agent_extra_options has no effect with Agent 5': } } file { '/etc/dd-agent': @@ -680,10 +678,10 @@ force => $conf_dir_purge, owner => $dd_user, group => $dd_group, - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } - concat {'/etc/dd-agent/datadog.conf': + concat { '/etc/dd-agent/datadog.conf': owner => $dd_user, group => $dd_group, mode => '0640', @@ -696,31 +694,31 @@ } else { $_dd_url = $dd_url } - concat::fragment{ 'datadog header': + concat::fragment { 'datadog header': target => '/etc/dd-agent/datadog.conf', content => template('datadog_agent/datadog_header.conf.erb'), order => '01', } - concat::fragment{ 'datadog tags': + concat::fragment { 'datadog tags': target => '/etc/dd-agent/datadog.conf', content => 'tags: ', order => '02', } - datadog_agent::tag5{$local_tags: } - datadog_agent::tag5{$facts_to_tags: + datadog_agent::tag5 { $local_tags: } + datadog_agent::tag5 { $facts_to_tags: lookup_fact => true, } - concat::fragment{ 'datadog footer': + concat::fragment { 'datadog footer': target => '/etc/dd-agent/datadog.conf', content => template('datadog_agent/datadog_footer.conf.erb'), order => '05', } unless $extra_template.empty { - concat::fragment{ 'datadog extra_template footer': + concat::fragment { 'datadog extra_template footer': target => '/etc/dd-agent/datadog.conf', content => template($extra_template), order => '06', @@ -728,7 +726,7 @@ } if ($apm_enabled == true) and (($apm_env != 'none') or $apm_analyzed_spans or $apm_obfuscation) { - concat::fragment{ 'datadog apm footer': + concat::fragment { 'datadog apm footer': target => '/etc/dd-agent/datadog.conf', content => template('datadog_agent/datadog_apm_footer.conf.erb'), order => '07', @@ -736,58 +734,57 @@ } if ($process_enabled == true) { - concat::fragment{ 'datadog process agent footer': + concat::fragment { 'datadog process agent footer': target => '/etc/dd-agent/datadog.conf', content => template('datadog_agent/datadog_process_footer.conf.erb'), order => '08', } } - file {'/etc/dd-agent/install_info': + file { '/etc/dd-agent/install_info': owner => $dd_user, group => $dd_group, mode => '0640', content => template('datadog_agent/install_info.erb'), require => File['/etc/dd-agent'], } - } else { #Agent 6/7 # notify of broken params on agent6/7 if !empty($proxy_host) { - notify { 'Setting proxy_host is only used with Agent 5. Please use agent_extra_options to set your proxy': } + notify { 'Setting proxy_host is only used with Agent 5. Please use agent_extra_options to set your proxy': } } if !empty($proxy_port) { - notify { 'Setting proxy_port is only used with Agent 5. Please use agent_extra_options to set your proxy': } + notify { 'Setting proxy_port is only used with Agent 5. Please use agent_extra_options to set your proxy': } } if !empty($proxy_user) { - notify { 'Setting proxy_user is only used with Agent 5. Please use agent_extra_options to set your proxy': } + notify { 'Setting proxy_user is only used with Agent 5. Please use agent_extra_options to set your proxy': } } if !empty($proxy_password) { - notify { 'Setting proxy_password is only used with Agent 5. Please use agent_extra_options to set your proxy': } + notify { 'Setting proxy_password is only used with Agent 5. Please use agent_extra_options to set your proxy': } } # lint:ignore:quoted_booleans $process_enabled_str = $process_enabled ? { true => 'true' , default => 'disabled' } # lint:endignore $base_extra_config = { - 'apm_config' => { - 'enabled' => $apm_enabled, - 'env' => $apm_env, - 'apm_non_local_traffic' => $apm_non_local_traffic - }, - 'process_config' => { - 'enabled' => $process_enabled_str, - 'scrub_args' => $scrub_args, - 'custom_sensitive_words' => $custom_sensitive_words, - }, - 'logs_enabled' => $logs_enabled, + 'apm_config' => { + 'enabled' => $apm_enabled, + 'env' => $apm_env, + 'apm_non_local_traffic' => $apm_non_local_traffic, + }, + 'process_config' => { + 'enabled' => $process_enabled_str, + 'scrub_args' => $scrub_args, + 'custom_sensitive_words' => $custom_sensitive_words, + }, + 'logs_enabled' => $logs_enabled, } if $logs_open_files_limit { $logs_base_config = { 'logs_config' => { 'container_collect_all' => $container_collect_all, - 'open_files_limit' => $logs_open_files_limit + 'open_files_limit' => $logs_open_files_limit, }, } } else { @@ -798,87 +795,88 @@ } } if $host.empty { - $host_config = {} + $host_config = {} } else { - $host_config = { - 'hostname' => $host, - } + $host_config = { + 'hostname' => $host, + } } if $apm_analyzed_spans { - $apm_analyzed_span_config = { - 'apm_config' => { - 'analyzed_spans' => $apm_analyzed_spans - } - } + $apm_analyzed_span_config = { + 'apm_config' => { + 'analyzed_spans' => $apm_analyzed_spans, + }, + } } else { - $apm_analyzed_span_config = {} + $apm_analyzed_span_config = {} } if $apm_obfuscation { - $apm_obfuscation_config = { - 'apm_config' => { - 'obfuscation' => $apm_obfuscation - } - } + $apm_obfuscation_config = { + 'apm_config' => { + 'obfuscation' => $apm_obfuscation, + }, + } } else { - $apm_obfuscation_config = {} + $apm_obfuscation_config = {} } if $apm_filter_tags { - $apm_filter_tags_config = { - 'apm_config' => { - 'filter_tags' => $apm_filter_tags - } - } + $apm_filter_tags_config = { + 'apm_config' => { + 'filter_tags' => $apm_filter_tags, + }, + } } else { - $apm_filter_tags_config = {} + $apm_filter_tags_config = {} } if $apm_filter_tags_regex { - $apm_filter_tags_regex_config = { - 'apm_config' => { - 'filter_tags_regex' => $apm_filter_tags_regex - } - } + $apm_filter_tags_regex_config = { + 'apm_config' => { + 'filter_tags_regex' => $apm_filter_tags_regex, + }, + } } else { - $apm_filter_tags_regex_config = {} + $apm_filter_tags_regex_config = {} } if $statsd_forward_host.empty { - $statsd_forward_config = {} + $statsd_forward_config = {} } else { - if String($statsd_forward_port).empty { - $statsd_forward_config = { - 'statsd_forward_host' => $statsd_forward_host, - } - } else { - $statsd_forward_config = { - 'statsd_forward_host' => $statsd_forward_host, - 'statsd_forward_port' => $statsd_forward_port, - } + if String($statsd_forward_port).empty { + $statsd_forward_config = { + 'statsd_forward_host' => $statsd_forward_host, } + } else { + $statsd_forward_config = { + 'statsd_forward_host' => $statsd_forward_host, + 'statsd_forward_port' => $statsd_forward_port, + } + } } if $additional_checksd { - $additional_checksd_config = { - 'additional_checksd' => $additional_checksd, - } + $additional_checksd_config = { + 'additional_checksd' => $additional_checksd, + } } else { - $additional_checksd_config = {} + $additional_checksd_config = {} } $extra_config = deep_merge( - $base_extra_config, - $logs_base_config, - $agent_extra_options, - $apm_analyzed_span_config, - $apm_obfuscation_config, - $apm_filter_tags_config, - $apm_filter_tags_regex_config, - $statsd_forward_config, - $host_config, - $additional_checksd_config) + $base_extra_config, + $logs_base_config, + $agent_extra_options, + $apm_analyzed_span_config, + $apm_obfuscation_config, + $apm_filter_tags_config, + $apm_filter_tags_regex_config, + $statsd_forward_config, + $host_config, + $additional_checksd_config + ) file { $_conf_dir: ensure => directory, @@ -920,10 +918,8 @@ $agent_config = deep_merge($_agent_config, $extra_config) if ($facts['os']['name'] == 'Windows') { - - file { 'C:/ProgramData/Datadog': - ensure => directory + ensure => directory, } file { 'C:/ProgramData/Datadog/datadog.yaml': @@ -943,9 +939,7 @@ content => template('datadog_agent/install_info.erb'), require => File['C:/ProgramData/Datadog'], } - } else { - file { '/etc/datadog-agent/datadog.yaml': owner => $dd_user, group => $dd_group, @@ -964,7 +958,6 @@ require => File['/etc/datadog-agent'], } } - } if $puppet_run_reports { @@ -993,5 +986,4 @@ } create_resources('datadog_agent::integration', $local_integrations) - } diff --git a/manifests/install_integration.pp b/manifests/install_integration.pp index ab661f10..ad70085d 100644 --- a/manifests/install_integration.pp +++ b/manifests/install_integration.pp @@ -3,12 +3,10 @@ String $integration_name = undef, String $version = undef, Boolean $third_party = false, -){ - - require ::datadog_agent +) { + require datadog_agent if $ensure == 'present' { - if $third_party { $install_cmd = 'install --third-party' } else { @@ -31,5 +29,4 @@ notify => Service[$datadog_agent::params::service_name], } } - } diff --git a/manifests/integration.pp b/manifests/integration.pp index 7824c94c..60920498 100644 --- a/manifests/integration.pp +++ b/manifests/integration.pp @@ -5,13 +5,12 @@ String $integration = $title, String $conf_file = 'conf', Enum['present', 'absent'] $ensure = 'present', -){ - +) { # We can't `require ::datadog_agent` from here since this class is used by the # datadog_agent class, causing a dependency cycle. If using this class # directly, you should define datadog_agent before datadog_agent::integration. - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/${integration}.d" $dst = "${dst_dir}/${$conf_file}.yaml" if (! defined(File[$dst_dir])) { @@ -20,14 +19,14 @@ owner => $datadog_agent::dd_user, group => $datadog_agent::dd_group, mode => $datadog_agent::params::permissions_directory, - before => File[$dst] + before => File[$dst], } } } else { $dst = "${datadog_agent::params::legacy_conf_dir}/${integration}.yaml" } - $file_ensure = $ensure ? { default => file, 'absent' => absent } + $file_ensure = $ensure ? { default => 'file', 'absent' => absent } file { $dst: ensure => $file_ensure, @@ -35,7 +34,6 @@ group => $datadog_agent::dd_group, mode => $datadog_agent::params::permissions_file, content => to_instances_yaml($init_config, $instances, $logs), - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } - } diff --git a/manifests/integrations/activemq_xml.pp b/manifests/integrations/activemq_xml.pp index ac1ecbb1..fe903232 100644 --- a/manifests/integrations/activemq_xml.pp +++ b/manifests/integrations/activemq_xml.pp @@ -42,23 +42,23 @@ # detailed_subscribers: ['subscriber1', 'subscriber2', 'subscriber3'] # # -class datadog_agent::integrations::activemq_xml( +class datadog_agent::integrations::activemq_xml ( String $url = 'http://localhost:8161', Boolean $supress_errors = false, Optional[String] $username = undef, Optional[String] $password = undef, - Optional[Array[String]] $detailed_queues = [], - Optional[Array[String]] $detailed_topics = [], - Optional[Array[String]] $detailed_subscribers = [], + Array[String] $detailed_queues = [], + Array[String] $detailed_topics = [], + Array[String] $detailed_subscribers = [], Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/activemq_xml.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/activemq_xml.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -67,7 +67,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -76,15 +76,15 @@ if !$instances and $url { $_instances = [{ - 'url' => $url, - 'username' => $username, - 'password' => $password, - 'supress_errors' => $supress_errors, - 'detailed_queues' => $detailed_queues, - 'detailed_topics' => $detailed_topics, - 'detailed_subscribers' => $detailed_subscribers, + 'url' => $url, + 'username' => $username, + 'password' => $password, + 'supress_errors' => $supress_errors, + 'detailed_queues' => $detailed_queues, + 'detailed_topics' => $detailed_topics, + 'detailed_subscribers' => $detailed_subscribers, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances diff --git a/manifests/integrations/apache.pp b/manifests/integrations/apache.pp index b6de7fc1..1a0b64c0 100644 --- a/manifests/integrations/apache.pp +++ b/manifests/integrations/apache.pp @@ -33,13 +33,13 @@ Array $tags = [], Boolean $disable_ssl_validation = false ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/apache.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/apache.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -48,7 +48,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -62,6 +62,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/apache.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/cacti.pp b/manifests/integrations/cacti.pp index 2f1ee0d4..367a40d5 100644 --- a/manifests/integrations/cacti.pp +++ b/manifests/integrations/cacti.pp @@ -12,19 +12,19 @@ # $path # The path to the cacti rrd directory e.g. /var/lib/cacti/rra/ # -class datadog_agent::integrations::cacti( - $mysql_host = 'localhost', - $mysql_user = 'cacti', - $mysql_password = undef, - $rrd_path = '/var/lib/cacti/rra/', +class datadog_agent::integrations::cacti ( + String $mysql_host = 'localhost', + String $mysql_user = 'cacti', + Any $mysql_password = undef, + String $rrd_path = '/var/lib/cacti/rra/', ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/cacti.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/cacti.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -33,7 +33,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -47,6 +47,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/cacti.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/cassandra.pp b/manifests/integrations/cassandra.pp index 8f5e17a4..9a651229 100644 --- a/manifests/integrations/cassandra.pp +++ b/manifests/integrations/cassandra.pp @@ -28,22 +28,22 @@ # } # # -class datadog_agent::integrations::cassandra( +class datadog_agent::integrations::cassandra ( String $host = 'localhost', Integer $port = 7199, Optional[String] $user = undef, Optional[String] $password = undef, - Optional[Hash] $tags = {}, + Hash $tags = {}, Optional[Integer] $max_returned_metrics = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/cassandra.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/cassandra.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: ensure => directory, @@ -51,7 +51,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { diff --git a/manifests/integrations/ceph.pp b/manifests/integrations/ceph.pp index 174c8ba3..7363e8dd 100644 --- a/manifests/integrations/ceph.pp +++ b/manifests/integrations/ceph.pp @@ -13,21 +13,21 @@ # class { 'datadog_agent::integrations::ceph' : # } # -class datadog_agent::integrations::ceph( - Array $tags = [ 'name:ceph_cluster' ], +class datadog_agent::integrations::ceph ( + Array $tags = ['name:ceph_cluster'], String $ceph_cmd = '/usr/bin/ceph', ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent file { '/etc/sudoers.d/datadog_ceph': - content => "# This file is required for dd ceph \ndd-agent ALL=(ALL) NOPASSWD:/usr/bin/ceph\n" + content => "# This file is required for dd ceph \ndd-agent ALL=(ALL) NOPASSWD:/usr/bin/ceph\n", } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/ceph.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/ceph.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -36,7 +36,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -50,6 +50,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/ceph.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/consul.pp b/manifests/integrations/consul.pp index d999d0e8..b89f895d 100644 --- a/manifests/integrations/consul.pp +++ b/manifests/integrations/consul.pp @@ -26,20 +26,20 @@ # new_leader_checks => false, # } # -class datadog_agent::integrations::consul( +class datadog_agent::integrations::consul ( String $url = 'http://localhost:8500', Boolean $catalog_checks = true, Boolean $network_latency_checks = true, Boolean $new_leader_checks = true, - Optional[Array] $service_whitelist = [] + Array $service_whitelist = [] ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/consul.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/consul.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -48,7 +48,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -62,6 +62,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/consul.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/directory.pp b/manifests/integrations/directory.pp index ca1b20cf..c482210b 100644 --- a/manifests/integrations/directory.pp +++ b/manifests/integrations/directory.pp @@ -65,7 +65,7 @@ String $pattern = '', Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $directory == '' { fail('bad directory argument and no instances hash provided') @@ -73,26 +73,26 @@ if !$instances and $directory { $_instances = [{ - 'directory' => $directory, - 'filegauges' => $filegauges, - 'recursive' => $recursive, - 'countonly' => $countonly, - 'name' => $nametag, - 'dirtagname' => $dirtagname, - 'filetagname' => $filetagname, - 'pattern' => $pattern, + 'directory' => $directory, + 'filegauges' => $filegauges, + 'recursive' => $recursive, + 'countonly' => $countonly, + 'name' => $nametag, + 'dirtagname' => $dirtagname, + 'filetagname' => $filetagname, + 'pattern' => $pattern, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/directory.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/directory.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -101,7 +101,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -115,6 +115,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/directory.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/disk.pp b/manifests/integrations/disk.pp index 30565739..911ac666 100644 --- a/manifests/integrations/disk.pp +++ b/manifests/integrations/disk.pp @@ -62,8 +62,8 @@ # } class datadog_agent::integrations::disk ( String $use_mount = 'no', - $all_partitions = undef, - $tag_by_filesystem = undef, + String $all_partitions = undef, + String $tag_by_filesystem = undef, Optional[Array[String]] $filesystem_exclude = undef, Optional[Array[String]] $device_exclude = undef, Optional[Array[String]] $mountpoint_exclude = undef, @@ -81,7 +81,7 @@ Optional[String] $excluded_disk_re = undef, # deprecated in agent versions >6.9 Optional[String] $excluded_mountpoint_re = undef, # deprecated in agent versions >6.9 ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent validate_legacy('Optional[String]', 'validate_re', $all_partitions, '^(no|yes)$') @@ -90,10 +90,10 @@ } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/disk.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/disk.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -102,7 +102,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -116,6 +116,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/disk.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/dns_check.pp b/manifests/integrations/dns_check.pp index 6b6bc7de..d097aaad 100644 --- a/manifests/integrations/dns_check.pp +++ b/manifests/integrations/dns_check.pp @@ -30,16 +30,16 @@ 'hostname' => 'google.com', 'nameserver' => '8.8.8.8', 'timeout' => 5, - } + }, ] ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/dns_check.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/dns_check.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -48,7 +48,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { diff --git a/manifests/integrations/docker_daemon.pp b/manifests/integrations/docker_daemon.pp index 3852b319..1f0c6719 100644 --- a/manifests/integrations/docker_daemon.pp +++ b/manifests/integrations/docker_daemon.pp @@ -19,52 +19,52 @@ # url => 'unix://var/run/docker.sock', # } # -class datadog_agent::integrations::docker_daemon( - $group = 'docker', - $docker_root = '/', - $timeout = 10, - $api_version = 'auto', - $tls = false, - $tls_client_cert = '/path/to/client-cert.pem', - $tls_client_key = '/path/to/client-key.pem', - $tls_cacert = '/path/to/ca.pem', - $tls_verify = true, - $init_retry_interval = 0, - $init_retries = 0, - $url = 'unix://var/run/docker.sock', - $collect_events = true, - $filtered_event_types = [], - $collect_container_size = false, - $custom_cgroups = false, - $health_service_check_whitelist = [], - $collect_container_count = false, - $collect_volume_count = false, - $collect_images_stats = false, - $collect_image_size = false, - $collect_disk_stats = false, - $collect_exit_codes = false, - $exclude = [], - $include = [], - $tags = [], - $ecs_tags = true, +class datadog_agent::integrations::docker_daemon ( + String $group = 'docker', + String $docker_root = '/', + Integer $timeout = 10, + String $api_version = 'auto', + Boolean $tls = false, + String $tls_client_cert = '/path/to/client-cert.pem', + String $tls_client_key = '/path/to/client-key.pem', + String$tls_cacert = '/path/to/ca.pem', + Boolean $tls_verify = true, + Integer $init_retry_interval = 0, + Integer $init_retries = 0, + String $url = 'unix://var/run/docker.sock', + Boolean $collect_events = true, + Array $filtered_event_types = [], + Boolean $collect_container_size = false, + Boolean $custom_cgroups = false, + Array $health_service_check_whitelist = [], + Boolean $collect_container_count = false, + Boolean $collect_volume_count = false, + Boolean $collect_images_stats = false, + Boolean $collect_image_size = false, + Boolean $collect_disk_stats = false, + Boolean $collect_exit_codes = false, + Array $exclude = [], + Array $include = [], + Array $tags = [], + Boolean $ecs_tags = true, # Possible values: "container_name", "image_name", "image_tag", "docker_image" - $performance_tags = [], + Array $performance_tags = [], # Possible values: "image_name", "image_tag", "docker_image" - $container_tags = [], + Array $container_tags = [], # Ex. "com.docker.compose.service", "com.docker.compose.project" - $collect_labels_as_tags = [], - $event_attributes_as_tags = [], + Array $collect_labels_as_tags = [], + Array $event_attributes_as_tags = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent exec { 'dd-agent-should-be-in-docker-group': command => "/usr/sbin/usermod -aG ${group} ${datadog_agent::dd_user}", unless => "/bin/cat /etc/group | grep '^${group}:' | grep -qw ${datadog_agent::dd_user}", require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $legacy_dir = "${datadog_agent::params::conf_dir}/docker_daemon.d" file { $legacy_dir: @@ -73,7 +73,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $legacy_conf = "${legacy_dir}/conf.yaml" } else { @@ -81,10 +81,10 @@ } file { $legacy_conf: - ensure => 'absent' + ensure => 'absent', } - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/docker.d" file { $dst_dir: @@ -93,7 +93,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -107,6 +107,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/docker_daemon.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/elasticsearch.pp b/manifests/integrations/elasticsearch.pp index 05383f7b..cfe6227b 100644 --- a/manifests/integrations/elasticsearch.pp +++ b/manifests/integrations/elasticsearch.pp @@ -23,7 +23,7 @@ # url => "http://localhost:9201" # } # -class datadog_agent::integrations::elasticsearch( +class datadog_agent::integrations::elasticsearch ( Boolean $cluster_stats = false, Boolean $index_stats = false, Optional[String] $password = undef, @@ -37,27 +37,27 @@ Optional[String] $username = undef, Optional[Array] $instances = undef ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent # $ssl_verify can be a bool or a string # https://github.com/DataDog/dd-agent/blob/master/checks.d/elastic.py#L454-L455 - if validate_legacy('Variant[Boolean, String]', 'is_string', $ssl_verify){ + if validate_legacy('Variant[Boolean, String]', 'is_string', $ssl_verify) { validate_absolute_path($ssl_verify) } if !$instances and $url { $_instances = [{ - 'cluster_stats' => $cluster_stats, - 'index_stats' => $index_stats, - 'password' => $password, - 'pending_task_stats' => $pending_task_stats, - 'pshard_stats' => $pshard_stats, - 'ssl_cert' => $ssl_cert, - 'ssl_key' => $ssl_key, - 'ssl_verify' => $ssl_verify, - 'tags' => $tags, - 'url' => $url, - 'username' => $username + 'cluster_stats' => $cluster_stats, + 'index_stats' => $index_stats, + 'password' => $password, + 'pending_task_stats' => $pending_task_stats, + 'pshard_stats' => $pshard_stats, + 'ssl_cert' => $ssl_cert, + 'ssl_key' => $ssl_key, + 'ssl_verify' => $ssl_verify, + 'tags' => $tags, + 'url' => $url, + 'username' => $username }] } elsif !$instances { $_instances = [] @@ -66,10 +66,10 @@ } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/elastic.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/elastic.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -78,7 +78,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -92,6 +92,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/elastic.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/fluentd.pp b/manifests/integrations/fluentd.pp index bcbf3c21..5918c3de 100644 --- a/manifests/integrations/fluentd.pp +++ b/manifests/integrations/fluentd.pp @@ -17,17 +17,17 @@ # } # # -class datadog_agent::integrations::fluentd( - $monitor_agent_url = 'http://localhost:24220/api/plugins.json', - Optional[Array] $plugin_ids = [], +class datadog_agent::integrations::fluentd ( + String $monitor_agent_url = 'http://localhost:24220/api/plugins.json', + Array $plugin_ids = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/fluentd.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/fluentd.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -36,7 +36,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { diff --git a/manifests/integrations/generic.pp b/manifests/integrations/generic.pp index c5e23d19..1c80694c 100644 --- a/manifests/integrations/generic.pp +++ b/manifests/integrations/generic.pp @@ -17,17 +17,17 @@ # integration_contents => template(my_custom_template), # } # -class datadog_agent::integrations::generic( +class datadog_agent::integrations::generic ( Optional[String] $integration_name = undef, Optional[String] $integration_contents = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/${integration_name}.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/${integration_name}.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -36,7 +36,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -50,6 +50,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => $integration_contents, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/haproxy.pp b/manifests/integrations/haproxy.pp index ee8728b2..08ab67de 100644 --- a/manifests/integrations/haproxy.pp +++ b/manifests/integrations/haproxy.pp @@ -16,19 +16,19 @@ # options => { collect_aggregates_only => 'False' }, # } # -class datadog_agent::integrations::haproxy( - $creds = {}, - $url = "http://${facts['networking']['ip']}:8080", - $options = {}, +class datadog_agent::integrations::haproxy ( + Hash $creds = {}, + String $url = "http://${facts['networking']['ip']}:8080", + Hash $options = {}, Optional[Array] $instances = undef ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $url { $_instances = [{ - 'creds' => $creds, - 'url' => $url, - 'options' => $options, + 'creds' => $creds, + 'url' => $url, + 'options' => $options, }] } elsif !$instances { $_instances = [] @@ -37,10 +37,10 @@ } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/haproxy.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/haproxy.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -49,7 +49,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -57,12 +57,12 @@ } file { $dst: - ensure => file, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_file, - content => template('datadog_agent/agent-conf.d/haproxy.yaml.erb'), - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + ensure => file, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_file, + content => template('datadog_agent/agent-conf.d/haproxy.yaml.erb'), + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/http_check.pp b/manifests/integrations/http_check.pp index a5964bb4..9b96feb6 100644 --- a/manifests/integrations/http_check.pp +++ b/manifests/integrations/http_check.pp @@ -166,84 +166,83 @@ # }] # } - class datadog_agent::integrations::http_check ( - $sitename = undef, - $url = undef, - $username = undef, - $password = undef, - $timeout = 1, - $method = 'get', - $min_collection_interval = undef, - $data = undef, - $threshold = undef, - $window = undef, - $content_match = undef, - $reverse_content_match = false, - $include_content = false, - $http_response_status_code = undef, - $collect_response_time = true, - $disable_ssl_validation = false, - $ignore_ssl_warning = false, - $skip_event = true, - $no_proxy = false, - $check_certificate_expiration = true, - $days_warning = undef, - $days_critical = undef, + String $sitename = undef, + String $url = undef, + String $username = undef, + Any $password = undef, + Integer $timeout = 1, + String $method = 'get', + Integer $min_collection_interval = undef, + Any $data = undef, + Integer $threshold = undef, + Integer $window = undef, + String $content_match = undef, + Boolean $reverse_content_match = false, + Boolean $include_content = false, + String $http_response_status_code = undef, + Boolean $collect_response_time = true, + Boolean $disable_ssl_validation = false, + Boolean $ignore_ssl_warning = false, + Boolean $skip_event = true, + Boolean $no_proxy = false, + Boolean $check_certificate_expiration = true, + Integer $days_warning = undef, + Integer $days_critical = undef, Optional[Boolean] $check_hostname = undef, Optional[String] $ssl_server_name = undef, - $headers = [], - $allow_redirects = true, - $tags = [], - $contact = [], + Array $headers = [], + Boolean $allow_redirects = true, + Array $tags = [], + Array $contact = [], Optional[Array] $instances = undef, - $ca_certs = undef, + String $ca_certs = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $url { $_instances = [{ - 'sitename' => $sitename, - 'url' => $url, - 'username' => $username, - 'password' => $password, - 'timeout' => $timeout, - 'method' => $method, - 'min_collection_interval' => $min_collection_interval, - 'data' => $data, - 'threshold' => $threshold, - 'window' => $window, - 'content_match' => $content_match, - 'reverse_content_match' => $reverse_content_match, - 'include_content' => $include_content, - 'http_response_status_code' => $http_response_status_code, - 'collect_response_time' => $collect_response_time, - 'disable_ssl_validation' => $disable_ssl_validation, - 'ignore_ssl_warning' => $ignore_ssl_warning, - 'skip_event' => $skip_event, - 'no_proxy' => $no_proxy, - 'check_certificate_expiration' => $check_certificate_expiration, - 'days_warning' => $days_warning, - 'days_critical' => $days_critical, - 'check_hostname' => $check_hostname, - 'ssl_server_name' => $ssl_server_name, - 'headers' => $headers, - 'allow_redirects' => $allow_redirects, - 'tags' => $tags, - 'contact' => $contact, - 'ca_certs' => $ca_certs, + 'sitename' => $sitename, + 'url' => $url, + 'username' => $username, + 'password' => $password, + 'timeout' => $timeout, + 'method' => $method, + 'min_collection_interval' => $min_collection_interval, + 'data' => $data, + 'threshold' => $threshold, + 'window' => $window, + 'content_match' => $content_match, + 'reverse_content_match' => $reverse_content_match, + 'include_content' => $include_content, + 'http_response_status_code' => $http_response_status_code, + 'collect_response_time' => $collect_response_time, + 'disable_ssl_validation' => $disable_ssl_validation, + 'ignore_ssl_warning' => $ignore_ssl_warning, + 'skip_event' => $skip_event, + 'no_proxy' => $no_proxy, + 'check_certificate_expiration' => $check_certificate_expiration, + 'days_warning' => $days_warning, + 'days_critical' => $days_critical, + 'check_hostname' => $check_hostname, + 'ssl_server_name' => $ssl_server_name, + 'headers' => $headers, + 'allow_redirects' => $allow_redirects, + 'tags' => $tags, + 'contact' => $contact, + 'ca_certs' => $ca_certs, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/http_check.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/http_check.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -252,7 +251,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -266,6 +265,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/http_check.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/jenkins.pp b/manifests/integrations/jenkins.pp index c3fe39bc..c017aee0 100644 --- a/manifests/integrations/jenkins.pp +++ b/manifests/integrations/jenkins.pp @@ -13,16 +13,16 @@ # } # # -class datadog_agent::integrations::jenkins( - $path = '/var/lib/jenkins' +class datadog_agent::integrations::jenkins ( + String $path = '/var/lib/jenkins' ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/jenkins.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/jenkins.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -31,7 +31,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -45,6 +45,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/jenkins.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/jmx.pp b/manifests/integrations/jmx.pp index e32f3ec9..10876b77 100644 --- a/manifests/integrations/jmx.pp +++ b/manifests/integrations/jmx.pp @@ -61,17 +61,17 @@ # }], # } # -class datadog_agent::integrations::jmx( - $init_config = {}, - $instances = [], +class datadog_agent::integrations::jmx ( + Hash $init_config = {}, + Array $instances = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/jmx.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/jmx.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -80,7 +80,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -94,7 +94,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/jmx.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } - } diff --git a/manifests/integrations/kafka.pp b/manifests/integrations/kafka.pp index 2f575e76..49072278 100644 --- a/manifests/integrations/kafka.pp +++ b/manifests/integrations/kafka.pp @@ -52,8 +52,8 @@ # ] # } # -class datadog_agent::integrations::kafka( - $host = 'localhost', +class datadog_agent::integrations::kafka ( + String $host = 'localhost', Variant[String[1], Integer] $port = 9999, Optional[String[1]] $username = undef, Optional[String[1]] $password = undef, @@ -65,32 +65,32 @@ Optional[Hash[String[1], String[1]]] $tags = undef, Optional[Array[Hash[String[1], Data]]] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $host and $port { $servers = [{ - 'host' => $host, - 'port' => $port, - 'username' => $username, - 'password' => $password, - 'process_name_regex' => $process_name_regex, - 'tools_jar_path' => $tools_jar_path, - 'java_bin_path' => $java_bin_path, - 'trust_store_path' => $trust_store_path, - 'trust_store_password' => $trust_store_password, - 'tags' => $tags, + 'host' => $host, + 'port' => $port, + 'username' => $username, + 'password' => $password, + 'process_name_regex' => $process_name_regex, + 'tools_jar_path' => $tools_jar_path, + 'java_bin_path' => $java_bin_path, + 'trust_store_path' => $trust_store_path, + 'trust_store_password' => $trust_store_password, + 'tags' => $tags, }] - } elsif !$instances{ + } elsif !$instances { $servers = [] } else { $servers = $instances } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/kafka.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/kafka.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -99,7 +99,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { diff --git a/manifests/integrations/kong.pp b/manifests/integrations/kong.pp index 15a17d92..b5815286 100644 --- a/manifests/integrations/kong.pp +++ b/manifests/integrations/kong.pp @@ -25,20 +25,20 @@ # } # class datadog_agent::integrations::kong ( - $instances = [ + Array $instances = [ { 'status_url' => 'http://localhost:8001/status/', 'tags' => [] } ] ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/kong.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/kong.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -47,7 +47,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -61,6 +61,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/kong.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/kubernetes.pp b/manifests/integrations/kubernetes.pp index b984191c..8c9a5929 100644 --- a/manifests/integrations/kubernetes.pp +++ b/manifests/integrations/kubernetes.pp @@ -21,22 +21,22 @@ # kubelet_client_key => '/etc/ssl/private/key', # } # -class datadog_agent::integrations::kubernetes( - $api_server_url = 'Enter_Your_API_url', - $apiserver_client_crt = '/path/to/crt', - $apiserver_client_key = '/path/to/key', - $kubelet_client_crt = '/path/to/crt', - $kubelet_client_key = '/path/to/key', - $tags = [], +class datadog_agent::integrations::kubernetes ( + String $api_server_url = 'Enter_Your_API_url', + String $apiserver_client_crt = '/path/to/crt', + String $apiserver_client_key = '/path/to/key', + String $kubelet_client_crt = '/path/to/crt', + String $kubelet_client_key = '/path/to/key', + Array $tags = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/kubernetes.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/kubernetes.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -45,7 +45,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { diff --git a/manifests/integrations/kubernetes_state.pp b/manifests/integrations/kubernetes_state.pp index 10fe409c..107f7014 100644 --- a/manifests/integrations/kubernetes_state.pp +++ b/manifests/integrations/kubernetes_state.pp @@ -17,18 +17,18 @@ # url => 'http://kubernetes.com:8080/metrics', # } # -class datadog_agent::integrations::kubernetes_state( - $url = 'Enter_State_URL', - $tags = [], +class datadog_agent::integrations::kubernetes_state ( + String $url = 'Enter_State_URL', + Array $tags = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/kubernetes_state.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/kubernetes_state.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -37,7 +37,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { diff --git a/manifests/integrations/linux_proc_extras.pp b/manifests/integrations/linux_proc_extras.pp index 9a93c006..98064809 100644 --- a/manifests/integrations/linux_proc_extras.pp +++ b/manifests/integrations/linux_proc_extras.pp @@ -13,16 +13,16 @@ # tags => [ 'env:production' ], # } -class datadog_agent::integrations::linux_proc_extras( - $tags = [], +class datadog_agent::integrations::linux_proc_extras ( + Array $tags = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/linux_proc_extras.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/linux_proc_extras.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -31,7 +31,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -45,7 +45,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/linux_proc_extras.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } - } diff --git a/manifests/integrations/logs.pp b/manifests/integrations/logs.pp index a71e0e19..5f8ec670 100644 --- a/manifests/integrations/logs.pp +++ b/manifests/integrations/logs.pp @@ -36,11 +36,11 @@ # https://docs.datadoghq.com/logs/log_collection # -class datadog_agent::integrations::logs( +class datadog_agent::integrations::logs ( Array $logs = [], ) inherits datadog_agent::params { - unless $::datadog_agent::_agent_major_version == 5 { - require ::datadog_agent + unless versioncmp($datadog_agent::_agent_major_version, '5') == 0 { + require datadog_agent file { "${datadog_agent::params::conf_dir}/logs.yaml": ensure => file, @@ -49,7 +49,7 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/logs.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } } diff --git a/manifests/integrations/marathon.pp b/manifests/integrations/marathon.pp index cf147156..bcf008bf 100644 --- a/manifests/integrations/marathon.pp +++ b/manifests/integrations/marathon.pp @@ -12,17 +12,17 @@ # url => "http://localhost:8080" # } # -class datadog_agent::integrations::marathon( - $marathon_timeout = 5, - $url = 'http://localhost:8080' +class datadog_agent::integrations::marathon ( + Integer $marathon_timeout = 5, + String $url = 'http://localhost:8080' ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/marathon.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/marathon.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -31,7 +31,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -45,6 +45,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/marathon.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/memcache.pp b/manifests/integrations/memcache.pp index 985da7c9..d0168edf 100644 --- a/manifests/integrations/memcache.pp +++ b/manifests/integrations/memcache.pp @@ -38,27 +38,27 @@ Variant[Boolean, String] $slabs = false, Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $url { $_instances = [{ - 'url' => $url, - 'port' => $port, - 'tags' => $tags, - 'items' => $items, - 'slabs' => $slabs, + 'url' => $url, + 'port' => $port, + 'tags' => $tags, + 'items' => $items, + 'slabs' => $slabs, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/mcache.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/mcache.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -67,7 +67,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -81,6 +81,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/mcache.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/mesos_master.pp b/manifests/integrations/mesos_master.pp index 065fe8d9..1809dd28 100644 --- a/manifests/integrations/mesos_master.pp +++ b/manifests/integrations/mesos_master.pp @@ -12,13 +12,13 @@ # url => "http://localhost:5050" # } # -class datadog_agent::integrations::mesos_master( - $mesos_timeout = 10, - $url = 'http://localhost:5050' +class datadog_agent::integrations::mesos_master ( + Integer $mesos_timeout = 10, + String $url = 'http://localhost:5050' ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/mesos.d" file { $dst_dir: @@ -27,7 +27,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -35,14 +35,14 @@ } file { $dst: - ensure => 'absent' + ensure => 'absent', } $legacy_dst_master = "${datadog_agent::params::legacy_conf_dir}/mesos_master.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_master_dir = "${datadog_agent::params::conf_dir}/mesos_master.d" file { $legacy_dst_master: - ensure => 'absent' + ensure => 'absent', } file { $dst_master_dir: @@ -51,7 +51,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst_master = "${dst_master_dir}/conf.yaml" } else { @@ -65,6 +65,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/mesos_master.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/mesos_slave.pp b/manifests/integrations/mesos_slave.pp index 9860cf71..b3691f10 100644 --- a/manifests/integrations/mesos_slave.pp +++ b/manifests/integrations/mesos_slave.pp @@ -12,16 +12,15 @@ # url => "http://localhost:5051" # } # -class datadog_agent::integrations::mesos_slave( - $mesos_timeout = 10, - $url = 'http://localhost:5051' +class datadog_agent::integrations::mesos_slave ( + Integer $mesos_timeout = 10, + String $url = 'http://localhost:5051' ) inherits datadog_agent::params { - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/mesos_slave.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/mesos_slave.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -30,7 +29,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -44,6 +43,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/mesos_slave.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/mongo.pp b/manifests/integrations/mongo.pp index ff87c3f9..4299bca5 100644 --- a/manifests/integrations/mongo.pp +++ b/manifests/integrations/mongo.pp @@ -93,16 +93,16 @@ # ] # } # -class datadog_agent::integrations::mongo( - Array $servers = [{'host' => 'localhost', 'port' => '27017'}] +class datadog_agent::integrations::mongo ( + Array $servers = [{ 'host' => 'localhost', 'port' => '27017' }] ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/mongo.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/mongo.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -111,7 +111,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -125,6 +125,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/mongo.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/mysql.pp b/manifests/integrations/mysql.pp index 26106e13..38ab0dc4 100644 --- a/manifests/integrations/mysql.pp +++ b/manifests/integrations/mysql.pp @@ -66,61 +66,61 @@ # } # # -class datadog_agent::integrations::mysql( +class datadog_agent::integrations::mysql ( String $host = 'localhost', - Optional[String] $user = 'datadog', - Optional[Variant[String, Integer]] $port = 3306, + String $user = 'datadog', + Variant[String, Integer] $port = 3306, Optional[String] $password = undef, Optional[String] $sock = undef, Array $tags = [], - $replication = '0', - $galera_cluster = '0', + String $replication = '0', + String $galera_cluster = '0', Boolean $extra_status_metrics = false, Boolean $extra_innodb_metrics = false, Boolean $extra_performance_metrics = false, Boolean $schema_size_metrics = false, Boolean $disable_innodb_metrics = false, Optional[Boolean] $dbm = undef, - Optional[Array] $queries = [], + Array $queries = [], Optional[Array] $instances = undef, - Optional[Array] $logs = [], - ) inherits datadog_agent::params { - require ::datadog_agent + Array $logs = [], +) inherits datadog_agent::params { + require datadog_agent if ($host == undef and $sock == undef) or - ($host != undef and $port == undef and $sock == undef) { + ($host != undef and $port == undef and $sock == undef) { fail('invalid MySQL configuration') } if !$instances and $host { $_instances = [{ - 'host' => $host, - 'password' => $password, - 'user' => $user, - 'port' => $port, - 'sock' => $sock, - 'tags' => $tags, - 'replication' => $replication, - 'galera_cluster' => $galera_cluster, - 'extra_status_metrics' => $extra_status_metrics, - 'extra_innodb_metrics' => $extra_innodb_metrics, - 'extra_performance_metrics' => $extra_performance_metrics, - 'schema_size_metrics' => $schema_size_metrics, - 'disable_innodb_metrics' => $disable_innodb_metrics, - 'dbm' => $dbm, - 'queries' => $queries, + 'host' => $host, + 'password' => $password, + 'user' => $user, + 'port' => $port, + 'sock' => $sock, + 'tags' => $tags, + 'replication' => $replication, + 'galera_cluster' => $galera_cluster, + 'extra_status_metrics' => $extra_status_metrics, + 'extra_innodb_metrics' => $extra_innodb_metrics, + 'extra_performance_metrics' => $extra_performance_metrics, + 'schema_size_metrics' => $schema_size_metrics, + 'disable_innodb_metrics' => $disable_innodb_metrics, + 'dbm' => $dbm, + 'queries' => $queries, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/mysql.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/mysql.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -129,7 +129,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -146,4 +146,3 @@ notify => Service[$datadog_agent::params::service_name], } } - diff --git a/manifests/integrations/network.pp b/manifests/integrations/network.pp index 3b409d63..e08acc0c 100644 --- a/manifests/integrations/network.pp +++ b/manifests/integrations/network.pp @@ -19,7 +19,7 @@ # } # # -class datadog_agent::integrations::network( +class datadog_agent::integrations::network ( Boolean $collect_connection_state = false, Boolean $collect_connection_queues = false, Array[String] $excluded_interfaces = [], @@ -39,13 +39,13 @@ Array[String] $metric_patterns_include = [], Array[String] $metric_patterns_exclude = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/network.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/network.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -54,7 +54,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { diff --git a/manifests/integrations/nginx.pp b/manifests/integrations/nginx.pp index 20853a77..0f867afe 100644 --- a/manifests/integrations/nginx.pp +++ b/manifests/integrations/nginx.pp @@ -59,17 +59,17 @@ # sourcecategory: 'http_web_access' # -class datadog_agent::integrations::nginx( +class datadog_agent::integrations::nginx ( Array $instances = [], Optional[Array] $logs = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/nginx.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/nginx.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -78,7 +78,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -92,6 +92,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/nginx.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/ntp.pp b/manifests/integrations/ntp.pp index 14251377..2251a847 100644 --- a/manifests/integrations/ntp.pp +++ b/manifests/integrations/ntp.pp @@ -23,20 +23,20 @@ # } # -class datadog_agent::integrations::ntp( - $offset_threshold = 60, - $host = undef, - $port = undef, - $version = undef, - $timeout = undef, +class datadog_agent::integrations::ntp ( + Integer $offset_threshold = 60, + String $host = undef, + Integer $port = undef, + String $version = undef, + Integer $timeout = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/ntp.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/ntp.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -45,7 +45,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -59,6 +59,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/ntp.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/oom_kill.pp b/manifests/integrations/oom_kill.pp index 62bb44a8..ac4d6e32 100644 --- a/manifests/integrations/oom_kill.pp +++ b/manifests/integrations/oom_kill.pp @@ -19,10 +19,10 @@ # } # -class datadog_agent::integrations::oom_kill( +class datadog_agent::integrations::oom_kill ( Array $instances = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $dst_dir = "${datadog_agent::params::conf_dir}/oom_kill.d" file { $dst_dir: @@ -31,7 +31,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" @@ -42,6 +42,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/oom_kill.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/pgbouncer.pp b/manifests/integrations/pgbouncer.pp index 1d9681d0..ba733bc7 100644 --- a/manifests/integrations/pgbouncer.pp +++ b/manifests/integrations/pgbouncer.pp @@ -43,7 +43,7 @@ # ], # } # -class datadog_agent::integrations::pgbouncer( +class datadog_agent::integrations::pgbouncer ( String $password = '', String $host = 'localhost', Variant[String, Integer] $port = '6432', @@ -51,13 +51,13 @@ Array $tags = [], Array $pgbouncers = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/pgbouncer.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/pgbouncer.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -66,7 +66,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { diff --git a/manifests/integrations/php_fpm.pp b/manifests/integrations/php_fpm.pp index 01fd401d..e1bd1dba 100644 --- a/manifests/integrations/php_fpm.pp +++ b/manifests/integrations/php_fpm.pp @@ -26,35 +26,35 @@ # } # -class datadog_agent::integrations::php_fpm( - $status_url = 'http://localhost/status', - $ping_url = 'http://localhost/ping', - $ping_reply = 'pong', - $http_host = undef, - $tags = [], - $instances = undef, - $use_fastcgi = 'false' +class datadog_agent::integrations::php_fpm ( + String $status_url = 'http://localhost/status', + String $ping_url = 'http://localhost/ping', + String $ping_reply = 'pong', + String $http_host = undef, + Array $tags = [], + Array $instances = undef, + String $use_fastcgi = 'false' ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances { $_instances = [{ - 'http_host' => $http_host, - 'status_url' => $status_url, - 'ping_url' => $ping_url, - 'ping_reply' => $ping_reply, - 'tags' => $tags, - 'use_fastcgi' => $use_fastcgi, + 'http_host' => $http_host, + 'status_url' => $status_url, + 'ping_url' => $ping_url, + 'ping_reply' => $ping_reply, + 'tags' => $tags, + 'use_fastcgi' => $use_fastcgi, }] } else { $_instances = $instances } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/php_fpm.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/php_fpm.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -63,7 +63,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -77,6 +77,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/php_fpm.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/postfix.pp b/manifests/integrations/postfix.pp index 1226b8dd..6d65825a 100644 --- a/manifests/integrations/postfix.pp +++ b/manifests/integrations/postfix.pp @@ -30,29 +30,29 @@ # class datadog_agent::integrations::postfix ( String $directory = '/var/spool/postfix', - Array $queues = [ 'active', 'deferred', 'incoming' ], - Optional[Array] $tags = [], + Array $queues = ['active', 'deferred', 'incoming'], + Array $tags = [], Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $directory { $_instances = [{ - 'directory' => $directory, - 'queues' => $queues, - 'tags' => $tags + 'directory' => $directory, + 'queues' => $queues, + 'tags' => $tags }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/postfix.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/postfix.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -61,7 +61,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -75,6 +75,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/postfix.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/postgres.pp b/manifests/integrations/postgres.pp index 00f3f22f..80fcae1b 100644 --- a/manifests/integrations/postgres.pp +++ b/manifests/integrations/postgres.pp @@ -82,7 +82,7 @@ # descriptors: # - ["tag_column", "tag_column.datadog.tag"] # -class datadog_agent::integrations::postgres( +class datadog_agent::integrations::postgres ( Optional[String] $password = undef, String $host = 'localhost', String $dbname = 'postgres', @@ -100,13 +100,13 @@ Hash $custom_metrics = {}, Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/postgres.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/postgres.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -115,7 +115,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -124,23 +124,23 @@ if !$instances and $host { $_instances = [{ - 'host' => $host, - 'password' => $password, - 'dbname' => $dbname, - 'port' => $port, - 'username' => $username, - 'ssl' => $ssl, - 'use_psycopg2' => $use_psycopg2, - 'tags' => $tags, - 'tables' => $tables, - 'custom_metrics' => $custom_metrics, - 'collect_function_metrics' => $collect_function_metrics, - 'collect_count_metrics' => $collect_count_metrics, - 'collect_activity_metrics' => $collect_activity_metrics, - 'collect_database_size_metrics' => $collect_database_size_metrics, - 'collect_default_database' => $collect_default_database, + 'host' => $host, + 'password' => $password, + 'dbname' => $dbname, + 'port' => $port, + 'username' => $username, + 'ssl' => $ssl, + 'use_psycopg2' => $use_psycopg2, + 'tags' => $tags, + 'tables' => $tables, + 'custom_metrics' => $custom_metrics, + 'collect_function_metrics' => $collect_function_metrics, + 'collect_count_metrics' => $collect_count_metrics, + 'collect_activity_metrics' => $collect_activity_metrics, + 'collect_database_size_metrics' => $collect_database_size_metrics, + 'collect_default_database' => $collect_default_database, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances diff --git a/manifests/integrations/postgres_custom_metric.pp b/manifests/integrations/postgres_custom_metric.pp index 91a7b913..92011034 100644 --- a/manifests/integrations/postgres_custom_metric.pp +++ b/manifests/integrations/postgres_custom_metric.pp @@ -15,13 +15,12 @@ # $descriptor: # an array that maps an sql column's to a tag. Each descriptor consists of two # fields -- column name, and datadog tag. -define datadog_agent::integrations::postgres_custom_metric( +define datadog_agent::integrations::postgres_custom_metric ( String $query, Hash $metrics, Boolean $relation = false, Array $descriptors = [], ) { - if $query !~ '^.*%s.*$' { fail('custom_metrics require %s for metric substitution') } diff --git a/manifests/integrations/process.pp b/manifests/integrations/process.pp index c69a3505..22777c5a 100644 --- a/manifests/integrations/process.pp +++ b/manifests/integrations/process.pp @@ -40,12 +40,12 @@ # # -class datadog_agent::integrations::process( +class datadog_agent::integrations::process ( Boolean $hiera_processes = false, - $init_config = {}, + Hash $init_config = {}, Array $processes = [], - ) inherits datadog_agent::params { - require ::datadog_agent +) inherits datadog_agent::params { + require datadog_agent if $hiera_processes { $local_processes = lookup({ 'name' => 'datadog_agent::integrations::process::processes', 'merge' => 'unique', 'default_value' => $processes }) @@ -54,10 +54,10 @@ } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/process.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/process.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -66,7 +66,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -74,12 +74,12 @@ } file { $dst: - ensure => $local_processes.length ? { 0 => absent, default => file}, + ensure => $local_processes.length ? { 0 => 'absent', default => file }, owner => $datadog_agent::dd_user, group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/process.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/rabbitmq.pp b/manifests/integrations/rabbitmq.pp index 66313f84..dc551f2a 100644 --- a/manifests/integrations/rabbitmq.pp +++ b/manifests/integrations/rabbitmq.pp @@ -52,8 +52,8 @@ class datadog_agent::integrations::rabbitmq ( Optional[String] $url = undef, - Optional[String] $username = 'guest', - Optional[String] $password = 'guest', + String $username = 'guest', + String $password = 'guest', Boolean $ssl_verify = true, Boolean $tag_families = false, Array $nodes = [], @@ -64,14 +64,13 @@ Array $exchanges = [], Array $exchanges_regexes = [], ) inherits datadog_agent::params { - - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/rabbitmq.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/rabbitmq.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -80,7 +79,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { diff --git a/manifests/integrations/redis.pp b/manifests/integrations/redis.pp index b3c27760..9e845a42 100644 --- a/manifests/integrations/redis.pp +++ b/manifests/integrations/redis.pp @@ -40,7 +40,7 @@ # warn_on_missing_keys: true # command_stats: false # -class datadog_agent::integrations::redis( +class datadog_agent::integrations::redis ( String $host = 'localhost', String $password = '', Variant[String, Integer] $port = '6379', @@ -53,10 +53,10 @@ Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if $ports == undef { - $_ports = [ $port ] + $_ports = [$port] } else { $_ports = $ports } @@ -75,10 +75,10 @@ } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/redisdb.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/redisdb.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -87,7 +87,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -96,7 +96,7 @@ if !$instances and $host { $_instances = $_port_instances - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances @@ -109,6 +109,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/redisdb.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/riak.pp b/manifests/integrations/riak.pp index 5d5ab753..3db23b5b 100644 --- a/manifests/integrations/riak.pp +++ b/manifests/integrations/riak.pp @@ -18,17 +18,17 @@ # url => 'http://localhost:8098/stats', # } # -class datadog_agent::integrations::riak( +class datadog_agent::integrations::riak ( String $url = 'http://localhost:8098/stats', Array $tags = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/riak.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/riak.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -37,7 +37,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -52,6 +52,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/riak.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/snmp.pp b/manifests/integrations/snmp.pp index 6527859d..882fa51b 100755 --- a/manifests/integrations/snmp.pp +++ b/manifests/integrations/snmp.pp @@ -50,17 +50,16 @@ # ], # } - class datadog_agent::integrations::snmp ( - $mibs_folder = undef, - $ignore_nonincreasing_oid = false, - $init_config = {}, - $instances = [], - $snmp_v1_instances = [], - $snmp_v2_instances = [], - $snmp_v3_instances = [], + Any $mibs_folder = undef, + Boolean $ignore_nonincreasing_oid = false, + Hash $init_config = {}, + Array $instances = [], + Array $snmp_v1_instances = [], + Array $snmp_v2_instances = [], + Array $snmp_v3_instances = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $versioned_instances = { 1 => $snmp_v1_instances, @@ -69,10 +68,10 @@ } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/snmp.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/snmp.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -81,7 +80,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -95,6 +94,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/snmp.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/solr.pp b/manifests/integrations/solr.pp index 4c6db020..405bec8f 100644 --- a/manifests/integrations/solr.pp +++ b/manifests/integrations/solr.pp @@ -26,23 +26,23 @@ # port => 8081, # } # -class datadog_agent::integrations::solr( - $hostname = 'localhost', - $port = 7199, - $username = undef, - $password = undef, - $java_bin_path = undef, - $trust_store_path = undef, - $trust_store_password = undef, - $tags = {}, +class datadog_agent::integrations::solr ( + String $hostname = 'localhost', + Integer $port = 7199, + String $username = undef, + Any $password = undef, + String $java_bin_path = undef, + String $trust_store_path = undef, + Any $trust_store_password = undef, + Hash $tags = {}, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/solr.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/solr.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -51,7 +51,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -65,7 +65,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/solr.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } - } diff --git a/manifests/integrations/ssh.pp b/manifests/integrations/ssh.pp index 697497bc..88c51945 100644 --- a/manifests/integrations/ssh.pp +++ b/manifests/integrations/ssh.pp @@ -26,22 +26,22 @@ # } # -class datadog_agent::integrations::ssh( - $host = $trusted['certname'], - $port = 22, - $username = $datadog_agent::dd_user, - $password = undef, - $sftp_check = true, - $private_key_file = undef, - $add_missing_keys = true, +class datadog_agent::integrations::ssh ( + String $host = $trusted['certname'], + Integer $port = 22, + String $username = $datadog_agent::dd_user, + Any $password = undef, + Boolean $sftp_check = true, + String $private_key_file = undef, + Boolean $add_missing_keys = true, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/ssh.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/ssh_check.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -50,7 +50,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -64,6 +64,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/ssh.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/supervisord.pp b/manifests/integrations/supervisord.pp index 6ad15166..3d547168 100644 --- a/manifests/integrations/supervisord.pp +++ b/manifests/integrations/supervisord.pp @@ -42,15 +42,15 @@ # class datadog_agent::integrations::supervisord ( - $instances = [{'servername' => 'server0', 'hostname' => 'localhost', 'port' => '9001'}], + Array $instances = [{ 'servername' => 'server0', 'hostname' => 'localhost', 'port' => '9001' }], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/supervisord.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/supervisord.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -59,7 +59,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -73,6 +73,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/supervisord.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/system_core.pp b/manifests/integrations/system_core.pp index 19a0a4e2..0861b5d2 100644 --- a/manifests/integrations/system_core.pp +++ b/manifests/integrations/system_core.pp @@ -7,13 +7,13 @@ # # class datadog_agent::integrations::system_core inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/system_core.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/system_core.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -22,7 +22,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -30,12 +30,12 @@ } file { $dst: - ensure => file, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_file, - content => template('datadog_agent/agent-conf.d/system_core.yaml.erb'), - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + ensure => file, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_file, + content => template('datadog_agent/agent-conf.d/system_core.yaml.erb'), + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/tcp_check.pp b/manifests/integrations/tcp_check.pp index bd5be538..0575002c 100644 --- a/manifests/integrations/tcp_check.pp +++ b/manifests/integrations/tcp_check.pp @@ -84,44 +84,43 @@ # }] # } - class datadog_agent::integrations::tcp_check ( - $check_name = undef, - $host = undef, - $port = undef, - Integer $timeout = 10, - $threshold = undef, - $window = undef, - $collect_response_time = undef, - $skip_event = undef, + String $check_name = undef, + String $host = undef, + String $port = undef, + Integer $timeout = 10, + Integer $threshold = undef, + Integer $window = undef, + Integer $collect_response_time = undef, + Integer $skip_event = undef, Array $tags = [], Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $host { $_instances = [{ - 'check_name' => $check_name, - 'host' => $host, - 'port' => $port, - 'timeout' => $timeout, - 'threshold' => $threshold, - 'window' => $window, - 'collect_response_time' => $collect_response_time, - 'skip_event' => $skip_event, - 'tags' => $tags, + 'check_name' => $check_name, + 'host' => $host, + 'port' => $port, + 'timeout' => $timeout, + 'threshold' => $threshold, + 'window' => $window, + 'collect_response_time' => $collect_response_time, + 'skip_event' => $skip_event, + 'tags' => $tags, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/tcp_check.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/tcp_check.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -130,7 +129,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -144,6 +143,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/tcp_check.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/tomcat.pp b/manifests/integrations/tomcat.pp index 5092603f..6b5ce7e7 100644 --- a/manifests/integrations/tomcat.pp +++ b/manifests/integrations/tomcat.pp @@ -28,25 +28,24 @@ # port => 8081, # } # -class datadog_agent::integrations::tomcat( - $hostname = 'localhost', - $port = 7199, - $jmx_url = undef, - $username = undef, - $password = undef, - $java_bin_path = undef, - $trust_store_path = undef, - $trust_store_password = undef, - $tags = {}, +class datadog_agent::integrations::tomcat ( + String $hostname = 'localhost', + Integer $port = 7199, + String $jmx_url = undef, + String $username = undef, + Any $password = undef, + String $java_bin_path = undef, + String $trust_store_path = undef, + Any $trust_store_password = undef, + Hash $tags = {}, ) inherits datadog_agent::params { - require ::datadog_agent - + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/tomcat.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/tomcat.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -55,7 +54,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -69,7 +68,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/tomcat.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } - } diff --git a/manifests/integrations/twemproxy.pp b/manifests/integrations/twemproxy.pp index f5f065c2..7499d29e 100644 --- a/manifests/integrations/twemproxy.pp +++ b/manifests/integrations/twemproxy.pp @@ -23,29 +23,29 @@ # ] # } # -class datadog_agent::integrations::twemproxy( - $host = 'localhost', - $port = '22222', - $instances = undef, +class datadog_agent::integrations::twemproxy ( + String $host = 'localhost', + String $port = '22222', + Array $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $host { $_instances = [{ - 'host' => $host, - 'port' => $port, + 'host' => $host, + 'port' => $port, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/twemproxy.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/twemproxy.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -54,7 +54,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -68,6 +68,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/twemproxy.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/varnish.pp b/manifests/integrations/varnish.pp index 95e31e8a..0da6baf5 100644 --- a/manifests/integrations/varnish.pp +++ b/manifests/integrations/varnish.pp @@ -22,17 +22,17 @@ # } # class datadog_agent::integrations::varnish ( - $varnishstat = '/usr/bin/varnishstat', - $instance_name = undef, - $tags = [], + String $varnishstat = '/usr/bin/varnishstat', + String $instance_name = undef, + Array $tags = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/varnish.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/varnish.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -41,7 +41,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -55,6 +55,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/varnish.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/zk.pp b/manifests/integrations/zk.pp index 0e3fad09..76af8417 100644 --- a/manifests/integrations/zk.pp +++ b/manifests/integrations/zk.pp @@ -28,15 +28,15 @@ # } # class datadog_agent::integrations::zk ( - $servers = [{'host' => 'localhost', 'port' => '2181'}] + Array $servers = [{ 'host' => 'localhost', 'port' => '2181' }] ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/zk.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/zk.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -45,7 +45,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -59,6 +59,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/zk.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/params.pp b/manifests/params.pp index 0483a91d..4dc51c67 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -28,7 +28,7 @@ case $facts['os']['name'] { 'Ubuntu','Debian','Raspbian' : { $rubydev_package = 'ruby-dev' - case $::operatingsystemrelease{ + case $facts['os']['release']['full'] { '14.04': { # Specific ruby/rubygems package name for Ubuntu 14.04 $ruby_package = 'ruby' @@ -87,5 +87,4 @@ } default: { fail("Class[datadog_agent]: Unsupported operatingsystem: ${facts['os']['name']}") } } - } diff --git a/manifests/redhat.pp b/manifests/redhat.pp index eb2bf2b9..7ab161fe 100644 --- a/manifests/redhat.pp +++ b/manifests/redhat.pp @@ -3,7 +3,7 @@ # This class contains the DataDog agent installation mechanism for Red Hat derivatives # -class datadog_agent::redhat( +class datadog_agent::redhat ( Integer $agent_major_version = $datadog_agent::params::default_agent_major_version, Optional[String] $agent_repo_uri = undef, Boolean $manage_repo = true, @@ -11,18 +11,16 @@ String $agent_flavor = $datadog_agent::params::package_name, Optional[Boolean] $rpm_repo_gpgcheck = undef, ) inherits datadog_agent::params { - if $manage_repo { - $all_keys = [ - 'https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public', - 'https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public', - 'https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public', - 'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public', ] #In this regex, version '1:6.15.0~rc.1-1' would match as $1='1:', $2='6', $3='15', $4='0', $5='~rc.1', $6='1' if $agent_version =~ /([0-9]+:)?([0-9]+)\.([0-9]+)\.([0-9]+)((?:~|-)[^0-9\s-]+[^-\s]*)?(?:-([0-9]+))?/ or $agent_version == 'latest' { - if $agent_major_version > 5 and ($agent_version == 'latest' or 0 + $3 > 35) { + if versioncmp($agent_major_version, '5') > 0 and ($agent_version == 'latest' or 0 + $3 > 35) { $keys = $all_keys[0,3] } else { $keys = $all_keys @@ -34,7 +32,7 @@ if ($rpm_repo_gpgcheck != undef) { $repo_gpgcheck = $rpm_repo_gpgcheck } else { - if ($agent_repo_uri == undef) and ($agent_major_version > 5) { + if ($agent_repo_uri == undef) and (versioncmp($agent_major_version, '5') > 0) { case $facts['os']['name'] { 'RedHat', 'CentOS', 'OracleLinux': { # disable repo_gpgcheck on 8.1 because of https://bugzilla.redhat.com/show_bug.cgi?id=1792506 @@ -51,7 +49,6 @@ } else { $repo_gpgcheck = false } - } case $agent_major_version { @@ -85,15 +82,15 @@ ensure => absent, } - yumrepo {'datadog5': + yumrepo { 'datadog5': ensure => absent, } - yumrepo {'datadog6': + yumrepo { 'datadog6': ensure => absent, } - yumrepo {'datadog': + yumrepo { 'datadog': enabled => 1, gpgcheck => 1, gpgkey => join($gpgkeys, "\n "), diff --git a/manifests/reports.pp b/manifests/reports.pp index ad3fb119..1fc6f072 100644 --- a/manifests/reports.pp +++ b/manifests/reports.pp @@ -15,53 +15,49 @@ # # Sample Usage: # -class datadog_agent::reports( - $api_key, - $puppetmaster_user, - $dogapi_version, - $manage_dogapi_gem = true, - $hostname_extraction_regex = undef, - $proxy_http = undef, - $proxy_https = undef, - $report_fact_tags = [], - $report_trusted_fact_tags = [], - $datadog_site = 'https://api.datadoghq.com', - $puppet_gem_provider = $datadog_agent::params::gem_provider, +class datadog_agent::reports ( + String $api_key, + String $puppetmaster_user, + String $dogapi_version, + Boolean $manage_dogapi_gem = true, + String $hostname_extraction_regex = undef, + String $proxy_http = undef, + String $proxy_https = undef, + Array $report_fact_tags = [], + Array $report_trusted_fact_tags = [], + String $datadog_site = 'https://api.datadoghq.com', + String $puppet_gem_provider = $datadog_agent::params::gem_provider, ) inherits datadog_agent::params { - if ($facts['os']['name'] == 'Windows') { - fail('Reporting is not yet supported from a Windows host') - } else { - - require ::datadog_agent + require datadog_agent if $manage_dogapi_gem { $rubydev_package = $datadog_agent::params::rubydev_package # check to make sure that you're not installing rubydev somewhere else if ! defined(Package[$rubydev_package]) { - package {$rubydev_package: + package { $rubydev_package: ensure => installed, - before => Package['dogapi'] + before => Package['dogapi'], } } if (! defined(Package['rubygems'])) { package { 'ruby': ensure => 'installed', - name => $datadog_agent::params::ruby_package + name => $datadog_agent::params::ruby_package, } package { 'rubygems': ensure => 'installed', name => $datadog_agent::params::rubygems_package, - require => Package['ruby'] + require => Package['ruby'], } } - package{ 'dogapi': + package { 'dogapi': ensure => $dogapi_version, provider => $puppet_gem_provider, } @@ -75,6 +71,5 @@ mode => '0640', require => File['/etc/datadog-agent'], } - } } diff --git a/manifests/security_agent.pp b/manifests/security_agent.pp index eceb1203..9e0ed4e5 100644 --- a/manifests/security_agent.pp +++ b/manifests/security_agent.pp @@ -1,4 +1,4 @@ -class datadog_agent::security_agent( +class datadog_agent::security_agent ( Boolean $enabled = false, Optional[String] $socket = undef, @@ -7,16 +7,14 @@ Optional[String] $service_provider = undef, ) inherits datadog_agent::params { - $securityagent_config = { 'runtime_security_config' => { 'enabled' => $enabled, - 'socket' => $socket, + 'socket' => $socket, }, } if $facts['os']['name'] == 'Windows' { - file { 'C:/ProgramData/Datadog/security-agent.yaml': owner => $datadog_agent::params::dd_user, group => $datadog_agent::params::dd_group, @@ -24,9 +22,7 @@ content => template('datadog_agent/security-agent.yaml.erb'), require => File['C:/ProgramData/Datadog'], } - } else { - if $service_provider { service { $datadog_agent::params::securityagent_service_name: ensure => $service_ensure, @@ -55,5 +51,4 @@ require => File['/etc/datadog-agent'], } } - } diff --git a/manifests/service.pp b/manifests/service.pp index fbd74eef..96af7d98 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -3,20 +3,19 @@ # This class declares the datadog-agent service # -class datadog_agent::service( - $service_ensure = 'running', +class datadog_agent::service ( + String $service_ensure = 'running', Variant[Boolean, Enum['manual', 'mask', 'delayed']] $service_enable = true, Optional[String] $service_provider = undef, String $agent_flavor = $datadog_agent::params::package_name, ) inherits datadog_agent::params { - if ($facts['os']['name'] == 'Windows') { - service { $datadog_agent::params::service_name: - ensure => $service_ensure, - enable => $service_enable, - restart => ['powershell', '-Command', 'Restart-Service -Force DatadogAgent'], # Force restarts dependent services - require => Package[$datadog_agent::params::package_name] - } + service { $datadog_agent::params::service_name: + ensure => $service_ensure, + enable => $service_enable, + restart => ['powershell', '-Command', 'Restart-Service -Force DatadogAgent'], # Force restarts dependent services + require => Package[$datadog_agent::params::package_name], + } } else { if $service_provider { service { $datadog_agent::params::service_name: @@ -37,6 +36,4 @@ } } } - - } diff --git a/manifests/suse.pp b/manifests/suse.pp index 37626817..4a928b52 100644 --- a/manifests/suse.pp +++ b/manifests/suse.pp @@ -3,7 +3,7 @@ # This class contains the DataDog agent installation mechanism for SUSE distributions # -class datadog_agent::suse( +class datadog_agent::suse ( Integer $agent_major_version = $datadog_agent::params::default_agent_major_version, String $agent_version = $datadog_agent::params::agent_version, String $release = $datadog_agent::params::apt_default_release, @@ -11,7 +11,6 @@ String $agent_flavor = $datadog_agent::params::package_name, Optional[Boolean] $rpm_repo_gpgcheck = undef, ) inherits datadog_agent::params { - $current_key = 'https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public' $all_keys = [ $current_key, @@ -21,11 +20,11 @@ ] #In this regex, version '1:6.15.0~rc.1-1' would match as $1='1:', $2='6', $3='15', $4='0', $5='~rc.1', $6='1' if $agent_version =~ /([0-9]+:)?([0-9]+)\.([0-9]+)\.([0-9]+)((?:~|-)[^0-9\s-]+[^-\s]*)?(?:-([0-9]+))?/ or $agent_version == 'latest' { - if $agent_major_version > 5 and ($agent_version == 'latest' or 0 + $3 > 35) { - $keys_to_use = $all_keys[0,3] - } else { - $keys_to_use = $all_keys - } + if versioncmp($agent_major_version, '5') > 0 and ($agent_version == 'latest' or 0 + $3 > 35) { + $keys_to_use = $all_keys[0,3] + } else { + $keys_to_use = $all_keys + } } else { $keys_to_use = $all_keys } @@ -41,10 +40,10 @@ } case $agent_major_version { - 5 : { fail('Agent v5 package not available in SUSE') } - 6 : { $gpgkeys = $keys_to_use } - 7 : { $gpgkeys = $keys_to_use } - default: { fail('invalid agent_major_version') } + 5 : { fail('Agent v5 package not available in SUSE') } + 6 : { $gpgkeys = $keys_to_use } + 7 : { $gpgkeys = $keys_to_use } + default: { fail('invalid agent_major_version') } } if ($agent_repo_uri != undef) { @@ -101,5 +100,4 @@ package { $agent_flavor: ensure => $agent_version, } - } diff --git a/manifests/system_probe.pp b/manifests/system_probe.pp index df0443a5..88a157c8 100644 --- a/manifests/system_probe.pp +++ b/manifests/system_probe.pp @@ -5,21 +5,19 @@ # to 'true on the datadog_agent class. # -class datadog_agent::system_probe( - Boolean $enabled = false, - Boolean $network_enabled = false, - Boolean $service_monitoring_enabled = false, - Optional[String] $log_file = undef, - Optional[String] $sysprobe_socket = undef, - Optional[Boolean] $enable_oom_kill = false, +class datadog_agent::system_probe ( + Boolean $enabled = false, + Boolean $network_enabled = false, + Boolean $service_monitoring_enabled = false, + Optional[String] $log_file = undef, + Optional[String] $sysprobe_socket = undef, + Boolean $enable_oom_kill = false, Optional[Hash] $runtime_security_config = undef, Boolean $service_enable = true, String $service_ensure = 'running', Optional[String] $service_provider = undef, ) inherits datadog_agent::params { - - $sysprobe_config = { 'system_probe_config' => { 'enabled' => $enabled, @@ -45,9 +43,7 @@ require => File['C:/ProgramData/Datadog'], notify => Service[$datadog_agent::params::service_name], } - } else { - if $service_provider { service { $datadog_agent::params::sysprobe_service_name: ensure => $service_ensure, @@ -76,5 +72,4 @@ require => File['/etc/datadog-agent'], } } - } diff --git a/manifests/tag5.pp b/manifests/tag5.pp index 9134b421..33b1b463 100644 --- a/manifests/tag5.pp +++ b/manifests/tag5.pp @@ -1,18 +1,17 @@ # Allow custom tags via a define -define datadog_agent::tag5( - $tag_name = $name, - $lookup_fact = false, -){ - - if $lookup_fact{ +define datadog_agent::tag5 ( + String $tag_name = $name, + Boolean $lookup_fact = false, +) { + if $lookup_fact { $value = getvar($tag_name) - if is_array($value){ + if is_array($value) { $tags = prefix($value, "${tag_name}:") - datadog_agent::tag5{$tags: } + datadog_agent::tag5 { $tags: } } else { if $value { - concat::fragment{ "datadog tag ${tag_name}:${value}": + concat::fragment { "datadog tag ${tag_name}:${value}": target => '/etc/dd-agent/datadog.conf', content => "${tag_name}:${value}, ", order => '03', @@ -20,11 +19,10 @@ } } } else { - concat::fragment{ "datadog tag ${tag_name}": + concat::fragment { "datadog tag ${tag_name}": target => '/etc/dd-agent/datadog.conf', content => "${tag_name}, ", order => '03', } } - } diff --git a/manifests/ubuntu.pp b/manifests/ubuntu.pp index 806cbef8..483fd3ca 100644 --- a/manifests/ubuntu.pp +++ b/manifests/ubuntu.pp @@ -3,23 +3,22 @@ # This class contains the DataDog agent installation mechanism for Debian derivatives # -class datadog_agent::ubuntu( - Integer $agent_major_version = $datadog_agent::params::default_agent_major_version, - String $agent_version = $datadog_agent::params::agent_version, - Optional[String] $agent_repo_uri = undef, - String $release = $datadog_agent::params::apt_default_release, - Boolean $skip_apt_key_trusting = false, - String $agent_flavor = $datadog_agent::params::package_name, - Optional[String] $apt_trusted_d_keyring = '/etc/apt/trusted.gpg.d/datadog-archive-keyring.gpg', - Optional[String] $apt_usr_share_keyring = '/usr/share/keyrings/datadog-archive-keyring.gpg', - Optional[Hash[String, String]] $apt_default_keys = { +class datadog_agent::ubuntu ( + Integer $agent_major_version = $datadog_agent::params::default_agent_major_version, + String $agent_version = $datadog_agent::params::agent_version, + Optional[String] $agent_repo_uri = undef, + String $release = $datadog_agent::params::apt_default_release, + Boolean $skip_apt_key_trusting = false, + String $agent_flavor = $datadog_agent::params::package_name, + String $apt_trusted_d_keyring = '/etc/apt/trusted.gpg.d/datadog-archive-keyring.gpg', + String $apt_usr_share_keyring = '/usr/share/keyrings/datadog-archive-keyring.gpg', + Hash[String, String] $apt_default_keys = { 'DATADOG_APT_KEY_CURRENT.public' => 'https://keys.datadoghq.com/DATADOG_APT_KEY_CURRENT.public', '5F1E256061D813B125E156E8E6266D4AC0962C7D' => 'https://keys.datadoghq.com/DATADOG_APT_KEY_C0962C7D.public', 'D75CEA17048B9ACBF186794B32637D44F14F620E' => 'https://keys.datadoghq.com/DATADOG_APT_KEY_F14F620E.public', 'A2923DFF56EDA6E76E55E492D3A80E30382E94DE' => 'https://keys.datadoghq.com/DATADOG_APT_KEY_382E94DE.public', }, ) inherits datadog_agent::params { - if $agent_version =~ /^[0-9]+\.[0-9]+\.[0-9]+((?:~|-)[^0-9\s-]+[^-\s]*)?$/ { $platform_agent_version = "1:${agent_version}-1" } @@ -55,15 +54,15 @@ exec { "ensure key ${key_fingerprint} is imported in APT keyring": command => "/bin/cat /tmp/${key_fingerprint} | gpg --import --batch --no-default-keyring --keyring ${apt_usr_share_keyring}", # the second part extracts the fingerprint of the key from output like "fpr::::A2923DFF56EDA6E76E55E492D3A80E30382E94DE:" - unless => @("CMD"/L) + unless => "@(\"CMD\"/L) /usr/bin/gpg --no-default-keyring --keyring ${apt_usr_share_keyring} --list-keys --with-fingerprint --with-colons | grep \ $(cat /tmp/${key_fingerprint} | gpg --with-colons --with-fingerprint 2>/dev/null | grep 'fpr:' | sed 's|^fpr||' | tr -d ':') - | CMD + | CMD", } } if ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '16') == -1) or - ($facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['full'], '9') == -1) { + ($facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['full'], '9') == -1) { file { $apt_trusted_d_keyring: mode => '0644', source => "file://${apt_usr_share_keyring}", @@ -104,12 +103,12 @@ package { $agent_flavor: ensure => $platform_agent_version, require => [Apt::Source['datadog'], - Class['apt::update']], + Class['apt::update']], } package { 'datadog-signing-keys': ensure => 'latest', require => [Apt::Source['datadog'], - Class['apt::update']], + Class['apt::update']], } } diff --git a/manifests/ubuntu_installer.pp b/manifests/ubuntu_installer.pp index 9f4ce9e2..b9ad851c 100644 --- a/manifests/ubuntu_installer.pp +++ b/manifests/ubuntu_installer.pp @@ -88,10 +88,10 @@ exec { "ensure key ${key_fingerprint} is imported in APT keyring": command => "/bin/cat /tmp/${key_fingerprint} | gpg --import --batch --no-default-keyring --keyring ${apt_usr_share_keyring}", # the second part extracts the fingerprint of the key from output like "fpr::::A2923DFF56EDA6E76E55E492D3A80E30382E94DE:" - unless => @("CMD"/L) + unless => "@(\"CMD\"/L) /usr/bin/gpg --no-default-keyring --keyring ${apt_usr_share_keyring} --list-keys --with-fingerprint --with-colons | grep \ $(cat /tmp/${key_fingerprint} | gpg --with-colons --with-fingerprint 2>/dev/null | grep 'fpr:' | sed 's|^fpr||' | tr -d ':') - | CMD + | CMD", } } if ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '16') == -1) or diff --git a/manifests/windows.pp b/manifests/windows.pp index 15e014af..07864727 100644 --- a/manifests/windows.pp +++ b/manifests/windows.pp @@ -3,7 +3,7 @@ # This class contains the DataDog agent installation mechanism for Windows # -class datadog_agent::windows( +class datadog_agent::windows ( Integer $agent_major_version = $datadog_agent::params::default_agent_major_version, String $agent_version = $datadog_agent::params::agent_version, Optional[String] $agent_repo_uri = undef, @@ -18,7 +18,6 @@ Optional[String] $ddagentuser_name = undef, Optional[String] $ddagentuser_password = undef, ) inherits datadog_agent::params { - $msi_full_path = "${msi_location}/datadog-agent-${agent_major_version}-${agent_version}.amd64.msi" if ($agent_repo_uri != undef) { @@ -46,16 +45,16 @@ exec { 'assert-acceptable-msi':, command => 'Exit 1', - unless => @(ACCEPTABLE), - $blacklist = '928b00d2f952219732cda9ae0515351b15f9b9c1ea1d546738f9dc0fda70c336','78b2bb2b231bcc185eb73dd367bfb6cb8a5d45ba93a46a7890fd607dc9188194'; - $fileStream = [system.io.file]::openread('${msi_full_path}'); - $hasher = [System.Security.Cryptography.HashAlgorithm]::create('sha256'); - $hash = $hasher.ComputeHash($fileStream); - $fileStream.close(); - $fileStream.dispose(); - $hexhash = [system.bitconverter]::tostring($hash).ToLower().replace('-',''); - if ($blacklist.Contains($hexhash)) { Exit 1 } else { Exit 0 } - | ACCEPTABLE + unless => "@(ACCEPTABLE), + \$blacklist = '928b00d2f952219732cda9ae0515351b15f9b9c1ea1d546738f9dc0fda70c336','78b2bb2b231bcc185eb73dd367bfb6cb8a5d45ba93a46a7890fd607dc9188194'; + \$fileStream = [system.io.file]::openread('${msi_full_path}'); + \$hasher = [System.Security.Cryptography.HashAlgorithm]::create('sha256'); + \$hash = \$hasher.ComputeHash(\$fileStream); + \$fileStream.close(); + \$fileStream.dispose(); + \$hexhash = [system.bitconverter]::tostring(\$hash).ToLower().replace('-',''); + if (\$blacklist.Contains(\$hexhash)) { Exit 1 } else { Exit 0 } + | ACCEPTABLE", provider => 'powershell', logoutput => 'on_failure', require => File['installer'], @@ -71,16 +70,15 @@ $hostname_option = $hostname ? { '' => {}, default => { 'HOSTNAME' => $hostname } } $npm_install_option = $npm_install ? { false => {}, true => { 'ADDLOCAL' => 'MainApplication,NPM' } } - $ddagentuser_name_option = $ddagentuser_name ? { undef => {}, default => { 'DDAGENTUSER_NAME' => $ddagentuser_name}} - $ddagentuser_password_option = ($ddagentuser_name != undef and $ddagentuser_password != undef) ? { true => {'DDAGENTUSER_PASSWORD' => $ddagentuser_password}, false => {}} + $ddagentuser_name_option = $ddagentuser_name ? { undef => {}, default => { 'DDAGENTUSER_NAME' => $ddagentuser_name } } + $ddagentuser_password_option = ($ddagentuser_name != undef and $ddagentuser_password != undef) ? { true => { 'DDAGENTUSER_PASSWORD' => $ddagentuser_password }, false => {} } package { $datadog_agent::params::package_name: ensure => $ensure_version, provider => 'windows', source => $msi_full_path, - install_options => ['/norestart', {'APIKEY' => $api_key, 'TAGS' => $tags_quote_wrap} + $npm_install_option + $hostname_option + $ddagentuser_name_option + $ddagentuser_password_option] + install_options => ['/norestart', { 'APIKEY' => $api_key, 'TAGS' => $tags_quote_wrap } + $npm_install_option + $hostname_option + $ddagentuser_name_option + $ddagentuser_password_option], } - } else { exec { 'datadog_6_14_fix': command => "((New-Object System.Net.WebClient).DownloadFile('https://s3.amazonaws.com/ddagent-windows-stable/scripts/fix_6_14.ps1', \$env:temp + '\\fix_6_14.ps1')); &\$env:temp\\fix_6_14.ps1", @@ -93,6 +91,5 @@ uninstall_options => ['/quiet'], subscribe => Exec['datadog_6_14_fix'], } - } } diff --git a/metadata.json b/metadata.json index 43374b44..2ed70307 100644 --- a/metadata.json +++ b/metadata.json @@ -10,7 +10,7 @@ "dependencies": [ { "name": "puppetlabs/stdlib", - "version_requirement": ">=4.25.0 <9.0.0" + "version_requirement": ">=4.25.0 <10.0.0" }, { "name": "puppetlabs/concat", @@ -148,11 +148,11 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">=4.6.0 <8.0.0" + "version_requirement": ">=4.6.0 < 9.0.0" } ], "description": "This will install the Datadog monitoring agent. Sign up and get your API key at: http://www.datadoghq.com", - "pdk-version": "1.15.0", - "template-url": "https://github.com/puppetlabs/pdk-templates#1.15.0", - "template-ref": "tags/1.15.0-0-g0bc522e" + "pdk-version": "3.4.0", + "template-url": "https://github.com/puppetlabs/pdk-templates#3.4.0", + "template-ref": "tags/3.4.0-0-gd3cc13f" } 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/default_facts.yml b/spec/default_facts.yml new file mode 100644 index 00000000..3346c394 --- /dev/null +++ b/spec/default_facts.yml @@ -0,0 +1,9 @@ +# Use default_module_facts.yml for module specific facts. +# +# Facts specified here will override the values provided by rspec-puppet-facts. +--- +networking: + ip: "172.16.254.254" + ip6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" + mac: "AA:AA:AA:AA:AA:AA" +is_pe: false diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8bf6b938..cb40a30f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,15 @@ +# frozen_string_literal: true + +RSpec.configure do |c| + c.mock_with :rspec +end + require 'puppetlabs_spec_helper/module_spec_helper' +require 'rspec-puppet-facts' + +require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb')) + +include RspecPuppetFacts DEBIAN_OS = ['Ubuntu', 'Debian'].freeze REDHAT_OS = ['RedHat', 'CentOS', 'Fedora', 'Amazon', 'Scientific', 'OracleLinux', 'AlmaLinux', 'Rocky'].freeze @@ -60,30 +71,88 @@ def getosrelease(operatingsystem) end end -RSpec.configure do |c| - c.default_facts = { - 'architecture' => 'x86_64', - 'operatingsystem' => (RSpec::Support::OS.windows? ? 'Windows' : 'Ubuntu'), - 'osfamily' => (RSpec::Support::OS.windows? ? 'windows' : 'Debian'), - 'operatingsystemmajrelease' => (RSpec::Support::OS.windows? ? '2019' : '14'), - 'operatingsystemminrelease' => (RSpec::Support::OS.windows? ? 'SP1' : '04'), - 'operatingsystemrelease' => (RSpec::Support::OS.windows? ? '2019 SP1' : '14.04'), - 'lsbdistrelease' => (RSpec::Support::OS.windows? ? '2019 SP1' : '14.04'), - 'lsbdistcodename' => (RSpec::Support::OS.windows? ? '2019' : '14.04'), - 'os' => { - 'architecture' => 'x86_64', - 'name' => (RSpec::Support::OS.windows? ? 'Windows' : 'Ubuntu'), - 'family' => (RSpec::Support::OS.windows? ? 'windows' : 'Debian'), - 'release' => { - 'major' => (RSpec::Support::OS.windows? ? '2019' : '14'), - 'minor' => (RSpec::Support::OS.windows? ? 'SP1' : '04'), - 'full' => (RSpec::Support::OS.windows? ? '2019 SP1' : '14.04'), - }, +# Get parameters from catalogue. +def get_from_catalogue(type, name, parameter) + catalogue.resource(type, name).send(:parameters)[parameter.to_sym] +end + +default_facts = { + puppetversion: Puppet.version, + facterversion: Facter.version, + architecture: 'x86_64', + operatingsystem: (RSpec::Support::OS.windows? ? 'Windows' : 'Ubuntu'), + osfamily: (RSpec::Support::OS.windows? ? 'windows' : 'Debian'), + operatingsystemmajrelease: (RSpec::Support::OS.windows? ? '2019' : '14'), + operatingsystemminrelease: (RSpec::Support::OS.windows? ? 'SP1' : '04'), + operatingsystemrelease: (RSpec::Support::OS.windows? ? '2019 SP1' : '14.04'), + lsbdistrelease: (RSpec::Support::OS.windows? ? '2019 SP1' : '14.04'), + lsbdistcodename: (RSpec::Support::OS.windows? ? '2019' : '14.04'), + os: { + architecture: 'x86_64', + name: (RSpec::Support::OS.windows? ? 'Windows' : 'Ubuntu'), + family: (RSpec::Support::OS.windows? ? 'windows' : 'Debian'), + release: { + major: (RSpec::Support::OS.windows? ? '2019' : '14'), + minor: (RSpec::Support::OS.windows? ? 'SP1' : '04'), + full: (RSpec::Support::OS.windows? ? '2019 SP1' : '14.04'), }, } +} + +default_fact_files = [ + File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')), + File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')), +] + +default_fact_files.each do |f| + next unless File.exist?(f) && File.readable?(f) && File.size?(f) + + begin + require 'deep_merge' + default_facts.deep_merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true)) + rescue StandardError => e + RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" + end end -# Get parameters from catalogue. -def get_from_catalogue(type, name, parameter) - catalogue.resource(type, name).send(:parameters)[parameter.to_sym] +# read default_facts and merge them over what is provided by facterdb +default_facts.each do |fact, value| + add_custom_fact fact, value, merge_facts: true end + +RSpec.configure do |c| + c.default_facts = default_facts + c.before :each do + # set to strictest setting for testing + # by default Puppet runs at warning level + Puppet.settings[:strict] = :warning + Puppet.settings[:strict_variables] = true + end + c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] + c.after(:suite) do + RSpec::Puppet::Coverage.report!(0) + 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 + +# Ensures that a module is defined +# @param module_name Name of the module +def ensure_module_defined(module_name) + module_name.split('::').reduce(Object) do |last_module, next_module| + last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false) + last_module.const_get(next_module, false) + end +end + +# 'spec_overrides' from sync.yml will appear below this line