pax_global_header00006660000000000000000000000064146460072130014515gustar00rootroot0000000000000052 comment=222fb44e82c58251dea3102008a988c1c1d7c03b puppet-tdc/000077500000000000000000000000001464600721300131465ustar00rootroot00000000000000puppet-tdc/.fixtures.yml000066400000000000000000000003371464600721300156230ustar00rootroot00000000000000# This file can be used to install module dependencies for unit testing # See https://github.com/puppetlabs/puppetlabs_spec_helper#using-fixtures for details --- fixtures: forge_modules: # stdlib: "puppetlabs/stdlib" puppet-tdc/.gitattributes000066400000000000000000000000761464600721300160440ustar00rootroot00000000000000*.rb eol=lf *.erb eol=lf *.pp eol=lf *.sh eol=lf *.epp eol=lf puppet-tdc/.gitignore000066400000000000000000000005201464600721300151330ustar00rootroot00000000000000.git/ .*.sw[op] .metadata .yardoc .yardwarns *.iml /.bundle/ /.idea/ /.vagrant/ /coverage/ /bin/ /doc/ /Gemfile.local /Gemfile.lock /junit/ /log/ /pkg/ /spec/fixtures/manifests/ /spec/fixtures/modules/* /tmp/ /vendor/ /convert_report.txt /update_report.txt .DS_Store .project .envrc /inventory.yaml /spec/fixtures/litmus_inventory.yaml puppet-tdc/.gitlab-ci.yml000066400000000000000000000023461464600721300156070ustar00rootroot00000000000000--- stages: - syntax - unit cache: paths: - vendor/bundle before_script: - bundle -v - rm Gemfile.lock || true - "# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner" - "# Set `rubygems_version` in the .sync.yml to set a value" - "# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set" - '[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION' - gem --version - bundle -v - bundle install --without system_tests --path vendor/bundle --jobs $(nproc) syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop-Ruby 2.5.7-Puppet ~> 6: stage: syntax image: ruby:2.5.7 script: - bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop variables: PUPPET_GEM_VERSION: '~> 6' parallel_spec-Ruby 2.5.7-Puppet ~> 6: stage: unit image: ruby:2.5.7 script: - bundle exec rake parallel_spec variables: PUPPET_GEM_VERSION: '~> 6' parallel_spec-Ruby 2.4.5-Puppet ~> 5: stage: unit image: ruby:2.4.5 script: - bundle exec rake parallel_spec variables: PUPPET_GEM_VERSION: '~> 5' puppet-tdc/.pdkignore000066400000000000000000000010051464600721300151250ustar00rootroot00000000000000.git/ .*.sw[op] .metadata .yardoc .yardwarns *.iml /.bundle/ /.idea/ /.vagrant/ /coverage/ /bin/ /doc/ /Gemfile.local /Gemfile.lock /junit/ /log/ /pkg/ /spec/fixtures/manifests/ /spec/fixtures/modules/* /tmp/ /vendor/ /convert_report.txt /update_report.txt .DS_Store .project .envrc /inventory.yaml /spec/fixtures/litmus_inventory.yaml /.fixtures.yml /Gemfile /.gitattributes /.github/ /.gitignore /.pdkignore /.puppet-lint.rc /Rakefile /rakelib/ /.rspec /..yml /.yardopts /spec/ /.vscode/ /.sync.yml /.devcontainer/ puppet-tdc/.puppet-lint.rc000066400000000000000000000000131464600721300160250ustar00rootroot00000000000000--relative puppet-tdc/.rspec000066400000000000000000000000371464600721300142630ustar00rootroot00000000000000--color --format documentation puppet-tdc/.rubocop.yml000066400000000000000000000407371464600721300154330ustar00rootroot00000000000000--- require: - rubocop-performance - rubocop-rspec AllCops: NewCops: enable DisplayCopNames: true TargetRubyVersion: '2.6' Include: - "**/*.rb" Exclude: - bin/* - ".vendor/**/*" - "**/Gemfile" - "**/Rakefile" - pkg/**/* - spec/fixtures/**/* - vendor/**/* - "**/Puppetfile" - "**/Vagrantfile" - "**/Guardfile" Layout/LineLength: Description: People have wide screens, use them. Max: 200 RSpec/BeforeAfterAll: Description: Beware of using after(:all) as it may cause state to leak between tests. A necessary evil in acceptance testing. Exclude: - spec/acceptance/**/*.rb RSpec/HookArgument: Description: Prefer explicit :each argument, matching existing module's style EnforcedStyle: each RSpec/DescribeSymbol: Exclude: - spec/unit/facter/**/*.rb Style/BlockDelimiters: Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to be consistent then. EnforcedStyle: braces_for_chaining Style/ClassAndModuleChildren: Description: Compact style reduces the required amount of indentation. EnforcedStyle: compact Style/EmptyElse: Description: Enforce against empty else clauses, but allow `nil` for clarity. EnforcedStyle: empty Style/FormatString: Description: Following the main puppet project's style, prefer the % format format. EnforcedStyle: percent Style/FormatStringToken: Description: Following the main puppet project's style, prefer the simpler template tokens over annotated ones. EnforcedStyle: template Style/Lambda: Description: Prefer the keyword for easier discoverability. EnforcedStyle: literal Style/RegexpLiteral: Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168 EnforcedStyle: percent_r Style/TernaryParentheses: Description: Checks for use of parentheses around ternary conditions. Enforce parentheses on complex expressions for better readability, but seriously consider breaking it up. EnforcedStyle: require_parentheses_when_complex Style/TrailingCommaInArguments: Description: Prefer always trailing comma on multiline argument lists. This makes diffs, and re-ordering nicer. EnforcedStyleForMultiline: comma Style/TrailingCommaInArrayLiteral: Description: Prefer always trailing comma on multiline literals. This makes diffs, and re-ordering nicer. EnforcedStyleForMultiline: comma Style/SymbolArray: Description: Using percent style obscures symbolic intent of array's contents. EnforcedStyle: brackets RSpec/MessageSpies: EnforcedStyle: receive Style/Documentation: Exclude: - lib/puppet/parser/functions/**/* - 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 Bundler/GemFilename: Enabled: false Bundler/InsecureProtocolSource: Enabled: false Capybara/CurrentPathExpectation: Enabled: false Capybara/VisibilityMatcher: Enabled: false Gemspec/DuplicatedAssignment: Enabled: false Gemspec/OrderedDependencies: Enabled: false Gemspec/RequiredRubyVersion: Enabled: false Gemspec/RubyVersionGlobalsUsage: Enabled: false Layout/ArgumentAlignment: Enabled: false Layout/BeginEndAlignment: Enabled: false Layout/ClosingHeredocIndentation: Enabled: false Layout/EmptyComment: Enabled: false Layout/EmptyLineAfterGuardClause: Enabled: false Layout/EmptyLinesAroundArguments: Enabled: false Layout/EmptyLinesAroundAttributeAccessor: Enabled: false Layout/EndOfLine: Enabled: false Layout/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: Enabled: false Metrics/MethodLength: Enabled: false Metrics/ModuleLength: Enabled: false 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/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 RSpec/PredicateMatcher: Enabled: false RSpec/ReceiveCounts: Enabled: false RSpec/ReceiveNever: Enabled: false RSpec/RepeatedExampleGroupBody: Enabled: false RSpec/RepeatedExampleGroupDescription: Enabled: false RSpec/RepeatedIncludeExample: Enabled: false RSpec/ReturnFromStub: Enabled: false RSpec/SharedExamples: Enabled: false RSpec/StubbedMock: Enabled: false RSpec/UnspecifiedException: Enabled: false RSpec/VariableDefinition: Enabled: false RSpec/VoidExpect: Enabled: false RSpec/Yield: Enabled: false Security/Open: Enabled: false Style/AccessModifierDeclarations: Enabled: false Style/AccessorGrouping: Enabled: false Style/BisectedAttrAccessor: Enabled: false Style/CaseLikeIf: Enabled: false Style/ClassEqualityComparison: Enabled: false Style/ColonMethodDefinition: Enabled: false Style/CombinableLoops: Enabled: false Style/CommentedKeyword: Enabled: false Style/Dir: Enabled: false Style/DoubleCopDisableDirective: Enabled: false Style/EmptyBlockParameter: Enabled: false Style/EmptyLambdaParameter: Enabled: false Style/Encoding: Enabled: false Style/EvalWithLocation: Enabled: false Style/ExpandPathArguments: Enabled: false Style/ExplicitBlockArgument: Enabled: false Style/ExponentialNotation: Enabled: false Style/FloatDivision: Enabled: false Style/FrozenStringLiteralComment: Enabled: false Style/GlobalStdStream: Enabled: false Style/HashAsLastArrayItem: Enabled: false Style/HashLikeCase: Enabled: false Style/HashTransformKeys: Enabled: false Style/HashTransformValues: Enabled: false Style/IfUnlessModifier: Enabled: false Style/KeywordParametersOrder: Enabled: false Style/MinMax: Enabled: false Style/MixinUsage: Enabled: false Style/MultilineWhenThen: Enabled: false Style/NegatedUnless: Enabled: false Style/NumericPredicate: Enabled: false Style/OptionalBooleanParameter: Enabled: false Style/OrAssignment: Enabled: false Style/RandomWithOffset: Enabled: false Style/RedundantAssignment: Enabled: false Style/RedundantCondition: Enabled: false Style/RedundantConditional: Enabled: false Style/RedundantFetchBlock: Enabled: false Style/RedundantFileExtensionInRequire: Enabled: false Style/RedundantRegexpCharacterClass: Enabled: false Style/RedundantRegexpEscape: Enabled: false Style/RedundantSelfAssignment: Enabled: false Style/RedundantSort: Enabled: false Style/RescueStandardError: Enabled: false Style/SingleArgumentDig: Enabled: false Style/SlicingWithRange: Enabled: false Style/SoleNestedConditional: Enabled: false Style/StderrPuts: Enabled: false Style/StringConcatenation: Enabled: false Style/Strip: Enabled: false Style/SymbolProc: Enabled: false Style/TrailingBodyOnClass: Enabled: false Style/TrailingBodyOnMethodDefinition: Enabled: false Style/TrailingBodyOnModule: Enabled: false Style/TrailingCommaInHashLiteral: Enabled: false Style/TrailingMethodEndStatement: Enabled: false Style/UnpackFirst: Enabled: false Capybara/MatchStyle: Enabled: false Capybara/NegationMatcher: Enabled: false Capybara/SpecificActions: Enabled: false Capybara/SpecificFinders: Enabled: false Capybara/SpecificMatcher: Enabled: false Gemspec/DeprecatedAttributeAssignment: Enabled: false Gemspec/DevelopmentDependencies: Enabled: false Gemspec/RequireMFA: Enabled: false Layout/LineContinuationLeadingSpace: Enabled: false Layout/LineContinuationSpacing: Enabled: false Layout/LineEndStringConcatenationIndentation: Enabled: false Layout/SpaceBeforeBrackets: Enabled: false Lint/AmbiguousAssignment: Enabled: false Lint/AmbiguousOperatorPrecedence: Enabled: false Lint/AmbiguousRange: Enabled: false Lint/ConstantOverwrittenInRescue: Enabled: false Lint/DeprecatedConstants: Enabled: false Lint/DuplicateBranch: Enabled: false Lint/DuplicateMagicComment: Enabled: false Lint/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 puppet-tdc/.travis.yml000066400000000000000000000023441464600721300152620ustar00rootroot00000000000000--- os: linux dist: xenial language: ruby cache: bundler before_install: - bundle -v - rm -f Gemfile.lock - "# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner" - "# See https://github.com/puppetlabs/pdk-templates/commit/705154d5c437796b821691b707156e1b056d244f for an example of how this was used" - "# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set" - '[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION' - gem --version - bundle -v script: - 'bundle exec rake $CHECK' bundler_args: --without system_tests rvm: - 2.5.7 stages: - static - spec - acceptance - if: tag =~ ^v\d name: deploy jobs: fast_finish: true include: - env: CHECK="check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint" stage: static - env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec rvm: 2.4.5 stage: spec - env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec rvm: 2.5.7 stage: spec - env: DEPLOY_TO_FORGE=yes stage: deploy branches: only: - master - /^v\d/ notifications: email: false puppet-tdc/.vscode/000077500000000000000000000000001464600721300145075ustar00rootroot00000000000000puppet-tdc/.vscode/extensions.json000066400000000000000000000001221464600721300175740ustar00rootroot00000000000000{ "recommendations": [ "puppet.puppet-vscode", "Shopify.ruby-lsp" ] } puppet-tdc/.yardopts000066400000000000000000000000221464600721300150060ustar00rootroot00000000000000--markup markdown puppet-tdc/CHANGELOG.md000066400000000000000000000007021464600721300147560ustar00rootroot00000000000000# Changelog All notable changes to this project will be documented in this file. ## Release 0.0.4 tidying up; make it work again under Bookworm new checks: check_tdc_package_version ## Release 0.0.3 new checks: test_manual.pp ## Release 0.0.2 new checks: test_config.pp test_file_group.pp test_file_owner.pp test_file_permission.pp test_process.pp ## Release 0.0.1 initial version Available checks: test_directory.pp test_file.pp puppet-tdc/Gemfile000066400000000000000000000072131464600721300144440ustar00rootroot00000000000000source ENV['GEM_SOURCE'] || 'https://rubygems.org' def location_for(place_or_version, fake_version = nil) git_url_regex = %r{\A(?(https?|git)[:@][^#]*)(#(?.*))?} file_url_regex = %r{\Afile:\/\/(?.*)} 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 "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.0', require: false gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false gem "facterdb", '~> 1.18', require: false gem "metadata-json-lint", '~> 4.0', require: false gem "rspec-puppet-facts", '~> 3.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] end group :development, :release_prep do gem "puppet-strings", '~> 4.0', require: false gem "puppetlabs_spec_helper", '~> 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 puppet_version = ENV['PUPPET_GEM_VERSION'] facter_version = ENV['FACTER_GEM_VERSION'] hiera_version = ENV['HIERA_GEM_VERSION'] 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 puppet-tdc/LICENSE000066400000000000000000000432541464600721300141630ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. puppet-tdc/README.md000066400000000000000000000014161464600721300144270ustar00rootroot00000000000000# tdc #### Table of Contents 1. [Module Description - What the module does and why it is useful](#module-description) 1. [Setup - The basics of getting started with [modulename]](#setup) * [What [modulename] affects](#what-[modulename]-affects) * [Setup requirements](#setup-requirements) * [Beginning with [modulename]](#beginning-with-[modulename]) 1. [Usage - Configuration options and additional functionality](#usage) 1. [Limitations - OS compatibility, etc.](#limitations) 1. [Development - Guide for contributing to the module](#development) ## Module description ## Setup ## Usage ## Limitations At the moment, this module can only be used together with nagios. ## Development The repository is available at github: https://github.com/alteholz/puppet-tdc puppet-tdc/Rakefile000066400000000000000000000005211464600721300146110ustar00rootroot00000000000000# 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' PuppetLint.configuration.send('disable_relative') puppet-tdc/TODO000066400000000000000000000014741464600721300136440ustar00rootroot00000000000000integrate into puppet: -> apt-get install puppet-module-alteholz-tdc -> /etc/puppet/code/environments/production/manifests/nodes.pp in the beginning: class {'tdc': } -> nagios4_server module /etc/puppet/code/environments/production/modules/nagios4_server/files/tdc <- owner puppet.puppet file { '/etc/nagios4/conf.d/tdc': ensure => 'directory', source => 'puppet:///modules/nagios4_server/tdc', recurse => 'remote', path => '/etc/nagios4/conf.d/tdc', owner => 'root', group => 'root', mode => '0755', notify => Service["nagios4"], } -> nagios_nrpe_server /etc/puppet/code/environments/production/modules/nagios_nrpe_server/files in nrpe_local.cfg at the end: include_dir=/usr/local/nagios/tdc/config puppet-tdc/appveyor.yml000066400000000000000000000024761464600721300155470ustar00rootroot00000000000000--- version: 1.1.x.{build} branches: only: - master - release skip_commits: message: /^\(?doc\)?.*/ clone_depth: 10 init: - SET - 'mkdir C:\ProgramData\PuppetLabs\code && exit 0' - 'mkdir C:\ProgramData\PuppetLabs\facter && exit 0' - 'mkdir C:\ProgramData\PuppetLabs\hiera && exit 0' - 'mkdir C:\ProgramData\PuppetLabs\puppet\var && exit 0' environment: matrix: - RUBY_VERSION: 24-x64 CHECK: syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop - PUPPET_GEM_VERSION: ~> 5.0 RUBY_VERSION: 24 CHECK: parallel_spec - PUPPET_GEM_VERSION: ~> 5.0 RUBY_VERSION: 24-x64 CHECK: parallel_spec - PUPPET_GEM_VERSION: ~> 6.0 RUBY_VERSION: 25 CHECK: parallel_spec - PUPPET_GEM_VERSION: ~> 6.0 RUBY_VERSION: 25-x64 CHECK: parallel_spec matrix: fast_finish: true install: - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH% - bundle install --jobs 4 --retry 2 --without system_tests - type Gemfile.lock build: off test_script: - bundle exec puppet -V - ruby -v - gem -v - bundle -v - bundle exec rake %CHECK% notifications: - provider: Email to: - nobody@nowhere.com on_build_success: false on_build_failure: false on_build_status_changed: false puppet-tdc/data/000077500000000000000000000000001464600721300140575ustar00rootroot00000000000000puppet-tdc/data/common.yaml000066400000000000000000000000071464600721300162300ustar00rootroot00000000000000--- {} puppet-tdc/header/000077500000000000000000000000001464600721300143765ustar00rootroot00000000000000puppet-tdc/header/HEADER.hash000066400000000000000000000013131464600721300161710ustar00rootroot00000000000000# # TDC: Test-driven configuration # # XXX # # Copyright (C) 2020 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # puppet-tdc/hiera.yaml000066400000000000000000000012551464600721300151250ustar00rootroot00000000000000--- version: 5 defaults: # Used for any hierarchy level that omits these keys. datadir: data # This path is relative to hiera.yaml's directory. data_hash: yaml_data # Use the built-in YAML backend. hierarchy: - name: "osfamily/major release" paths: # Used to distinguish between Debian and Ubuntu - "os/%{facts.os.name}/%{facts.os.release.major}.yaml" - "os/%{facts.os.family}/%{facts.os.release.major}.yaml" # Used for Solaris - "os/%{facts.os.family}/%{facts.kernelrelease}.yaml" - name: "osfamily" paths: - "os/%{facts.os.name}.yaml" - "os/%{facts.os.family}.yaml" - name: 'common' path: 'common.yaml' puppet-tdc/lib/000077500000000000000000000000001464600721300137145ustar00rootroot00000000000000puppet-tdc/lib/puppet-generator-nagios000077500000000000000000000057661464600721300204370ustar00rootroot00000000000000#!/bin/bash # # TDC: Test-driven configuration # # generator of nagios config files # # Copyright (C) 2020 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # DEST=$1 WHAT=$2 APPEND=$3 PARA1="$4" PARA2="$5" PARA3="$6" OUT=$DEST-$WHAT.cfg if [ "x$APPEND" == "xonlycreateonce" ]; then # we only want to create the file once if [ -f $OUT ]; then exit 0 fi fi if [ "x$APPEND" == "xno" ]; then rm -f $OUT fi if [ "x$PARA1" == "xdummy" ]; then # we just want to delete the file, do nothing more exit 0 fi if [ "x$WHAT" == "xservice" ]; then # for tdc_manual we have $PARA2 containg the name of the manual test # all other services should have an empty string echo "define service {" >> $OUT echo " hostgroup_name $PARA1" >> $OUT if [ -z "$PARA2" ]; then echo " service_description Service for `basename $DEST`" >> $OUT else echo " service_description Service $PARA2 for `basename $DEST`" >> $OUT fi echo " check_command check_nrpe_1arg!$PARA1" >> $OUT echo " use generic-service" >> $OUT echo " notification_interval 0" >> $OUT echo "}" >> $OUT exit 0 fi if [ "x$WHAT" == "xhost" ]; then # we can not give all stuff as parameter here, so we use a hostdb and grep everything hostuse=$PARA2 if [ -f $PARA3 ]; then hostentry=`grep $PARA1 $PARA3` if [ ! -z "$hostentry" ]; then hostuse=`echo $hostentry|awk -F"#" '{printf("%s\n",$2)}'` if [ -z "$hostuse" ]; then # we have an empty "use" field in the database, so use default again hostuse=$PARA2 fi hostaddress=`echo $hostentry|awk -F"#" '{printf("%s\n",$3)}'` fi fi # in case of an empty value, better do nothing if [ "x$PARA1" == "x" ]; then exit 2 fi if [ "x$hostuse" == "x" ]; then exit 3 fi echo "define host{" >> $OUT echo " use $hostuse" >> $OUT echo " host_name $PARA1" >> $OUT if [ ! -z "$hostaddress" ]; then echo " address $hostaddress" >> $OUT fi echo " }" >> $OUT exit 0 fi if [ "x$WHAT" == "xhostgroup" ]; then echo "define hostgroup {" >> $OUT echo " hostgroup_name $PARA1" >> $OUT echo " alias $PARA1" >> $OUT echo " members $PARA2" >> $OUT echo " }" >> $OUT exit 0 fi exit 1 puppet-tdc/manifests/000077500000000000000000000000001464600721300151375ustar00rootroot00000000000000puppet-tdc/manifests/create_nagios_host.pp000066400000000000000000000030201464600721300213330ustar00rootroot00000000000000# # TDC: Test-driven configuration # # define host entry for nagios # # Copyright (C) 2020-2024 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # # @summary create host entry for nagios # # @example Basic usage # define { 'tdc::create_nagios_host': # } # # @param nagiosout outputfile for this test # @param nagioshostuse name of host to be used in definition # @param nagioshostdb name of hostdb to be used # @param tdctitle name of test (should not be changed) define tdc::create_nagios_host ( String $nagiosout = "${tdc::nagiosdir}/tdc-${facts['networking']['fqdn']}", String $nagioshostuse = 'generic-host', String $nagioshostdb = "${tdc::nagiosdir}/hostdb.tdc", String $tdctitle = $title, ) { #) inherits tdc { Exec { path => ['/usr/bin', '/usr/sbin', '/bin'], } generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} host onlycreateonce ${facts['networking']['fqdn']} ${nagioshostuse} ${nagioshostdb}") } puppet-tdc/manifests/init.pp000066400000000000000000000047521464600721300164530ustar00rootroot00000000000000# # TDC: Test-driven configuration # # main definition of class tdc # # Copyright (C) 2020-2024 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # # @summary initial configuration of the TDC module, needs to be called first # # @example Basic usage # tdc {} # } # # @param monitor # Monitoring software that shall be used together with this module. # Currently only nagios is supported (and probably icinga). # @param checkrootdir # Root directory of the tree where all configuration and scripts will be stored. # @param checkscriptdir # Subdirectory of $checkrootdir to define the location of all scripts that perform checks. # @param checkconfigdir # Subdirectory of $checkrootdir to define the location of all configurations files. # @param nagiosdir # Directory on puppetmaster where all nagios configurations files shall be stored. # @param generator # Generator for configuration files (up to now only nagios) # @param nrpeservice # service to notify in case of changed test configuration class tdc ( String $monitor = 'nagios', String $checkrootdir = '/usr/local/nagios/tdc', String $checkscriptdir = 'plugins', String $checkconfigdir = 'config', String $nagiosdir = '/etc/puppet/code/environments/production/modules/nagios4_server/files/tdc', String $generator = '/usr/share/puppet/modules/tdc/lib/puppet-generator-nagios', String $nrpeservice = 'nagios-nrpe-server', ) { #) inherits tdc { Exec { path => ['/usr/bin', '/usr/sbin', '/bin'], } file { $checkrootdir: ensure => directory, owner => 'root', group => 'root', mode => '0755', } file { "${checkrootdir}/${checkscriptdir}": ensure => directory, owner => 'root', group => 'root', mode => '0755', } file { "${checkrootdir}/${checkconfigdir}": ensure => directory, owner => 'root', group => 'root', mode => '0755', } } puppet-tdc/manifests/test_config.pp000066400000000000000000000064141464600721300200110ustar00rootroot00000000000000# # TDC: Test-driven configuration # # class for testing configuration of a software # # Copyright (C) 2020-2024 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # # @summary create tests for a list of files # # @example Basic usage # define { 'tdc::test_config': # command => '/usr/sbin/apache2ctl -t', # } # define { 'tdc::test_config': # type => 'apache2', # } # # @param command Command to execute # @param type Type of check; using internal commands # @param nagiosout outputfile for this test # @param nagioscheck name of check to be performed define tdc::test_config ( String $command = ' ', String $type = 'undef', String $nagiosout = "${tdc::nagiosdir}/tdc-${facts['networking']['fqdn']}-${title}-config", String $nagioscheck = "${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_config", ) { #) inherits tdc { Exec { path => ['/usr/bin', '/usr/sbin', '/bin'], } case $type { 'apache2', 'apache': { $doit = '/usr/sbin/apache2ctl -t' } default: { $doit = $command } } if $doit == '' { $doit = '/bin/false' } concat { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-config.cfg": owner => 'root', group => 'root', mode => '0644', } concat::fragment { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-config.cfg header": target => "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-config.cfg", content => epp('tdc/tdc_config_header.epp', { 'type' => 'test for config', 'cmn' => $title }), order => '00', } concat::fragment { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-config.cfg 1": target => "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-config.cfg", content => "command[check_tdc_${$title}-${facts['networking']['fqdn']}-config]=${nagioscheck} '${doit}'\n", notify => Service[$tdc::nrpeservice], } $lfqdn=$facts['networking']['fqdn'] generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} service onlycreateonce check_tdc_${title}-${$lfqdn}-config") generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} hostgroup onlycreateonce check_tdc_${title}-${lfqdn}-config ${lfqdn}") if !defined(File["${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_config"]) { file { "${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_config": ensure => file, owner => 'root', group => 'root', mode => '0755', path => "${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_config", content => epp('tdc/check_tdc_config.epp'), } } #III we don't need hosts yet: # generate ("/bin/bash", "-c", "${tdc::generator} ${tdc::nagiosdir}/tdc-$fqdn-${title}-config host no $fqdn") } puppet-tdc/manifests/test_directory.pp000066400000000000000000000065211464600721300205470ustar00rootroot00000000000000# # TDC: Test-driven configuration # # define for testing presence of a list of directories # # Copyright (C) 2020-2024 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # # @summary create tests for a list of directories # # @example Basic usage # define { 'tdc::test_directory': # directory => ['/etc', '/tmp'], # } # # @param directory Array of directories to be tested # @param nagiosout outputfile for this test # @param nagioscheck name of check to be performed # @param tdctitle name of test (should not be changed) define tdc::test_directory ( Array $directory = [], String $nagiosout = "${tdc::nagiosdir}/tdc-${facts['networking']['fqdn']}-${title}-directory", String $nagioscheck = "${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_directory", String $tdctitle = $title, ) { #) inherits tdc { Exec { path => ['/usr/bin', '/usr/sbin', '/bin'], } concat { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-directory.cfg": owner => 'root', group => 'root', mode => '0644', notify => Service[$tdc::nrpeservice], } concat::fragment { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-directory.cfg header": target => "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-directory.cfg", content => epp('tdc/tdc_config_header.epp', { 'type' => 'test for directories', 'cmn' => $title }), order => '00', } generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} service no dummy") generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} hostgroup no dummy ${facts['networking']['fqdn']}") # create the tests from the directory array $directory.each | $f, $ddd | { concat::fragment { "${ddd} ${f}": target => "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-directory.cfg", content => "command[check_tdc_${title}-${f}-${facts['networking']['fqdn']}-directory]=${nagioscheck} ${ddd}\n", } $lfqdn=$facts['networking']['fqdn'] generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} service yes check_tdc_${title}-${f}-${lfqdn}-directory") generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} hostgroup yes check_tdc_${title}-${f}-${lfqdn}-directory ${lfqdn}") } if !defined(File["${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_directory"]) { file { "${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_directory": ensure => file, owner => 'root', group => 'root', mode => '0755', path => "${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_directory", content => epp('tdc/check_tdc_directory.epp'), } } #III we don't need hosts yet: # generate ("/bin/bash", "-c", "${tdc::generator} ${nagiosout} host no ${facts['networking']['fqdn']}") } puppet-tdc/manifests/test_file.pp000066400000000000000000000063701464600721300174640ustar00rootroot00000000000000# # TDC: Test-driven configuration # # define for testing presence of a list of files # # Copyright (C) 2020-2024 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # # @summary create tests for a list of files # # @example Basic usage # define { 'tdc::test_file': # file => ['/usr/sbin/ntpd', '/etc/ntp.conf'], # } # # @param file Array of files to be tested # @param nagiosout outputfile for this test # @param nagioscheck name of check to be performed # @param tdctitle name of test (should not be changed) define tdc::test_file ( Array $file = [], String $nagiosout = "${tdc::nagiosdir}/tdc-${facts['networking']['fqdn']}-${title}-file", String $nagioscheck = "${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_file", String $tdctitle = $title, ) { #) inherits tdc { include tdc Exec { path => ['/usr/bin', '/usr/sbin', '/bin'], } concat { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-file.cfg": owner => 'root', group => 'root', mode => '0644', } concat::fragment { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-file.cfg header": target => "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-file.cfg", content => epp('tdc/tdc_config_header.epp', { 'type' => 'test for files', 'cmn' => $title }), order => '00', } generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} service no dummy") generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} hostgroup no dummy ${facts['networking']['fqdn']}") # create the tests from the file array $file.each | $f, $fff | { concat::fragment { "${fff} ${f}": target => "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-file.cfg", content => "command[check_tdc_${title}-${f}-${facts['networking']['fqdn']}-file]=${nagioscheck} ${fff}\n", notify => Service[$tdc::nrpeservice], } $lfqdn=$facts['networking']['fqdn'] generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} service yes check_tdc_${title}-${f}-${lfqdn}-file") generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} hostgroup yes check_tdc_${title}-${f}-${lfqdn}-file ${lfqdn}") } if !defined(File["${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_file"]) { file { "${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_file": ensure => file, owner => 'root', group => 'root', mode => '0755', path => "${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_file", content => epp('tdc/check_tdc_file.epp'), } } #III we don't need hosts yet: # generate ("/bin/bash", "-c", "${tdc::generator} ${tdc::nagiosdir}/tdc-$lfqdn-${title}-file host no $lfqdn") } puppet-tdc/manifests/test_file_group.pp000066400000000000000000000065471464600721300207060ustar00rootroot00000000000000# # TDC: Test-driven configuration # # define for testing groupship of a list of files # # Copyright (C) 2020-2024 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # # @summary create tests for a list of files # # @example Basic usage # define { 'tdc::test_file_group': # file => [ # { # file => '/usr/sbin/ntpd', # group => 'root', # }, # } # # @param file Array of files to be tested # @param nagiosout outputfile for this test # @param nagioscheck name of check to be performed # @param tdctitle name of test (should not be changed) define tdc::test_file_group ( Array $file = [], String $nagiosout = "${tdc::nagiosdir}/tdc-${facts['networking']['fqdn']}-${title}-file-group", String $nagioscheck = "${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_file_group", String $tdctitle = $title, ) { #) inherits tdc { Exec { path => ['/usr/bin', '/usr/sbin', '/bin'], } concat { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-file-group.cfg": owner => 'root', group => 'root', mode => '0644', } concat::fragment { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-file-group.cfg header": target => "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-file-group.cfg", content => epp('tdc/tdc_config_header.epp', { 'type' => 'test for files', 'cmn' => $title }), order => '00', } generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} service no dummy") generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} hostgroup no dummy ${facts['networking']['fqdn']}") # create the tests from the file array $lfqdn=$facts['networking']['fqdn'] $file.each | $f, $fff | { concat::fragment { "${fff} ${f}": target => "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-file-group.cfg", content => "command[check_tdc_${title}-${f}-${lfqdn}-file-group]=${nagioscheck} ${fff['file']} ${fff['group']}\n", notify => Service[$tdc::nrpeservice], } generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} service yes check_tdc_${title}-${f}-${lfqdn}-file-group") generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} hostgroup yes check_tdc_${title}-${f}-${lfqdn}-file-group ${lfqdn}") } if !defined(File["${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_file_group"]) { file { "${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_file_group": ensure => file, owner => 'root', group => 'root', mode => '0755', path => "${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_file_group", content => epp('tdc/check_tdc_file_group.epp'), } } #III we don't need hosts yet: # generate ("/bin/bash", "-c", "${tdc::generator} ${tdc::nagiosdir}/tdc-$fqdn-${title}-file-group host no $fqdn") } puppet-tdc/manifests/test_file_owner.pp000066400000000000000000000065571464600721300207050ustar00rootroot00000000000000# # TDC: Test-driven configuration # # define for testing ownership of a list of files # # Copyright (C) 2020-2024 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # # @summary create tests for a list of files # # @example Basic usage # define { 'tdc::test_file_owner': # file => [ # { # file => '/usr/sbin/ntpd', # owner => 'root', # }, # } # # @param file Array of files to be tested # @param nagiosout outputfile for this test # @param nagioscheck name of check to be performed # @param tdctitle name of test (should not be changed) define tdc::test_file_owner ( Array $file = [], String $nagiosout = "${tdc::nagiosdir}/tdc-${facts['networking']['fqdn']}-${title}-file-owner", String $nagioscheck = "${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_file_owner", String $tdctitle = $title, ) { #) inherits tdc { Exec { path => ['/usr/bin', '/usr/sbin', '/bin'], } concat { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-file-owner.cfg": owner => 'root', group => 'root', mode => '0644', } concat::fragment { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-file-owner.cfg header": target => "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-file-owner.cfg", content => epp('tdc/tdc_config_header.epp', { 'type' => 'test for files', 'cmn' => $title }), order => '00', } generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} service no dummy") generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} hostgroup no dummy ${facts['networking']['fqdn']}") # create the tests from the file array $lfqdn=$facts['networking']['fqdn'] $file.each | $f, $fff | { concat::fragment { "${fff} ${f}": target => "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-file-owner.cfg", content => "command[check_tdc_${title}-${f}-${lfqdn}-file-owner]=${nagioscheck} ${fff['file']} ${fff['owner']}\n", notify => Service[$tdc::nrpeservice], } generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} service yes check_tdc_${title}-${f}-${lfqdn}-file-owner") generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} hostgroup yes check_tdc_${title}-${f}-${lfqdn}-file-owner ${lfqdn}") } if !defined(File["${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_file_owner"]) { file { "${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_file_owner": ensure => file, owner => 'root', group => 'root', mode => '0755', path => "${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_file_owner", content => epp('tdc/check_tdc_file_owner.epp'), } } #III we don't need hosts yet: # generate ("/bin/bash", "-c", "${tdc::generator} ${tdc::nagiosdir}/tdc-$fqdn-${title}-file-owner host no $fqdn") } puppet-tdc/manifests/test_file_permission.pp000066400000000000000000000067021464600721300217330ustar00rootroot00000000000000# # TDC: Test-driven configuration # # define for testing permissions of a list of files # # Copyright (C) 2020-2024 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # # @summary create tests for a list of files # # @example Basic usage # define { 'tdc::test_file_permission': # file => [ # { # file => '/usr/sbin/ntpd', # permission => '755', # }, # } # # @param file Array of files to be tested # @param nagiosout outputfile for this test # @param nagioscheck name of check to be performed # @param tdctitle name of test (should not be changed) define tdc::test_file_permission ( Array $file = [], String $nagiosout = "${tdc::nagiosdir}/tdc-${facts['networking']['fqdn']}-${title}-file-permission", String $nagioscheck = "${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_file_permission", String $tdctitle = $title, ) { #) inherits tdc { Exec { path => ['/usr/bin', '/usr/sbin', '/bin'], } concat { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-file-permission.cfg": owner => 'root', group => 'root', mode => '0644', } concat::fragment { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-file-permission.cfg header": target => "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-file-permission.cfg", content => epp('tdc/tdc_config_header.epp', { 'type' => 'test for files', 'cmn' => $title }), order => '00', } generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} service no dummy") generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} hostgroup no dummy ${facts['networking']['fqdn']}") # create the tests from the file array $lfqdn=$facts['networking']['fqdn'] $file.each | $f, $fff | { concat::fragment { "${fff} ${f}": target => "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-file-permission.cfg", content => "command[check_tdc_${title}-${f}-${lfqdn}-file-permission]=${nagioscheck} ${fff['file']} ${fff['permission']}\n", notify => Service[$tdc::nrpeservice], } generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} service yes check_tdc_${title}-${f}-${lfqdn}-file-permission") generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} hostgroup yes check_tdc_${title}-${f}-${lfqdn}-file-permission ${lfqdn}") } if !defined(File["${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_file_permission"]) { file { "${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_file_permission": ensure => file, owner => 'root', group => 'root', mode => '0755', path => "${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_file_permission", content => epp('tdc/check_tdc_file_permission.epp'), } } #III we don't need hosts yet: # generate ("/bin/bash", "-c", "${tdc::generator} ${tdc::nagiosdir}/tdc-$fqdn-${title}-file-permission host no $fqdn") } puppet-tdc/manifests/test_hostipv4.pp000066400000000000000000000060651464600721300203260ustar00rootroot00000000000000# # TDC: Test-driven configuration # # define for testing presence of a host via ipv4 # # Copyright (C) 2020-2024 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # # @summary create tests to check whether host is up via ipv4 # # @example Basic usage # define { 'tdc::test_hostipv4': # host => ['host.example.com'], # } # # @param host Array of hosts to be tested # @param nagiosout outputfile for this test # @param nagioscheck name of check to be performed # @param pingwarning waring level for ping # @param pingcritical critical level for ping # @param tdctitle name of test (should not be changed) define tdc::test_hostipv4 ( Array $host = [], String $nagiosout = "${tdc::nagiosdir}/tdc-${facts['networking']['fqdn']}-${title}-hostipv4", String $nagioscheck = '/usr/lib/nagios/plugins/check_ping', String $pingwarning = '1000,20%', String $pingcritical = '1500,60%', String $tdctitle = $title, ) { #) inherits tdc { Exec { path => ['/usr/bin', '/usr/sbin', '/bin'], } concat { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-hostipv4.cfg": owner => 'root', group => 'root', mode => '0644', } concat::fragment { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-hostipv4.cfg header": target => "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-hostipv4.cfg", content => epp('tdc/tdc_config_header.epp', { 'type' => 'test for hostipv4', 'cmn' => $title }), order => '00', } generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} service no dummy") generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} hostgroup no dummy ${facts['networking']['fqdn']}") # create the tests from the process array $lfqdn=$facts['networking']['fqdn'] $host.each | $f, $fff | { concat::fragment { "${fff} ${f}": target => "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-hostipv4.cfg", content => "command[check_tdc_${title}-${f}-${lfqdn}-hostipv4]=${nagioscheck} -H ${fff} -4 -w ${pingwarning} -c ${pingcritical}\n", notify => Service[$tdc::nrpeservice], } generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} service yes check_tdc_${title}-${f}-${lfqdn}-hostipv4") generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} hostgroup yes check_tdc_${title}-${f}-${lfqdn}-hostipv4 ${lfqdn}") } #III we don't need hosts yet: # generate ("/bin/bash", "-c", "${tdc::generator} ${tdc::nagiosdir}/tdc-$fqdn-${title}-hostipv4 host no $fqdn") } puppet-tdc/manifests/test_hostipv6.pp000066400000000000000000000060711464600721300203250ustar00rootroot00000000000000# # TDC: Test-driven configuration # # define for testing presence of a host via ipv6 # # Copyright (C) 2020-2024 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # # @summary create tests to check whether host is up via ipv6 # # @example Basic usage # define { 'tdc::test_hostipv6': # host => ['host.example.com'], # } # # @param host Array of hosts to be tested # @param nagiosout outputfile for this test # @param nagioscheck name of check to be performed # @param pingwarning waring level for ping # @param pingcritical critical level for ping # @param tdctitle name of test (should not be changed) define tdc::test_hostipv6 ( Array $host = [], String $nagiosout = "${tdc::nagiosdir}/tdc-${facts['networking']['fqdn']}-${title}-hostipv6", String $nagioscheck = '/usr/lib/nagios/plugins/check_ping', String $pingwarning = '1000,20%', String $pingcritical = '1500,60%', String $tdctitle = $title, ) { #) inherits tdc { Exec { path => ['/usr/bin', '/usr/sbin', '/bin'], } concat { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-hostipv6.cfg": owner => 'root', group => 'root', mode => '0644', } concat::fragment { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-hostipv6.cfg header": target => "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-hostipv6.cfg", content => epp('tdc/tdc_config_header.epp', { 'type' => 'test for hostipv6', 'cmn' => $title }), order => '00', } generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} service no dummy") generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} hostgroup no dummy ${facts['networking']['fqdn']}") # create the tests from the process array $lfqdn=$facts['networking']['fqdn'] $host.each | $f, $fff | { concat::fragment { "${fff} ${f}": target => "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-hostipv6.cfg", content => "command[check_tdc_${title}-${f}-${lfqdn}-hostipv6]=${nagioscheck} -H ${fff} -4 -w ${pingwarning} -c ${pingcritical}\n", notify => Service[$tdc::nrpeservice], } generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} service yes check_tdc_${title}-${f}-${lfqdn}-hostipv6") generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} hostgroup yes check_tdc_${title}-${f}-${lfqdn}-hostipv6 ${lfqdn}") } #III we don't need hosts yet: # generate ("/bin/bash", "-c", "${tdc::generator} ${tdc::nagiosdir}/tdc-$fqdn-${title}-hostipv6 host no $fqdn") } puppet-tdc/manifests/test_manual.pp000066400000000000000000000055251464600721300200230ustar00rootroot00000000000000# # TDC: Test-driven configuration # # define for manual testing of nrpe stuff # # Copyright (C) 2021-2024 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # # @summary create manual tests # # @example Basic usage # define { 'tdc::test_manual': # manual => ['check_debian_version'], # } # # @param manual Array of manual tests # @param nagiosout outputfile for this test # @param nagioscheckprefix name of prefix for check to be performed # @param tdctitle name of test (should not be changed) define tdc::test_manual ( Array $manual = [], String $nagiosout = "${tdc::nagiosdir}/tdc-${facts['networking']['fqdn']}-${title}-manual", String $nagioscheckprefix = '/usr/local/nagios/plugins', String $tdctitle = $title, ) { #) inherits tdc { Exec { path => ['/usr/bin', '/usr/sbin', '/bin'], } concat { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-manual.cfg": owner => 'root', group => 'root', mode => '0644', } concat::fragment { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-manual.cfg header": target => "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-manual.cfg", content => epp('tdc/tdc_config_header.epp', { 'type' => 'manual test', 'cmn' => $title }), order => '00', } generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} service no dummy") generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} hostgroup no dummy ${facts['networking']['fqdn']}") # create the tests from the manual array $lfqdn=$facts['networking']['fqdn'] $manual.each | $f, $fff | { concat::fragment { "${fff} ${f}": target => "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-manual.cfg", content => "command[check_tdc_${title}-${f}-${lfqdn}-manual]=${nagioscheckprefix}/${fff} \n", notify => Service[$tdc::nrpeservice], } generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} service yes check_tdc_${title}-${f}-${lfqdn}-manual ${fff}") generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} hostgroup yes check_tdc_${title}-${f}-${lfqdn}-manual ${lfqdn}") } #III we don't need hosts yet: # generate ("/bin/bash", "-c", "${tdc::generator} ${tdc::nagiosdir}/tdc-$fqdn-${title}-manual host no $fqdn") } puppet-tdc/manifests/test_package_version.pp000066400000000000000000000067411464600721300217070ustar00rootroot00000000000000# # TDC: Test-driven configuration # # define for testing version of a package # # Copyright (C) 2024 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # # @summary create tests for a list of packages # # @example Basic usage # define { 'tdc::test_file': # file => ['/usr/sbin/ntpd', '/etc/ntp.conf'], # } # # @param packages Array of packages to be tested # @param versions Array of versions to be tested # @param nagiosout outputfile for this test # @param nagioscheck name of check to be performed # @param tdctitle name of test (should not be changed) define tdc::test_package_version ( Array $packages = [], Array $versions = [], String $nagiosout = "${tdc::nagiosdir}/tdc-${facts['networking']['fqdn']}-${title}-package_version", String $nagioscheck = "${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_package_version", String $tdctitle = $title, ) { #) inherits tdc { include tdc Exec { path => ['/usr/bin', '/usr/sbin', '/bin'], } concat { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-package_version.cfg": owner => 'root', group => 'root', mode => '0644', } concat::fragment { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-package_version.cfg header": target => "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-package_version.cfg", content => epp('tdc/tdc_config_header.epp', { 'type' => 'test for package version', 'cmn' => $title }), order => '00', } generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} service no dummy") generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} hostgroup no dummy ${facts['networking']['fqdn']}") # create the tests from the packages array $lfqdn=$facts['networking']['fqdn'] $packages.each | $f, $fff | { concat::fragment { "${fff} ${f}": target => "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-package_version.cfg", content => "command[check_tdc_${title}-${f}-${lfqdn}-packages]=${nagioscheck} ${fff} ${versions[$f]}\n", notify => Service[$tdc::nrpeservice], } generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} service yes check_tdc_${title}-${f}-${lfqdn}-package_version") generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} hostgroup yes check_tdc_${title}-${f}-${lfqdn}-package_version ${lfqdn}") } if !defined(File["${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_package_version"]) { file { "${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_package_version": ensure => file, owner => 'root', group => 'root', mode => '0755', path => "${tdc::checkrootdir}/${tdc::checkscriptdir}/check_tdc_package_version", content => epp('tdc/check_tdc_package_version.epp'), } } #III we don't need hosts yet: # generate ("/bin/bash", "-c", "${tdc::generator} ${tdc::nagiosdir}/tdc-$lfqdn-${title}-file host no $lfqdn") } puppet-tdc/manifests/test_process.pp000066400000000000000000000060741464600721300202240ustar00rootroot00000000000000# # TDC: Test-driven configuration # # define for testing presence of a list of running processes # # Copyright (C) 2020-2024 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # # @summary create tests for a list of processes # # @example Basic usage # define { 'tdc::test_process': # process => ['tayga'], # } # # @param process Array of processes to be tested # @param nagiosout outputfile for this test # @param nagioscheck name of check to be performed # @param minprocs minimal number of processes that should be available # @param maxprocs maximal number of processes that should be available # @param tdctitle name of test (should not be changed) define tdc::test_process ( Array $process = [], String $nagiosout = "${tdc::nagiosdir}/tdc-${facts['networking']['fqdn']}-${title}-process", String $nagioscheck = '/usr/lib/nagios/plugins/check_procs', Integer $minprocs = 1, Integer $maxprocs = 1, String $tdctitle = $title, ) { #) inherits tdc { Exec { path => ['/usr/bin', '/usr/sbin', '/bin'], } concat { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-process.cfg": owner => 'root', group => 'root', mode => '0644', } concat::fragment { "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-process.cfg header": target => "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-process.cfg", content => epp('tdc/tdc_config_header.epp', { 'type' => 'test for process', 'cmn' => $title }), order => '00', } generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} service no dummy") generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} hostgroup no dummy ${facts['networking']['fqdn']}") # create the tests from the process array $lfqdn=$facts['networking']['fqdn'] $process.each | $f, $fff | { concat::fragment { "${fff} ${f}": target => "${tdc::checkrootdir}/${tdc::checkconfigdir}/tdc_${title}-process.cfg", content => "command[check_tdc_${title}-${f}-${lfqdn}-process]=${nagioscheck} -C ${fff} -c ${minprocs}:${maxprocs}\n", notify => Service[$tdc::nrpeservice], } generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} service yes check_tdc_${title}-${f}-${lfqdn}-process") generate ('/bin/bash', '-c', "${tdc::generator} ${nagiosout} hostgroup yes check_tdc_${title}-${f}-${lfqdn}-process ${lfqdn}") } #III we don't need hosts yet: # generate ("/bin/bash", "-c", "${tdc::generator} ${tdc::nagiosdir}/tdc-$fqdn-${title}-process host no $fqdn") } puppet-tdc/metadata.json000066400000000000000000000026501464600721300156240ustar00rootroot00000000000000{ "name": "alteholz-tdc", "version": "0.0.4", "author": "Thorsten Alteholz", "summary": "test-driven configuration", "license": "GPL-2.0", "source": "https://github.com/alteholz/puppet-tdc", "project_page": "https://github.com/alteholz/puppet-tdc", "issues_url": "https://github.com/alteholz/puppet-tdc/issues", "dependencies": [ { "name": "puppetlabs/concat", "version_requirement": ">= 5.1.0 <= 6.2.0" } ], "operatingsystem_support": [ { "operatingsystem": "CentOS", "operatingsystemrelease": [ "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "7" ] }, { "operatingsystem": "RedHat", "operatingsystemrelease": [ "8" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "7" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "9" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "18.04" ] }, { "operatingsystem": "windows", "operatingsystemrelease": [ "2019", "10" ] } ], "requirements": [ { "name": "puppet", "version_requirement": ">= 4.10.0 < 7.0.0" } ], "pdk-version": "3.2.0", "template-url": "pdk-default#3.2.0", "template-ref": "tags/3.2.0-0-gb257ef1" } puppet-tdc/pdk.yaml000066400000000000000000000000171464600721300146060ustar00rootroot00000000000000--- ignore: [] puppet-tdc/spec/000077500000000000000000000000001464600721300141005ustar00rootroot00000000000000puppet-tdc/spec/default_facts.yml000066400000000000000000000004071464600721300174300ustar00rootroot00000000000000# 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 puppet-tdc/spec/spec_helper.rb000066400000000000000000000042611464600721300167210ustar00rootroot00000000000000# 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 default_facts = { puppetversion: Puppet.version, facterversion: Facter.version, } 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 # 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 puppet-tdc/templates/000077500000000000000000000000001464600721300151445ustar00rootroot00000000000000puppet-tdc/templates/check_tdc_config.epp000066400000000000000000000016611464600721300211120ustar00rootroot00000000000000#!/bin/bash # # TDC: Test-driven configuration # # performs config check # # Copyright (C) 2020-2024 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # parameter: COMMAND -> command to test config with COMMAND="$@" $COMMAND rc=$? if [ $rc == 0 ]; then echo "OK: $COMMAND works" exit 0 fi echo "CRITICAL: $COMMAND shows error $rc" exit 2 puppet-tdc/templates/check_tdc_directory.epp000066400000000000000000000017331464600721300216510ustar00rootroot00000000000000#!/bin/bash # # TDC: Test-driven configuration # # performs check whether directory is available and really is a directory # # Copyright (C) 2020-2024 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # parameter: DIRECTORY -> directory to test DIRECTORY=$1 if [ -d $DIRECTORY ]; then echo "OK: $DIRECTORY is available" exit 0 fi echo "CRITICAL: $DIRECTORY is not available" exit 2 puppet-tdc/templates/check_tdc_file.epp000066400000000000000000000016631464600721300205660ustar00rootroot00000000000000#!/bin/bash # # TDC: Test-driven configuration # # performs check whether file is available and really is a file # # Copyright (C) 2020-2024 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # parameter: FILE -> file to test FILE=$1 if [ -f $FILE ]; then echo "OK: $FILE is available" exit 0 fi echo "CRITICAL: $FILE is not available" exit 2 puppet-tdc/templates/check_tdc_file_group.epp000066400000000000000000000023371464600721300220010ustar00rootroot00000000000000#!/bin/bash # # TDC: Test-driven configuration # # performs check whether group access of file is correctly set # # Copyright (C) 2020-2024 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # parameter: FILE -> file to test # GROUP -> expected group of file FILE=$1 GROUP=$2 if [ ! -f $FILE ] && [ ! -d $FILE ]; then echo "CRITICAL: $FILE is not available" exit 2 fi STAT=/usr/bin/stat testgroup="$($STAT --format '%G' "$1")" if [ "x${testgroup}" = "x${GROUP}" ]; then echo "OK: group $GROUP of $FILE is OK" exit 0 else echo "CRITICAL: $GROUP is not group of $FILE" exit 2 fi echo "CRITICAL: what am I doing here" exit 2 puppet-tdc/templates/check_tdc_file_owner.epp000066400000000000000000000023251464600721300217740ustar00rootroot00000000000000#!/bin/bash # # TDC: Test-driven configuration # # performs check whether file owner is correctly set # # Copyright (C) 2020-2024 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # parameter: FILE -> file to test # OWNER -> expected owner of file FILE=$1 OWNER=$2 if [ ! -f $FILE ] && [ ! -d $FILE ]; then echo "CRITICAL: $FILE is not available" exit 2 fi STAT=/usr/bin/stat testowner="$($STAT --format '%U' "$1")" if [ "x${testowner}" = "x${OWNER}" ]; then echo "OK: owner $OWNER of $FILE is OK" exit 0 else echo "CRITICAL: $OWNER is not owner of $FILE" exit 2 fi echo "CRITICAL: what am I doing here" exit 2 puppet-tdc/templates/check_tdc_file_permission.epp000066400000000000000000000024171464600721300230340ustar00rootroot00000000000000#!/bin/bash # # TDC: Test-driven configuration # # performs check whether file permissions are correctly set # # Copyright (C) 2020-2024 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # parameter: FILE -> file to test # PERMISSION -> expected permissions of file FILE=$1 PERMISSION=$2 if [ ! -f $FILE ] && [ ! -d $FILE ]; then echo "CRITICAL: $FILE is not available" exit 2 fi STAT=/usr/bin/stat testpermission="$($STAT --format '%a' "$1")" if [ "x${testpermission}" = "x${PERMISSION}" ]; then echo "OK: permission $PERMISSION of $FILE is OK" exit 0 else echo "CRITICAL: $PERMISSION is not permission of $FILE" exit 2 fi echo "CRITICAL: what am I doing here" exit 2 puppet-tdc/templates/check_tdc_link.epp000066400000000000000000000016731464600721300206050ustar00rootroot00000000000000#!/bin/bash # # TDC: Test-driven configuration # # performs check whether link is available and really is a link # # Copyright (C) 2020-2024 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # parameter: LINK -> link to test LINK=$1 DEST=$2 if [ -L $LINK ]; then echo "OK: $LINK is available" exit 0 fi echo "CRITICAL: $LINK is not available" exit 2 puppet-tdc/templates/check_tdc_package_version.epp000066400000000000000000000025141464600721300230030ustar00rootroot00000000000000#!/bin/bash # # TDC: Test-driven configuration # # performs check whether installed package version is greater or equal than the required one # # Copyright (C) 2020-2024 Thorsten Alteholz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # parameter: PACKAGE -> package to test # parameter: VERSION -> version to test PACKAGE=$1 VERSION=$2 DPKG=/usr/bin/dpkg if [ ! -f $DPKG ]; then echo "CRITICAL: $DPKG not found" exit 2 fi PVERSION=`$DPKG -s $PACKAGE | grep '^Version:'|awk '{printf("%s\n",$2)}'` $DPKG --compare-versions $PVERSION gt $VERSION rc=$? if [ $rc == 0 ]; then echo "OK: $PACKAGE is at least available in version $VERSION (-> $PVERSION)" exit 0 fi echo "CRITICAL: version of $PACKAGE is $PVERSION which is not greater or equal to $VERSION" exit 2 puppet-tdc/templates/tdc_config_header.epp000066400000000000000000000001231464600721300212550ustar00rootroot00000000000000# this file contains the test created for <%= $type %> # in module <%= $cmn %> # #