From afbd0c08ac845d80f64a346f482b564fa62e8f38 Mon Sep 17 00:00:00 2001 From: Peter Verraedt Date: Tue, 21 Sep 2021 09:40:30 +0200 Subject: [PATCH 01/11] Support puppet 7 and stdlib 7 Signed-off-by: Peter Verraedt --- metadata.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metadata.json b/metadata.json index 9101d41..52b0238 100644 --- a/metadata.json +++ b/metadata.json @@ -10,7 +10,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 3.0.0 < 7.0.0" + "version_requirement": ">= 3.0.0 < 8.0.0" } ], "operatingsystem_support": [ @@ -67,6 +67,6 @@ ], "description": "Manage nsswitch. Supports LDAP integration.", "dependencies": [ - {"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 5.0.0"} + {"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 8.0.0"} ] } From cf8b61789d71d23c8d1703e34c270426c68579db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Roche?= Date: Fri, 7 Jul 2023 10:47:28 +0200 Subject: [PATCH 02/11] Relax dependency constraint and allow stdlib 8.x --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 52b0238..231faad 100644 --- a/metadata.json +++ b/metadata.json @@ -67,6 +67,6 @@ ], "description": "Manage nsswitch. Supports LDAP integration.", "dependencies": [ - {"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 8.0.0"} + {"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 9.0.0"} ] } From 8c82aadd612f22ba83f91c966f11c2d80a12b82e Mon Sep 17 00:00:00 2001 From: Yorick Poels Date: Tue, 4 Jun 2024 15:49:07 +0200 Subject: [PATCH 03/11] Relax stdlib - add puppet 8 to metadata --- metadata.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/metadata.json b/metadata.json index 231faad..a9559de 100644 --- a/metadata.json +++ b/metadata.json @@ -10,7 +10,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 3.0.0 < 8.0.0" + "version_requirement": ">= 7.0.0 < 9.0.0" } ], "operatingsystem_support": [ @@ -67,6 +67,9 @@ ], "description": "Manage nsswitch. Supports LDAP integration.", "dependencies": [ - {"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 9.0.0"} + { + "name": "puppetlabs/stdlib", + "version_requirement": ">= 4.6.0 < 10.0.0" + } ] } From 80d38ed1e2fc777765fe0031ed5ac38be6b05e2f Mon Sep 17 00:00:00 2001 From: Yorick Poels Date: Wed, 5 Jun 2024 14:50:21 +0200 Subject: [PATCH 04/11] Remove stdlib legacy functions - fix with new --- manifests/init.pp | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 46cdf60..6416f6d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -3,15 +3,15 @@ # This module manages nsswitch. # class nsswitch ( - $config_file = '/etc/nsswitch.conf', - $ensure_ldap = 'absent', - $ensure_vas = 'absent', - $vas_nss_module_passwd = 'vas4', - $vas_nss_module_group = 'vas4', - $vas_nss_module_automount = 'nis', - $vas_nss_module_netgroup = 'nis', - $vas_nss_module_aliases = undef, - $vas_nss_module_services = undef, + Stdlib::Absolutepath $config_file = '/etc/nsswitch.conf', + Enum['absent','present'] $ensure_ldap = 'absent', + Enum['absent','present'] $ensure_vas = 'absent', + String $vas_nss_module_passwd = 'vas4', + String $vas_nss_module_group = 'vas4', + String $vas_nss_module_automount = 'nis', + String $vas_nss_module_netgroup = 'nis', + String $vas_nss_module_aliases = undef, + String $vas_nss_module_services = undef, $passwd = 'USE_DEFAULTS', $sudoers = 'USE_DEFAULTS', $shadow = 'USE_DEFAULTS', @@ -32,19 +32,6 @@ $nsswitch_prof_attr = 'USE_DEFAULTS', $nsswitch_project = 'USE_DEFAULTS', ) { - - validate_absolute_path($config_file) - validate_re($ensure_ldap, '^(present|absent)$', - 'Valid values for ensure_ldap are \'absent\' and \'present\'.') - validate_re($ensure_vas, '^(present|absent)$', - 'Valid values for ensure_vas are \'absent\' and \'present\'.') - validate_string($vas_nss_module_passwd) - validate_string($vas_nss_module_group) - validate_string($vas_nss_module_automount) - validate_string($vas_nss_module_netgroup) - validate_string($vas_nss_module_aliases) - validate_string($vas_nss_module_services) - case $::osfamily { 'Debian','Suse': { $default_passwd = 'files' From 18d1172e2ae9b724aa6c7b3d67666181835e50a4 Mon Sep 17 00:00:00 2001 From: Yorick Poels Date: Wed, 5 Jun 2024 16:05:24 +0200 Subject: [PATCH 05/11] Convert with PDK --- .gitattributes | 5 + .gitignore | 58 ++-- .pdkignore | 44 +++ .puppet-lint.rc | 1 + .rspec | 2 + .rubocop.yml | 730 ++++++++++++++++++++++++++++++++++++++++ .sync.yml | 8 + .vscode/extensions.json | 6 + .yardopts | 1 + Gemfile | 108 ++++-- Rakefile | 21 +- data/common.yaml | 1 + hiera.yaml | 21 ++ metadata.json | 19 +- spec/default_facts.yml | 9 + spec/spec_helper.rb | 79 ++++- 16 files changed, 1011 insertions(+), 102 deletions(-) create mode 100644 .gitattributes create mode 100644 .pdkignore create mode 100644 .puppet-lint.rc create mode 100644 .rspec create mode 100644 .rubocop.yml create mode 100644 .sync.yml create mode 100644 .vscode/extensions.json create mode 100644 .yardopts create mode 100644 data/common.yaml create mode 100644 hiera.yaml create mode 100644 spec/default_facts.yml diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9032a01 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +*.rb eol=lf +*.erb eol=lf +*.pp eol=lf +*.sh eol=lf +*.epp eol=lf diff --git a/.gitignore b/.gitignore index 222e35e..3f15512 100644 --- a/.gitignore +++ b/.gitignore @@ -1,34 +1,28 @@ -# Default .gitignore for Ruby -*.gem -*.rbc -.bundle -.config -coverage -InstalledFiles -lib/bundler/man -pkg -rdoc -spec/reports -test/tmp -test/version_tmp -tmp - -# YARD artifacts +.git/ +.*.sw[op] +.metadata .yardoc -_yardoc -doc/ - -# Vim -*.swp - -# Eclipse -.project - -# OS X +.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 - -# Puppet -coverage/ -spec/fixtures/manifests/* -spec/fixtures/modules/* -Gemfile.lock +.project +.envrc +/inventory.yaml +/spec/fixtures/litmus_inventory.yaml diff --git a/.pdkignore b/.pdkignore new file mode 100644 index 0000000..862847a --- /dev/null +++ b/.pdkignore @@ -0,0 +1,44 @@ +.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/ diff --git a/.puppet-lint.rc b/.puppet-lint.rc new file mode 100644 index 0000000..cc96ece --- /dev/null +++ b/.puppet-lint.rc @@ -0,0 +1 @@ +--relative diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..16f9cdb --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--color +--format documentation diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..21b82b9 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,730 @@ +--- +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 diff --git a/.sync.yml b/.sync.yml new file mode 100644 index 0000000..8c2c98e --- /dev/null +++ b/.sync.yml @@ -0,0 +1,8 @@ +# This file can be used to customize the files managed by PDK. +# +# See https://github.com/puppetlabs/pdk-templates/blob/main/README.md +# for more information. +# +# See https://github.com/puppetlabs/pdk-templates/blob/main/config_defaults.yml +# for the default values. +--- {} diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..6da8d47 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "puppet.puppet-vscode", + "Shopify.ruby-lsp" + ] +} diff --git a/.yardopts b/.yardopts new file mode 100644 index 0000000..29c933b --- /dev/null +++ b/.yardopts @@ -0,0 +1 @@ +--markup markdown diff --git a/Gemfile b/Gemfile index 8c48d01..7a9ef2e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,41 +1,77 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' -if puppetversion = ENV['PUPPET_GEM_VERSION'] - gem 'puppet', puppetversion, :require => false -else - gem 'puppet', :require => false +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'), +] -gem 'facter', '>= 2.2.0' -gem 'rspec-puppet', '~> 2.0' -gem 'puppet-lint' -gem 'puppet-lint-absolute_classname-check' -gem 'puppet-lint-alias-check' -gem 'puppet-lint-empty_string-check' -gem 'puppet-lint-file_ensure-check' -gem 'puppet-lint-file_source_rights-check' -gem 'puppet-lint-leading_zero-check' -gem 'puppet-lint-spaceship_operator_without_tag-check' -gem 'puppet-lint-trailing_comma-check' -gem 'puppet-lint-undef_in_function-check' -gem 'puppet-lint-unquoted_string-check' -gem 'puppet-lint-variable_contains_upcase' - -gem 'rspec', '~> 2.0' if RUBY_VERSION >= '1.8.7' && RUBY_VERSION < '1.9' -gem 'rake', '~> 10.0' if RUBY_VERSION >= '1.8.7' && RUBY_VERSION < '1.9' -gem 'json', '<= 1.8' if RUBY_VERSION < '2.0.0' -gem 'json_pure', '<= 2.0.1' if RUBY_VERSION < '2.0.0' -gem 'metadata-json-lint', '0.0.11' if RUBY_VERSION <= '1.9.3' -gem 'metadata-json-lint' if RUBY_VERSION > '1.9.3' -gem 'public_suffix', '~> 1.1.0' if RUBY_VERSION < '2.1.1' && RUBY_VERSION >= '1.9' -gem 'public_suffix', '1.3.0' if RUBY_VERSION < '1.9' - -gem 'puppetlabs_spec_helper', '2.0.2', :require => false if RUBY_VERSION >= '1.8.7' && RUBY_VERSION < '1.9' -gem 'puppetlabs_spec_helper', '>= 2.0.0', :require => false if RUBY_VERSION >= '1.9' -gem 'parallel_tests', '<= 2.9.0', :require => false if RUBY_VERSION < '2.0.0' && RUBY_VERSION >= '1.9' -gem 'parallel_tests', '1.0.9', :require => false if RUBY_VERSION < '1.9' -gem 'parallel', '1.3.3.1', :require => false if RUBY_VERSION < '1.9' - -if puppetversion && puppetversion < '5.0' && RUBY_VERSION >= '2.1.9' - gem 'semantic_puppet', :require => false +extra_gemfiles.each do |gemfile| + if File.file?(gemfile) && File.readable?(gemfile) + eval(File.read(gemfile), binding) + end end +# vim: syntax=ruby diff --git a/Rakefile b/Rakefile index 2e8251e..77590fe 100644 --- a/Rakefile +++ b/Rakefile @@ -1,16 +1,9 @@ +# 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-lint/tasks/puppet-lint' -PuppetLint.configuration.send('disable_80chars') -PuppetLint.configuration.send('disable_140chars') -PuppetLint.configuration.relative = true -PuppetLint.configuration.ignore_paths = ['spec/**/*.pp', 'pkg/**/*.pp', 'vendor/**/*.pp'] +require 'puppet-syntax/tasks/puppet-syntax' +require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings' -desc 'Validate manifests, templates, and ruby files' -task :validate do - Dir['spec/**/*.rb', 'lib/**/*.rb'].each do |ruby_file| - sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/ - end - Dir['files/**/*.sh'].each do |shell_script| - sh "bash -n #{shell_script}" - end -end +PuppetLint.configuration.send('disable_relative') diff --git a/data/common.yaml b/data/common.yaml new file mode 100644 index 0000000..2fbf0ff --- /dev/null +++ b/data/common.yaml @@ -0,0 +1 @@ +--- {} diff --git a/hiera.yaml b/hiera.yaml new file mode 100644 index 0000000..545fff3 --- /dev/null +++ b/hiera.yaml @@ -0,0 +1,21 @@ +--- +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' diff --git a/metadata.json b/metadata.json index a9559de..d5ad1b4 100644 --- a/metadata.json +++ b/metadata.json @@ -7,10 +7,10 @@ "source": "git://github.com/ghoneycutt/puppet-module-nsswitch.git", "project_page": "https://github.com/ghoneycutt/puppet-module-nsswitch", "issues_url": "https://github.com/ghoneycutt/puppet-module-nsswitch/issues", - "requirements": [ + "dependencies": [ { - "name": "puppet", - "version_requirement": ">= 7.0.0 < 9.0.0" + "name": "puppetlabs/stdlib", + "version_requirement": ">= 4.6.0 < 10.0.0" } ], "operatingsystem_support": [ @@ -65,11 +65,14 @@ "operatingsystem": "SLED" } ], - "description": "Manage nsswitch. Supports LDAP integration.", - "dependencies": [ + "requirements": [ { - "name": "puppetlabs/stdlib", - "version_requirement": ">= 4.6.0 < 10.0.0" + "name": "puppet", + "version_requirement": ">= 7.0.0 < 9.0.0" } - ] + ], + "description": "Manage nsswitch. Supports LDAP integration.", + "pdk-version": "3.2.0", + "template-url": "pdk-default#3.2.0", + "template-ref": "tags/3.2.0-0-gb257ef1" } diff --git a/spec/default_facts.yml b/spec/default_facts.yml new file mode 100644 index 0000000..3346c39 --- /dev/null +++ b/spec/default_facts.yml @@ -0,0 +1,9 @@ +# Use default_module_facts.yml for module specific facts. +# +# Facts specified here will override the values provided by rspec-puppet-facts. +--- +networking: + ip: "172.16.254.254" + ip6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" + mac: "AA:AA:AA:AA:AA:AA" +is_pe: false diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cd91de5..ae7c1f6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,20 +1,75 @@ +# 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 -RSpec.configure do |config| - config.hiera_config = 'spec/fixtures/hiera/hiera.yaml' - config.before :each do - # Ensure that we don't accidentally cache facts and environment between - # test cases. This requires each example group to explicitly load the - # facts being exercised with something like - # Facter.collection.loader.load(:ipaddress) - Facter.clear - Facter.clear_messages + # 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 - config.default_facts = { - :environment => 'rp_env', - } 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 From e5ef404ff5c04a285b20f4720f7a650e22ca4b78 Mon Sep 17 00:00:00 2001 From: Yorick Poels Date: Wed, 5 Jun 2024 17:37:20 +0200 Subject: [PATCH 06/11] Rewrite init manifest to support hieradata Also remove all legacy stdlib validation functions and replace with up to date param checking --- manifests/init.pp | 287 ++++++++++++++-------------------------------- 1 file changed, 83 insertions(+), 204 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 6416f6d..6f48886 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -3,268 +3,147 @@ # This module manages nsswitch. # class nsswitch ( - Stdlib::Absolutepath $config_file = '/etc/nsswitch.conf', - Enum['absent','present'] $ensure_ldap = 'absent', - Enum['absent','present'] $ensure_vas = 'absent', - String $vas_nss_module_passwd = 'vas4', - String $vas_nss_module_group = 'vas4', - String $vas_nss_module_automount = 'nis', - String $vas_nss_module_netgroup = 'nis', - String $vas_nss_module_aliases = undef, - String $vas_nss_module_services = undef, - $passwd = 'USE_DEFAULTS', - $sudoers = 'USE_DEFAULTS', - $shadow = 'USE_DEFAULTS', - $group = 'USE_DEFAULTS', - $hosts = 'USE_DEFAULTS', - $automount = 'USE_DEFAULTS', - $services = 'USE_DEFAULTS', - $bootparams = 'USE_DEFAULTS', - $aliases = 'USE_DEFAULTS', - $publickey = 'USE_DEFAULTS', - $netgroup = 'USE_DEFAULTS', - $protocols = 'USE_DEFAULTS', - $ethers = 'USE_DEFAULTS', - $rpc = 'USE_DEFAULTS', - $nsswitch_ipnodes = 'USE_DEFAULTS', - $nsswitch_printers = 'USE_DEFAULTS', - $nsswitch_auth_attr = 'USE_DEFAULTS', - $nsswitch_prof_attr = 'USE_DEFAULTS', - $nsswitch_project = 'USE_DEFAULTS', + Stdlib::Absolutepath $config_file, + Enum['absent','present'] $ensure_ldap, + Enum['absent','present'] $ensure_vas, + String $vas_nss_module_passwd, + String $vas_nss_module_group, + String $vas_nss_module_automount, + String $vas_nss_module_netgroup, + String $vas_nss_module_aliases, + String $vas_nss_module_services, + String $passwd, + String $sudoers, + String $shadow, + String $group, + String $hosts, + String $automount, + String $services, + String $bootparams, + String $aliases, + String $publickey, + String $netgroup, + String $protocols, + String $ethers, + String $rpc, + String $nsswitch_ipnodes, + String $nsswitch_printers, + String $nsswitch_auth_attr, + String $nsswitch_prof_attr, + String $nsswitch_project, ) { - case $::osfamily { - 'Debian','Suse': { - $default_passwd = 'files' - $default_sudoers = 'files' - $default_shadow = 'files' - $default_group = 'files' - $default_hosts = 'files dns' - $default_automount = 'files' - $default_services = 'files' - $default_bootparams = 'files' - $default_aliases = 'files' - $default_publickey = 'files' - $default_netgroup = 'files' - $default_protocols = 'files' - $default_ethers = 'files' - $default_rpc = 'files' - $default_nsswitch_ipnodes = undef - $default_nsswitch_printers = undef - $default_nsswitch_auth_attr = undef - $default_nsswitch_prof_attr = undef - $default_nsswitch_project = undef - } - 'RedHat': { - if $::operatingsystemmajrelease == '7' { - $default_passwd = 'files sss' - $default_sudoers = 'files sss' - $default_shadow = 'files sss' - $default_group = 'files sss' - $default_hosts = 'files dns myhostname' - $default_automount = 'files sss' - $default_services = 'files sss' - $default_bootparams = 'nisplus [NOTFOUND=return] files' - $default_aliases = 'files nisplus' - $default_publickey = 'nisplus' - $default_netgroup = 'files sss' - $default_protocols = 'files' - $default_ethers = 'files' - $default_rpc = 'files' - } else { - $default_passwd = 'files' - $default_sudoers = 'files' - $default_shadow = 'files' - $default_group = 'files' - $default_hosts = 'files dns' - $default_automount = 'files' - $default_services = 'files' - $default_bootparams = 'files' - $default_aliases = 'files' - $default_publickey = 'files' - $default_netgroup = 'files' - $default_protocols = 'files' - $default_ethers = 'files' - $default_rpc = 'files' - } - - $default_nsswitch_ipnodes = undef - $default_nsswitch_printers = undef - $default_nsswitch_auth_attr = undef - $default_nsswitch_prof_attr = undef - $default_nsswitch_project = undef - } - 'Solaris': { - $default_passwd = 'files' - $default_sudoers = 'files' - $default_shadow = 'files' - $default_group = 'files' - $default_hosts = 'files dns' - $default_automount = 'files' - $default_services = 'files' - $default_bootparams = 'files' - $default_aliases = 'files' - $default_publickey = 'files' - $default_netgroup = 'files' - $default_protocols = 'files' - $default_ethers = 'files' - $default_rpc = 'files' - $default_nsswitch_ipnodes = 'files dns' - $default_nsswitch_printers = 'user files' - $default_nsswitch_auth_attr = 'files' - $default_nsswitch_prof_attr = 'files' - $default_nsswitch_project = 'files' - } - default: { - fail("nsswitch supports osfamilies Debian, RedHat, Solaris and Suse. Detected osfamily is <${::osfamily}>.") - } - } - if $passwd == 'USE_DEFAULTS' { - $passwd_real = $default_passwd + $passwd_real = $nsswitch::default_passwd } else { $passwd_real = $passwd } - validate_string($passwd_real) - if $protocols == 'USE_DEFAULTS' { - $protocols_real = $default_protocols + if $nsswitch::protocols == 'USE_DEFAULTS' { + $protocols_real = $nsswitch::default_protocols } else { - $protocols_real = $protocols + $protocols_real = $nsswitch::protocols } - validate_string($protocols_real) - if $ethers == 'USE_DEFAULTS' { - $ethers_real = $default_ethers + if $nsswitch::ethers == 'USE_DEFAULTS' { + $ethers_real = $nsswitch::default_ethers } else { - $ethers_real = $ethers + $ethers_real = $nsswitch::ethers } - validate_string($ethers_real) - if $rpc == 'USE_DEFAULTS' { - $rpc_real = $default_rpc + if $nsswitch::rpc == 'USE_DEFAULTS' { + $rpc_real = $nsswitch::default_rpc } else { - $rpc_real = $rpc + $rpc_real = $nsswitch::rpc } - validate_string($rpc_real) - if $shadow == 'USE_DEFAULTS' { - $shadow_real = $default_shadow + if $nsswitch::shadow == 'USE_DEFAULTS' { + $shadow_real = $nsswitch::default_shadow } else { - $shadow_real = $shadow + $shadow_real = $nsswitch::shadow } - validate_string($shadow_real) - if $sudoers == 'USE_DEFAULTS' { - $sudoers_real = $default_sudoers + if $nsswitch::sudoers == 'USE_DEFAULTS' { + $sudoers_real = $nsswitch::default_sudoers } else { - $sudoers_real = $sudoers + $sudoers_real = $nsswitch::sudoers } - validate_string($sudoers_real) - if $group == 'USE_DEFAULTS' { - $group_real = $default_group + if $nsswitch::group == 'USE_DEFAULTS' { + $group_real = $nsswitch::default_group } else { - $group_real = $group + $group_real = $nsswitch::group } - validate_string($group_real) - if $hosts == 'USE_DEFAULTS' { - $hosts_real = $default_hosts + if $nsswitch::hosts == 'USE_DEFAULTS' { + $hosts_real = $nsswitch::default_hosts } else { - $hosts_real = $hosts + $hosts_real = $nsswitch::hosts } - validate_string($hosts_real) - if $automount == 'USE_DEFAULTS' { - $automount_real = $default_automount + if $nsswitch::automount == 'USE_DEFAULTS' { + $automount_real = $nsswitch::default_automount } else { - $automount_real = $automount + $automount_real = $nsswitch::automount } - validate_string($automount_real) - if $services == 'USE_DEFAULTS' { - $services_real = $default_services + if $nsswitch::services == 'USE_DEFAULTS' { + $services_real = $nsswitch::default_services } else { - $services_real = $services + $services_real = $nsswitch::services } - validate_string($services_real) - if $bootparams == 'USE_DEFAULTS' { - $bootparams_real = $default_bootparams + if $nsswitch::bootparams == 'USE_DEFAULTS' { + $bootparams_real = $nsswitch::default_bootparams } else { - $bootparams_real = $bootparams + $bootparams_real = $nsswitch::bootparams } - validate_string($bootparams_real) - if $aliases == 'USE_DEFAULTS' { - $aliases_real = $default_aliases + if $nsswitch::aliases == 'USE_DEFAULTS' { + $aliases_real = $nsswitch::default_aliases } else { - $aliases_real = $aliases + $aliases_real = $nsswitch::aliases } - validate_string($aliases_real) - if $publickey == 'USE_DEFAULTS' { - $publickey_real = $default_publickey + if $nsswitch::publickey == 'USE_DEFAULTS' { + $publickey_real = $nsswitch::default_publickey } else { - $publickey_real = $publickey + $publickey_real = $nsswitch::publickey } - validate_string($publickey_real) - if $netgroup == 'USE_DEFAULTS' { - $netgroup_real = $default_netgroup + if $nsswitch::netgroup == 'USE_DEFAULTS' { + $netgroup_real = $nsswitch::default_netgroup } else { - $netgroup_real = $netgroup + $netgroup_real = $nsswitch::netgroup } - validate_string($netgroup_real) - if $nsswitch_ipnodes == 'USE_DEFAULTS' { - $nsswitch_ipnodes_real = $default_nsswitch_ipnodes + if $nsswitch::nsswitch_ipnodes == 'USE_DEFAULTS' { + $nsswitch_ipnodes_real = $nsswitch::default_nsswitch_ipnodes } else { - $nsswitch_ipnodes_real = $nsswitch_ipnodes + $nsswitch_ipnodes_real = $nsswitch::nsswitch_ipnodes } - if $nsswitch_ipnodes_real != undef { - validate_string($nsswitch_ipnodes_real) - } - - if $nsswitch_printers == 'USE_DEFAULTS' { - $nsswitch_printers_real = $default_nsswitch_printers + if $nsswitch::nsswitch_printers == 'USE_DEFAULTS' { + $nsswitch_printers_real = $nsswitch::default_nsswitch_printers } else { - $nsswitch_printers_real = $nsswitch_printers - } - - if $nsswitch_printers_real != undef { - validate_string($nsswitch_printers_real) + $nsswitch_printers_real = $nsswitch::nsswitch_printers } - if $nsswitch_auth_attr == 'USE_DEFAULTS' { - $nsswitch_auth_attr_real = $default_nsswitch_auth_attr + if $nsswitch::nsswitch_auth_attr == 'USE_DEFAULTS' { + $nsswitch_auth_attr_real = $nsswitch::default_nsswitch_auth_attr } else { - $nsswitch_auth_attr_real = $nsswitch_auth_attr + $nsswitch_auth_attr_real = $nsswitch::nsswitch_auth_attr } - if $nsswitch_auth_attr_real != undef { - validate_string($nsswitch_auth_attr_real) - } - - if $nsswitch_prof_attr == 'USE_DEFAULTS' { - $nsswitch_prof_attr_real = $default_nsswitch_prof_attr + if $nsswitch::nsswitch_prof_attr == 'USE_DEFAULTS' { + $nsswitch_prof_attr_real = $nsswitch::default_nsswitch_prof_attr } else { - $nsswitch_prof_attr_real = $nsswitch_prof_attr - } - - if $nsswitch_prof_attr_real != undef { - validate_string($nsswitch_prof_attr_real) + $nsswitch_prof_attr_real = $nsswitch::nsswitch_prof_attr } - if $nsswitch_project == 'USE_DEFAULTS' { - $nsswitch_project_real = $default_nsswitch_project + if $nsswitch::nsswitch_project == 'USE_DEFAULTS' { + $nsswitch_project_real = $nsswitch::default_nsswitch_project } else { - $nsswitch_project_real = $nsswitch_project - } - - if $nsswitch_project_real != undef { - validate_string($nsswitch_project_real) + $nsswitch_project_real = $nsswitch::nsswitch_project } file { 'nsswitch_config_file': From 0ce36f247eaa30e99e0941ab29dbc682443e223e Mon Sep 17 00:00:00 2001 From: Yorick Poels Date: Wed, 5 Jun 2024 17:46:26 +0200 Subject: [PATCH 07/11] Clean up metadata - remove some OS Remove old releases - add Alma and Rocky --- metadata.json | 39 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/metadata.json b/metadata.json index d5ad1b4..c92281b 100644 --- a/metadata.json +++ b/metadata.json @@ -17,53 +17,38 @@ { "operatingsystem": "Debian", "operatingsystemrelease": [ - "6" + "11", + "12" ] }, { "operatingsystem": "RedHat", "operatingsystemrelease": [ - "5", - "6", - "7" + "8", + "9" ] }, { - "operatingsystem": "CentOS", + "operatingsystem": "AlmaLinux", "operatingsystemrelease": [ - "5", - "6", - "7" + "8", + "9" ] }, { - "operatingsystem": "OracleLinux", + "operatingsystem": "RockyLinux", "operatingsystemrelease": [ - "5", - "6", - "7" - ] - }, - { - "operatingsystem": "Scientific", - "operatingsystemrelease": [ - "5", - "6", - "7" + "8", + "9" ] }, { "operatingsystem": "Solaris", "operatingsystemrelease": [ - "10" + "10", + "11" ] }, - { - "operatingsystem": "SLES" - }, - { - "operatingsystem": "SLED" - } ], "requirements": [ { From f96521355384b3a925b6f1cd1acdc907a055db5d Mon Sep 17 00:00:00 2001 From: Yorick Poels Date: Wed, 5 Jun 2024 17:47:22 +0200 Subject: [PATCH 08/11] Add common hieradata --- data/common.yaml | 52 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/data/common.yaml b/data/common.yaml index 2fbf0ff..5dde202 100644 --- a/data/common.yaml +++ b/data/common.yaml @@ -1 +1,51 @@ ---- {} +--- + +nsswitch::config_file: '/etc/nsswitch.conf' +nsswitch::ensure_ldap: absent +nsswitch::ensure_vas: 'absent' +nsswitch::vas_nss_module_passwd: 'vas4' +nsswitch::vas_nss_module_group: 'vas4' +nsswitch::vas_nss_module_automount: 'nis' +nsswitch::vas_nss_module_netgroup: 'nis' +nsswitch::vas_nss_module_aliases: undef +nsswitch::vas_nss_module_services: undef +# +nsswitch::default_passwd: 'files' +nsswitch::default_sudoers: 'files' +nsswitch::default_shadow: 'files' +nsswitch::default_group: 'files' +nsswitch::default_hosts: 'files dns' +nsswitch::default_automount: 'files' +nsswitch::default_services: 'files' +nsswitch::default_bootparams: 'files' +nsswitch::default_aliases: 'files' +nsswitch::default_publickey: 'files' +nsswitch::default_netgroup: 'files' +nsswitch::default_protocols: 'files' +nsswitch::default_ethers: 'files' +nsswitch::default_rpc: 'files' +nsswitch::default_nsswitch_ipnodes: undef +nsswitch::default_nsswitch_printers: undef +nsswitch::default_nsswitch_auth_attr: undef +nsswitch::default_nsswitch_prof_attr: undef +nsswitch::default_nsswitch_project: undef +# +nsswitch::passwd: USE_DEFAULTS +nsswitch::sudoers: USE_DEFAULTS +nsswitch::shadow: USE_DEFAULTS +nsswitch::group: USE_DEFAULTS +nsswitch::hosts: USE_DEFAULTS +nsswitch::automount: USE_DEFAULTS +nsswitch::services: USE_DEFAULTS +nsswitch::bootparams: USE_DEFAULTS +nsswitch::aliases: USE_DEFAULTS +nsswitch::publickey: USE_DEFAULTS +nsswitch::netgroup: USE_DEFAULTS +nsswitch::protocols: USE_DEFAULTS +nsswitch::ethers: USE_DEFAULTS +nsswitch::rpc: USE_DEFAULTS +nsswitch::nsswitch_ipnodes: USE_DEFAULTS +nsswitch::nsswitch_printers: USE_DEFAULTS +nsswitch::nsswitch_auth_attr: USE_DEFAULTS +nsswitch::nsswitch_prof_attr: USE_DEFAULTS +nsswitch::nsswitch_project: USE_DEFAULTS From 91161a64ef38c762ae2f79aaed0e7ae1c616ede8 Mon Sep 17 00:00:00 2001 From: Yorick Poels Date: Wed, 5 Jun 2024 17:47:35 +0200 Subject: [PATCH 09/11] Add osfamily specific data --- data/os/Debian.yaml | 20 ++++++++++++++++++++ data/os/RedHat.yaml | 20 ++++++++++++++++++++ data/os/Solaris.yaml | 20 ++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 data/os/Debian.yaml create mode 100644 data/os/RedHat.yaml create mode 100644 data/os/Solaris.yaml diff --git a/data/os/Debian.yaml b/data/os/Debian.yaml new file mode 100644 index 0000000..72aacee --- /dev/null +++ b/data/os/Debian.yaml @@ -0,0 +1,20 @@ +--- +nsswitch::default_passwd: 'files' +nsswitch::default_sudoers: 'files' +nsswitch::default_shadow: 'files' +nsswitch::default_group: 'files' +nsswitch::default_hosts: 'files dns' +nsswitch::default_automount: 'files' +nsswitch::default_services: 'files' +nsswitch::default_bootparams: 'files' +nsswitch::default_aliases: 'files' +nsswitch::default_publickey: 'files' +nsswitch::default_netgroup: 'files' +nsswitch::default_protocols: 'files' +nsswitch::default_ethers: 'files' +nsswitch::default_rpc: 'files' +nsswitch::default_nsswitch_ipnodes: undef +nsswitch::default_nsswitch_printers: undef +nsswitch::default_nsswitch_auth_attr: undef +nsswitch::default_nsswitch_prof_attr: undef +nsswitch::default_nsswitch_project: undef diff --git a/data/os/RedHat.yaml b/data/os/RedHat.yaml new file mode 100644 index 0000000..79c266e --- /dev/null +++ b/data/os/RedHat.yaml @@ -0,0 +1,20 @@ +--- +nsswitch::default_passwd: 'files' +nsswitch::default_sudoers: 'files' +nsswitch::default_shadow: 'files' +nsswitch::default_group: 'files' +nsswitch::default_hosts: 'files dns' +nsswitch::default_automount: 'files' +nsswitch::default_services: 'files' +nsswitch::default_bootparams: 'files' +nsswitch::default_aliases: 'files' +nsswitch::default_publickey: 'files' +nsswitch::default_netgroup: 'files' +nsswitch::default_protocols: 'files' +nsswitch::default_ethers: 'files' +nsswitch::default_rpc: 'files' +nsswitch::default_nsswitch_ipnodes: undef +nsswitch::default_nsswitch_printers: undef +nsswitch::default_nsswitch_auth_attr: undef +nsswitch::default_nsswitch_prof_attr: undef +nsswitch::default_nsswitch_project: undef \ No newline at end of file diff --git a/data/os/Solaris.yaml b/data/os/Solaris.yaml new file mode 100644 index 0000000..166bf8c --- /dev/null +++ b/data/os/Solaris.yaml @@ -0,0 +1,20 @@ +--- +nsswitch::default_passwd: 'files' +nsswitch::default_sudoers: 'files' +nsswitch::default_shadow: 'files' +nsswitch::default_group: 'files' +nsswitch::default_hosts: 'files dns' +nsswitch::default_automount: 'files' +nsswitch::default_services: 'files' +nsswitch::default_bootparams: 'files' +nsswitch::default_aliases: 'files' +nsswitch::default_publickey: 'files' +nsswitch::default_netgroup: 'files' +nsswitch::default_protocols: 'files' +nsswitch::default_ethers: 'files' +nsswitch::default_rpc: 'files' +nsswitch::default_nsswitch_ipnodes: 'files dns' +nsswitch::default_nsswitch_printers: 'user files' +nsswitch::default_nsswitch_auth_attr: 'files' +nsswitch::default_nsswitch_prof_attr: 'files' +nsswitch::default_nsswitch_project: 'files' \ No newline at end of file From b1338a21d783e05cc4511b53c419d71f0d48d8b6 Mon Sep 17 00:00:00 2001 From: Yorick Poels Date: Tue, 11 Jun 2024 17:47:37 +0200 Subject: [PATCH 10/11] Fix metadata syntax error --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index c92281b..548f0e0 100644 --- a/metadata.json +++ b/metadata.json @@ -48,7 +48,7 @@ "10", "11" ] - }, + } ], "requirements": [ { From a45cc59820ed68c4a1cac575e37477d3e7237ba9 Mon Sep 17 00:00:00 2001 From: Yorick Poels Date: Tue, 26 Nov 2024 15:38:58 +0100 Subject: [PATCH 11/11] Test GitHub ci workflow --- .github/workflows/ci.yaml | 88 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..795fac7 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,88 @@ +name: CI + +on: + push: + branches: + - main + - master + pull_request: + + +jobs: + unit: + runs-on: ubuntu-latest + continue-on-error: ${{ matrix.allow_failure }} + strategy: + fail-fast: false + matrix: + include: + - ruby: 2.7.7 + puppet: 7 + fixtures: .fixtures.yml + allow_failure: false + - ruby: 3.2.2 + puppet: 8 + fixtures: .fixtures.yml + allow_failure: false + env: + BUNDLE_WITHOUT: system_tests:release + PUPPET_GEM_VERSION: "~> ${{ matrix.puppet }}.0" + FIXTURES_YML: ${{ matrix.fixtures }} + name: Puppet ${{ matrix.puppet }} (Ruby ${{ matrix.ruby }}) + steps: + - uses: actions/checkout@v3 + - name: Setup ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + cache-version: 2 + bundler: '2.1.0' + - name: Validate + run: bundle exec rake check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint + - name: Run tests + run: bundle exec rake parallel_spec + acceptance: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + set: + - "el8" + - "el9" + - "debian-11" + - "ubuntu-2004" + - "ubuntu-2204" + puppet: + - "puppet7" + - "puppet8" + env: + BUNDLE_WITHOUT: development:release + BEAKER_debug: true + name: ${{ matrix.puppet }} ${{ matrix.set }} + steps: + - name: Enable IPv6 on docker + run: | + echo '{"ipv6":true,"fixed-cidr-v6":"2001:db8:1::/64"}' | sudo tee /etc/docker/daemon.json + sudo service docker restart + # https://github.com/actions/virtual-environments/issues/181#issuecomment-610874237 + - name: apparmor + run: | + set -x + sudo apt-get remove mysql-server --purge + sudo apt-get update + sudo apt-get install apparmor-profiles + sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld + - uses: actions/checkout@v3 + - name: Setup ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '2.7' + bundler-cache: true + cache-version: 2 + bundler: '2.1.0' + - name: Run tests + run: bundle exec rake beaker + env: + BEAKER_PUPPET_COLLECTION: ${{ matrix.puppet }} + BEAKER_set: ${{ matrix.set }}