From 83b2fd20fe6c446cf11f32745b9bf02be3e8e8d2 Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Tue, 24 Sep 2024 10:18:55 +0200 Subject: [PATCH 01/22] pdk update --- .gitignore | 13 +- .pdkignore | 29 +- .puppet-lint.rc | 1 + .rubocop.yml | 632 +++++++++++++++++++++++++++++++++++++++- .vscode/extensions.json | 6 + Gemfile | 52 ++-- Rakefile | 76 +---- metadata.json | 6 +- pdk.yaml | 2 + spec/default_facts.yml | 10 +- spec/spec_helper.rb | 35 ++- 11 files changed, 744 insertions(+), 118 deletions(-) create mode 100644 .puppet-lint.rc create mode 100644 .vscode/extensions.json create mode 100644 pdk.yaml diff --git a/.gitignore b/.gitignore index 650022e..2803e56 100644 --- a/.gitignore +++ b/.gitignore @@ -16,9 +16,20 @@ /log/ /pkg/ /spec/fixtures/manifests/ -/spec/fixtures/modules/ +/spec/fixtures/modules/* /tmp/ /vendor/ +/.vendor/ /convert_report.txt /update_report.txt .DS_Store +.project +.envrc +/inventory.yaml +/spec/fixtures/litmus_inventory.yaml +.resource_types +.modules +.task_cache.json +.plan_cache.json +.rerun.json +bolt-debug.log diff --git a/.pdkignore b/.pdkignore index 650022e..84684be 100644 --- a/.pdkignore +++ b/.pdkignore @@ -16,9 +16,36 @@ /log/ /pkg/ /spec/fixtures/manifests/ -/spec/fixtures/modules/ +/spec/fixtures/modules/* /tmp/ /vendor/ +/.vendor/ /convert_report.txt /update_report.txt .DS_Store +.project +.envrc +/inventory.yaml +/spec/fixtures/litmus_inventory.yaml +.resource_types +.modules +.task_cache.json +.plan_cache.json +.rerun.json +bolt-debug.log +/.fixtures.yml +/Gemfile +/.gitattributes +/.github/ +/.gitignore +/.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/.rubocop.yml b/.rubocop.yml index f5a6c2a..21b82b9 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,10 +1,13 @@ --- -require: rubocop-rspec +require: +- rubocop-performance +- rubocop-rspec AllCops: + NewCops: enable DisplayCopNames: true - TargetRubyVersion: '2.1' + TargetRubyVersion: '2.6' Include: - - "./**/*.rb" + - "**/*.rb" Exclude: - bin/* - ".vendor/**/*" @@ -16,13 +19,9 @@ AllCops: - "**/Puppetfile" - "**/Vagrantfile" - "**/Guardfile" -Metrics/LineLength: +Layout/LineLength: Description: People have wide screens, use them. Max: 200 -GetText/DecorateString: - Description: We don't want to decorate test output. - Exclude: - - spec/* RSpec/BeforeAfterAll: Description: Beware of using after(:all) as it may cause state to leak between tests. A necessary evil in acceptance testing. @@ -31,6 +30,9 @@ RSpec/BeforeAfterAll: RSpec/HookArgument: Description: Prefer explicit :each argument, matching existing module's style EnforcedStyle: each +RSpec/DescribeSymbol: + Exclude: + - spec/unit/facter/**/*.rb Style/BlockDelimiters: Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to be consistent then. @@ -63,7 +65,7 @@ Style/TrailingCommaInArguments: Description: Prefer always trailing comma on multiline argument lists. This makes diffs, and re-ordering nicer. EnforcedStyleForMultiline: comma -Style/TrailingCommaInLiteral: +Style/TrailingCommaInArrayLiteral: Description: Prefer always trailing comma on multiline literals. This makes diffs, and re-ordering nicer. EnforcedStyleForMultiline: comma @@ -78,20 +80,176 @@ Style/Documentation: - spec/**/* Style/WordArray: EnforcedStyle: brackets +Performance/AncestorsInclude: + Enabled: true +Performance/BigDecimalWithNumericArgument: + Enabled: true +Performance/BlockGivenWithExplicitBlock: + Enabled: true +Performance/CaseWhenSplat: + Enabled: true +Performance/ConstantRegexp: + Enabled: true +Performance/MethodObjectAsBlock: + Enabled: true +Performance/RedundantSortBlock: + Enabled: true +Performance/RedundantStringChars: + Enabled: true +Performance/ReverseFirst: + Enabled: true +Performance/SortReverse: + Enabled: true +Performance/Squeeze: + Enabled: true +Performance/StringInclude: + Enabled: true +Performance/Sum: + Enabled: true Style/CollectionMethods: Enabled: true Style/MethodCalledOnDoEndBlock: Enabled: true Style/StringMethods: Enabled: true +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/IndentHeredoc: +Layout/FirstArgumentIndentation: + Enabled: false +Layout/HashAlignment: + Enabled: false +Layout/HeredocIndentation: + Enabled: false +Layout/LeadingEmptyLines: + Enabled: false +Layout/SpaceAroundMethodCallOperator: + Enabled: false +Layout/SpaceInsideArrayLiteralBrackets: + Enabled: false +Layout/SpaceInsideReferenceBrackets: + Enabled: false +Lint/BigDecimalNew: + Enabled: false +Lint/BooleanSymbol: + Enabled: false +Lint/ConstantDefinitionInBlock: + Enabled: false +Lint/DeprecatedOpenSSLConstant: + Enabled: false +Lint/DisjunctiveAssignmentInConstructor: + Enabled: false +Lint/DuplicateElsifCondition: + Enabled: false +Lint/DuplicateRequire: + Enabled: false +Lint/DuplicateRescueException: + Enabled: false +Lint/EmptyConditionalBody: + Enabled: false +Lint/EmptyFile: + Enabled: false +Lint/ErbNewArguments: + Enabled: false +Lint/FloatComparison: + Enabled: false +Lint/HashCompareByIdentity: + Enabled: false +Lint/IdentityComparison: + Enabled: false +Lint/InterpolationCheck: + Enabled: false +Lint/MissingCopEnableDirective: + Enabled: false +Lint/MixedRegexpCaptureTypes: + Enabled: false +Lint/NestedPercentLiteral: + Enabled: false +Lint/NonDeterministicRequireOrder: + Enabled: false +Lint/OrderedMagicComments: + Enabled: false +Lint/OutOfRangeRegexpRef: + Enabled: false +Lint/RaiseException: + Enabled: false +Lint/RedundantCopEnableDirective: + Enabled: false +Lint/RedundantRequireStatement: + Enabled: false +Lint/RedundantSafeNavigation: + Enabled: false +Lint/RedundantWithIndex: + Enabled: false +Lint/RedundantWithObject: + Enabled: false +Lint/RegexpAsCondition: + Enabled: false +Lint/ReturnInVoidContext: + Enabled: false +Lint/SafeNavigationConsistency: + Enabled: false +Lint/SafeNavigationWithEmpty: + Enabled: false +Lint/SelfAssignment: + Enabled: false +Lint/SendWithMixinArgument: + Enabled: false +Lint/ShadowedArgument: + Enabled: false +Lint/StructNewOverride: + Enabled: false +Lint/ToJSON: + Enabled: false +Lint/TopLevelReturnWithArgument: + Enabled: false +Lint/TrailingCommaInAttributeDeclaration: + Enabled: false +Lint/UnreachableLoop: + Enabled: false +Lint/UriEscapeUnescape: + Enabled: false +Lint/UriRegexp: + Enabled: false +Lint/UselessMethodDefinition: + Enabled: false +Lint/UselessTimes: Enabled: false Metrics/AbcSize: Enabled: false Metrics/BlockLength: Enabled: false +Metrics/BlockNesting: + Enabled: false Metrics/ClassLength: Enabled: false Metrics/CyclomaticComplexity: @@ -104,19 +262,469 @@ Metrics/ParameterLists: Enabled: false Metrics/PerceivedComplexity: Enabled: false +Migration/DepartmentName: + Enabled: false +Naming/AccessorMethodName: + Enabled: false +Naming/BlockParameterName: + Enabled: false +Naming/HeredocDelimiterCase: + Enabled: false +Naming/HeredocDelimiterNaming: + Enabled: false +Naming/MemoizedInstanceVariableName: + Enabled: false +Naming/MethodParameterName: + Enabled: false +Naming/RescuedExceptionsVariableName: + Enabled: false +Naming/VariableNumber: + Enabled: false +Performance/BindCall: + Enabled: false +Performance/DeletePrefix: + Enabled: false +Performance/DeleteSuffix: + Enabled: false +Performance/InefficientHashSearch: + Enabled: false +Performance/UnfreezeString: + Enabled: false +Performance/UriDefaultParser: + Enabled: false +RSpec/Be: + Enabled: false +RSpec/Capybara/FeatureMethods: + Enabled: false +RSpec/ContainExactly: + Enabled: false +RSpec/ContextMethod: + Enabled: false +RSpec/ContextWording: + Enabled: false RSpec/DescribeClass: Enabled: false +RSpec/EmptyHook: + Enabled: false +RSpec/EmptyLineAfterExample: + Enabled: false +RSpec/EmptyLineAfterExampleGroup: + Enabled: false +RSpec/EmptyLineAfterHook: + Enabled: false RSpec/ExampleLength: Enabled: false -RSpec/MessageExpectation: +RSpec/ExampleWithoutDescription: + Enabled: false +RSpec/ExpectChange: + Enabled: false +RSpec/ExpectInHook: + Enabled: false +RSpec/FactoryBot/AttributeDefinedStatically: + Enabled: false +RSpec/FactoryBot/CreateList: + Enabled: false +RSpec/FactoryBot/FactoryClassName: + Enabled: false +RSpec/HooksBeforeExamples: + Enabled: false +RSpec/ImplicitBlockExpectation: + Enabled: false +RSpec/ImplicitSubject: + Enabled: false +RSpec/LeakyConstantDeclaration: + Enabled: false +RSpec/LetBeforeExamples: + Enabled: false +RSpec/MatchArray: + Enabled: false +RSpec/MissingExampleGroupArgument: Enabled: false RSpec/MultipleExpectations: Enabled: false +RSpec/MultipleMemoizedHelpers: + Enabled: false +RSpec/MultipleSubjects: + Enabled: false RSpec/NestedGroups: Enabled: false -Style/AsciiComments: +RSpec/PredicateMatcher: + Enabled: false +RSpec/ReceiveCounts: + Enabled: false +RSpec/ReceiveNever: + Enabled: false +RSpec/RepeatedExampleGroupBody: + Enabled: false +RSpec/RepeatedExampleGroupDescription: + Enabled: false +RSpec/RepeatedIncludeExample: + Enabled: false +RSpec/ReturnFromStub: + Enabled: false +RSpec/SharedExamples: + Enabled: false +RSpec/StubbedMock: + Enabled: false +RSpec/UnspecifiedException: + Enabled: false +RSpec/VariableDefinition: + Enabled: false +RSpec/VoidExpect: + Enabled: false +RSpec/Yield: + Enabled: false +Security/Open: + Enabled: false +Style/AccessModifierDeclarations: + Enabled: false +Style/AccessorGrouping: + Enabled: false +Style/BisectedAttrAccessor: + Enabled: false +Style/CaseLikeIf: + Enabled: false +Style/ClassEqualityComparison: + Enabled: false +Style/ColonMethodDefinition: + Enabled: false +Style/CombinableLoops: + Enabled: false +Style/CommentedKeyword: + Enabled: false +Style/Dir: + Enabled: false +Style/DoubleCopDisableDirective: + Enabled: false +Style/EmptyBlockParameter: + Enabled: false +Style/EmptyLambdaParameter: + Enabled: false +Style/Encoding: + Enabled: false +Style/EvalWithLocation: + Enabled: false +Style/ExpandPathArguments: + Enabled: false +Style/ExplicitBlockArgument: + Enabled: false +Style/ExponentialNotation: + Enabled: false +Style/FloatDivision: + Enabled: false +Style/FrozenStringLiteralComment: + Enabled: false +Style/GlobalStdStream: + Enabled: false +Style/HashAsLastArrayItem: + Enabled: false +Style/HashLikeCase: + Enabled: false +Style/HashTransformKeys: + Enabled: false +Style/HashTransformValues: Enabled: false Style/IfUnlessModifier: Enabled: false +Style/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/.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/Gemfile b/Gemfile index 626d661..8e9f845 100644 --- a/Gemfile +++ b/Gemfile @@ -13,19 +13,37 @@ def location_for(place_or_version, fake_version = nil) end end -ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments -minor_version = ruby_version_segments[0..1].join('.') - group :development do - gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') - gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') - gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') - gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') - gem "json", '<= 2.0.4', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.4.4') - gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby] - gem "puppet-module-posix-dev-r#{minor_version}", require: false, platforms: [:ruby] - gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-win-dev-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.5.1', require: false if Gem::Requirement.create(['>= 3.0.0', '< 3.0.5']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.6.1', require: false if Gem::Requirement.create(['>= 3.1.0', '< 3.1.3']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.6.3', require: false if Gem::Requirement.create(['>= 3.2.0', '< 4.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "racc", '~> 1.4.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "deep_merge", '~> 1.2.2', require: false + gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false + gem "facterdb", '~> 2.1', require: false + gem "metadata-json-lint", '~> 4.0', require: false + gem "rspec-puppet-facts", '~> 4.0', require: false + gem "dependency_checker", '~> 1.0.0', require: false + gem "parallel_tests", '= 3.12.1', require: false + gem "pry", '~> 0.10', require: false + gem "simplecov-console", '~> 0.9', require: false + gem "puppet-debugger", '~> 1.0', require: false + gem "rubocop", '~> 1.50.0', require: false + gem "rubocop-performance", '= 1.16.0', require: false + gem "rubocop-rspec", '= 2.19.0', require: false + gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "rexml", '>= 3.0.0', '< 3.2.7', require: false +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'] @@ -42,16 +60,6 @@ gems['puppet'] = location_for(puppet_version) gems['facter'] = location_for(facter_version) if facter_version gems['hiera'] = location_for(hiera_version) if hiera_version -if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)} - # If we're using a Puppet gem on Windows which handles its own win32-xxx gem - # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445). - gems['win32-dir'] = ['<= 0.4.9', require: false] - gems['win32-eventlog'] = ['<= 0.6.5', require: false] - gems['win32-process'] = ['<= 0.7.5', require: false] - gems['win32-security'] = ['<= 0.2.5', require: false] - gems['win32-service'] = ['0.8.8', require: false] -end - gems.each do |gem_name, gem_params| gem gem_name, *gem_params end diff --git a/Rakefile b/Rakefile index a6b14c5..caa4e30 100644 --- a/Rakefile +++ b/Rakefile @@ -1,76 +1,10 @@ +# frozen_string_literal: true + +require 'bundler' +require 'puppet_litmus/rake_tasks' if Gem.loaded_specs.key? 'puppet_litmus' require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-syntax/tasks/puppet-syntax' -require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? -require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any? -require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any? - -def changelog_user - return unless Rake.application.top_level_tasks.include? "changelog" - returnVal = nil || JSON.load(File.read('metadata.json'))['author'] - raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil? - puts "GitHubChangelogGenerator user:#{returnVal}" - returnVal -end - -def changelog_project - return unless Rake.application.top_level_tasks.include? "changelog" - returnVal = nil || JSON.load(File.read('metadata.json'))['name'] - raise "unable to find the changelog_project in .sync.yml or the name in metadata.json" if returnVal.nil? - puts "GitHubChangelogGenerator project:#{returnVal}" - returnVal -end - -def changelog_future_release - return unless Rake.application.top_level_tasks.include? "changelog" - returnVal = JSON.load(File.read('metadata.json'))['version'] - raise "unable to find the future_release (version) in metadata.json" if returnVal.nil? - puts "GitHubChangelogGenerator future_release:#{returnVal}" - returnVal -end +require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings' PuppetLint.configuration.send('disable_relative') -if Bundler.rubygems.find_name('github_changelog_generator').any? - GitHubChangelogGenerator::RakeTask.new :changelog do |config| - raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil? - config.user = "#{changelog_user}" - config.project = "#{changelog_project}" - config.future_release = "#{changelog_future_release}" - config.exclude_labels = ['maintenance'] - config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)." - config.add_pr_wo_labels = true - config.issues = false - config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM" - config.configure_sections = { - "Changed" => { - "prefix" => "### Changed", - "labels" => ["backwards-incompatible"], - }, - "Added" => { - "prefix" => "### Added", - "labels" => ["feature", "enhancement"], - }, - "Fixed" => { - "prefix" => "### Fixed", - "labels" => ["bugfix"], - }, - } - end -else - desc 'Generate a Changelog from GitHub' - task :changelog do - raise <= Gem::Version.new('2.2.2')" -EOM - end -end - diff --git a/metadata.json b/metadata.json index 698bb54..6245f52 100644 --- a/metadata.json +++ b/metadata.json @@ -66,7 +66,7 @@ } ], "description": "This module provides the Puppi libraries required by Example42 modules and, if explicitly included, the puppi command, its working environment, the defines and procedures to deploy applications", - "pdk-version": "1.8.0", - "template-url": "file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git", - "template-ref": "1.8.0-0-g0d9da00" + "pdk-version": "3.3.0", + "template-url": "pdk-default#3.3.0", + "template-ref": "tags/3.3.0-0-g5d17ec1" } diff --git a/pdk.yaml b/pdk.yaml new file mode 100644 index 0000000..4bef4bd --- /dev/null +++ b/pdk.yaml @@ -0,0 +1,2 @@ +--- +ignore: [] diff --git a/spec/default_facts.yml b/spec/default_facts.yml index 62876a3..3346c39 100644 --- a/spec/default_facts.yml +++ b/spec/default_facts.yml @@ -2,10 +2,8 @@ # # Facts specified here will override the values provided by rspec-puppet-facts. --- -ipaddress: "172.16.254.254" +networking: + ip: "172.16.254.254" + ip6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" + mac: "AA:AA:AA:AA:AA:AA" is_pe: false -macaddress: "AA:AA:AA:AA:AA:AA" -operatingsystem: "RedHat" -architecture: "x86_64" -kernel: "Linux" -osfamily: "RedHat" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 35654b3..ae7c1f6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,9 @@ +# frozen_string_literal: true + +RSpec.configure do |c| + c.mock_with :rspec +end + require 'puppetlabs_spec_helper/module_spec_helper' require 'rspec-puppet-facts' @@ -19,21 +25,46 @@ next unless File.exist?(f) && File.readable?(f) && File.size?(f) begin - default_facts.merge!(YAML.safe_load(File.read(f))) - rescue => e + 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) From 179b67ac866361a6ce1b6416195d43a2fae50aca Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Tue, 24 Sep 2024 11:37:22 +0200 Subject: [PATCH 02/22] lint fixes and params validation --- .puppet-lint.rc | 1 + manifests/check.pp | 15 ++- manifests/configure.pp | 16 ++- manifests/dependencies.pp | 2 - manifests/deploy.pp | 16 ++- manifests/extras.pp | 51 ++++---- manifests/helper.pp | 7 +- manifests/helpers.pp | 2 - manifests/info.pp | 11 +- manifests/info/instance.pp | 33 +++-- manifests/info/module.pp | 37 +++--- manifests/info/readme.pp | 49 ++++---- manifests/init.pp | 16 ++- manifests/initialize.pp | 15 ++- manifests/install_packages.pp | 17 ++- manifests/log.pp | 9 +- manifests/mcollective/client.pp | 10 +- manifests/mcollective/server.pp | 6 +- manifests/netinstall.pp | 32 +++-- manifests/one.pp | 6 +- manifests/params.pp | 32 +++-- manifests/project.pp | 33 +++-- manifests/project/archive.pp | 123 ++++++++++--------- manifests/project/builder.pp | 74 ++++++------ manifests/project/dir.pp | 109 ++++++++--------- manifests/project/files.pp | 205 ++++++++++++++++---------------- manifests/project/git.pp | 100 ++++++++-------- manifests/project/hg.pp | 98 ++++++++------- manifests/project/maven.pp | 121 +++++++++---------- manifests/project/mysql.pp | 111 +++++++++-------- manifests/project/service.pp | 61 +++++----- manifests/project/svn.pp | 108 +++++++++-------- manifests/project/tar.pp | 153 ++++++++++++------------ manifests/project/war.pp | 154 ++++++++++++------------ manifests/project/y4maven.pp | 194 +++++++++++++++--------------- manifests/project/yum.pp | 95 +++++++-------- manifests/report.pp | 15 ++- manifests/rollback.pp | 15 ++- manifests/run.pp | 7 +- manifests/runscript.pp | 34 +++--- manifests/skel.pp | 5 +- manifests/todo.pp | 13 +- manifests/two.pp | 2 - manifests/ze.pp | 11 +- 44 files changed, 1058 insertions(+), 1166 deletions(-) mode change 100644 => 100755 manifests/project/git.pp diff --git a/.puppet-lint.rc b/.puppet-lint.rc index cc96ece..8d66c08 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1 +1,2 @@ --relative +--ignore-lint-parameter_documentation \ No newline at end of file diff --git a/manifests/check.pp b/manifests/check.pp index f652d09..5ae3661 100644 --- a/manifests/check.pp +++ b/manifests/check.pp @@ -13,13 +13,13 @@ # :include:../README.check # define puppi::check ( - $command, - $base_dir = '', - $hostwide = 'no', - $priority = '50', - $project = 'default', - $enable = true ) { - + String $command, + String $base_dir = '', + String $hostwide = 'no', + Variant[String,Integer] $priority = '50', + String $project = 'default', + Boolean $enable = true, +) { require puppi require puppi::params @@ -46,5 +46,4 @@ content => "${real_base_dir}/${command}\n", tag => 'puppi_check', } - } diff --git a/manifests/configure.pp b/manifests/configure.pp index c827fd7..fd95f6c 100644 --- a/manifests/configure.pp +++ b/manifests/configure.pp @@ -14,13 +14,13 @@ # :include:../README.deploy # define puppi::configure ( - $command, - $project, - $arguments = '', - $priority = '50', - $user = 'root', - $enable = true ) { - + String $command, + String $project, + String $arguments = '', + Variant[String,Integer] $priority = '50', + String $user = 'root', + Boolean $enable = true, +) { require puppi require puppi::params @@ -35,6 +35,4 @@ content => "su - ${user} -c \"export project=${project} && ${puppi::params::scriptsdir}/${command} ${arguments}\"\n", tag => 'puppi_deploy', } - } - diff --git a/manifests/dependencies.pp b/manifests/dependencies.pp index 828b86d..af9cd27 100644 --- a/manifests/dependencies.pp +++ b/manifests/dependencies.pp @@ -8,7 +8,6 @@ # install_dependencies => false # class puppi::dependencies { - require puppi::params if ! defined(Package['curl']) { @@ -34,5 +33,4 @@ if ! defined(Package[$puppi::params::package_mail]) { package { $puppi::params::package_mail : ensure => present } } - } diff --git a/manifests/deploy.pp b/manifests/deploy.pp index b2633cc..9e43f50 100644 --- a/manifests/deploy.pp +++ b/manifests/deploy.pp @@ -14,13 +14,13 @@ # :include:../README.deploy # define puppi::deploy ( - $command, - $project, - $arguments = '', - $priority = '50', - $user = 'root', - $enable = true ) { - + String $command, + String $project, + String $arguments = '', + Variant[String,Integer] $priority = '50', + String $user = 'root', + Boolean $enable = true, +) { require puppi require puppi::params @@ -35,6 +35,4 @@ content => "su - ${user} -c \"export project=${project} && ${puppi::params::scriptsdir}/${command} ${arguments}\"\n", tag => 'puppi_deploy', } - } - diff --git a/manifests/extras.pp b/manifests/extras.pp index 61ac735..d8d1469 100644 --- a/manifests/extras.pp +++ b/manifests/extras.pp @@ -7,7 +7,6 @@ # extra_class=> 'example42::puppi::extras', # class puppi::extras { - # Default Checks puppi::check { 'NTP_Sync': @@ -52,11 +51,10 @@ hostwide => 'yes' , } - # Info Pages - $network_run = $::os['name'] ? { - 'Solaris' => [ 'ifconfig -a' , 'netstat -nr' , 'cat /etc/resolv.conf' , 'arp -an' , 'netstat -na' ], - default => [ 'ifconfig' , 'route -n' , 'cat /etc/resolv.conf' , 'arp -an' , 'netstat -natup | grep LISTEN' ], + $network_run = $facts['os']['name'] ? { + 'Solaris' => ['ifconfig -a' , 'netstat -nr' , 'cat /etc/resolv.conf' , 'arp -an' , 'netstat -na'], + default => ['ifconfig' , 'route -n' , 'cat /etc/resolv.conf' , 'arp -an' , 'netstat -natup | grep LISTEN'], } puppi::info { 'network': @@ -64,9 +62,9 @@ run => $network_run, } - $users_run = $::os['name'] ? { - 'Solaris' => [ 'who' , 'last' ], - default => [ 'who' , 'last' , 'LANG=C lastlog | grep -v \'Never logged in\'' ], + $users_run = $facts['os']['name'] ? { + 'Solaris' => ['who' , 'last'], + default => ['who' , 'last' , 'LANG=C lastlog | grep -v \'Never logged in\''], } puppi::info { 'users': @@ -74,9 +72,9 @@ run => $users_run, } - $perf_run = $::os['name'] ? { - 'Solaris' => [ 'uptime' , 'vmstat 1 5' ], - default => [ 'uptime' , 'free' , 'vmstat 1 5' ], + $perf_run = $facts['os']['name'] ? { + 'Solaris' => ['uptime' , 'vmstat 1 5'], + default => ['uptime' , 'free' , 'vmstat 1 5'], } puppi::info { 'perf': @@ -84,9 +82,9 @@ run => $perf_run, } - $disks_run = $::os['name'] ? { - 'Solaris' => [ 'df -h' , 'mount' ], - default => [ 'df -h' , 'mount' , 'blkid' , 'fdisk -l' ], + $disks_run = $facts['os']['name'] ? { + 'Solaris' => ['df -h' , 'mount'], + default => ['df -h' , 'mount' , 'blkid' , 'fdisk -l'], } puppi::info { 'disks': @@ -94,9 +92,9 @@ run => $disks_run, } - $hardware_run = $::os['name'] ? { - 'Solaris' => [ 'find /devices/' ], - default => [ 'lspci' , 'cat /proc/cpuinfo' ], + $hardware_run = $facts['os']['name'] ? { + 'Solaris' => ['find /devices/'], + default => ['lspci' , 'cat /proc/cpuinfo'], } puppi::info { 'hardware': @@ -104,12 +102,12 @@ run => $hardware_run, } - $packages_run = $::os['name'] ? { - /(?i:RedHat|CentOS|Scientific|Amazon|Linux)/ => [ 'yum repolist' , 'rpm -qa' ] , - /(?i:Debian|Ubuntu|Mint)/ => [ 'apt-config dump' , 'apt-cache stats' , 'apt-key list' , 'dpkg -l' ], - /(Solaris)/ => [ 'pkginfo' ], - /(Archlinux)/ => [ 'pacman -Qet' ], - default => [ 'echo' ], + $packages_run = $facts['os']['name'] ? { + /(?i:RedHat|CentOS|Scientific|Amazon|Linux)/ => ['yum repolist' , 'rpm -qa'], + /(?i:Debian|Ubuntu|Mint)/ => ['apt-config dump' , 'apt-cache stats' , 'apt-key list' , 'dpkg -l'], + /(Solaris)/ => ['pkginfo'], + /(Archlinux)/ => ['pacman -Qet'], + default => ['echo'], } puppi::info { 'packages': @@ -128,8 +126,7 @@ } ### Default Logs - case $::os['family'] { - + case $facts['os']['family'] { 'Debian': { puppi::log { 'system': description => 'General System Messages', @@ -201,8 +198,6 @@ } } - default: { } - + default: {} } - } diff --git a/manifests/helper.pp b/manifests/helper.pp index d87c198..fd43328 100644 --- a/manifests/helper.pp +++ b/manifests/helper.pp @@ -11,9 +11,9 @@ # } # define puppi::helper ( - $template, - $ensure = 'present' ) { - + String $template, + String $ensure = 'present', +) { require puppi require puppi::params @@ -25,5 +25,4 @@ group => $puppi::params::configfile_group, content => template($template), } - } diff --git a/manifests/helpers.pp b/manifests/helpers.pp index b8cd2f4..393c247 100644 --- a/manifests/helpers.pp +++ b/manifests/helpers.pp @@ -7,10 +7,8 @@ # Automatically included by Puppi # class puppi::helpers { - # Standard helper for Example42 modules puppi::helper { 'standard': template => 'puppi/helpers/standard.yml.erb', } - } diff --git a/manifests/info.pp b/manifests/info.pp index 7ae750d..d7116b7 100644 --- a/manifests/info.pp +++ b/manifests/info.pp @@ -18,10 +18,10 @@ # :include:../README.info # define puppi::info ( - $description = '', - $templatefile = 'puppi/info.erb', - $run = '' ) { - + String $description = '', + String $templatefile = 'puppi/info.erb', + String $run = '', +) { require puppi require puppi::params @@ -34,7 +34,7 @@ } file { "${puppi::params::infodir}/${name}": - ensure => present, + ensure => file, mode => '0750', owner => $puppi::params::configfile_owner, group => $puppi::params::configfile_group, @@ -42,5 +42,4 @@ content => template($templatefile), tag => 'puppi_info', } - } diff --git a/manifests/info/instance.pp b/manifests/info/instance.pp index 9d9d992..24fed9c 100644 --- a/manifests/info/instance.pp +++ b/manifests/info/instance.pp @@ -3,31 +3,30 @@ # This is a puppi info plugin specific for the tomcat::instance define # define puppi::info::instance ( - $servicename = '', - $processname = '', - $configdir = '', - $bindir = '', - $pidfile = '', - $datadir = '', - $logdir = '', - $httpport = '', - $controlport = '', - $ajpport = '', - $description = '', - $run = '', - $verbose = 'no', - $templatefile = 'puppi/info/instance.erb' ) { - + String $servicename = '', + String $processname = '', + String $configdir = '', + String $bindir = '', + String $pidfile = '', + String $datadir = '', + String $logdir = '', + Variant[String,Integer] $httpport = '', + Variant[String,Integer] $controlport = '', + Variant[String,Integer] $ajpport = '', + String $description = '', + String $run = '', + String $verbose = 'no', + String $templatefile = 'puppi/info/instance.erb', +) { require puppi require puppi::params file { "${puppi::params::infodir}/${name}": - ensure => present, + ensure => file, mode => '0750', owner => $puppi::params::configfile_owner, group => $puppi::params::configfile_group, content => template($templatefile), tag => 'puppi_info', } - } diff --git a/manifests/info/module.pp b/manifests/info/module.pp index df6f3c6..89376b4 100644 --- a/manifests/info/module.pp +++ b/manifests/info/module.pp @@ -26,28 +26,28 @@ # } # define puppi::info::module ( - $packagename = '', - $servicename = '', - $processname = '', - $configfile = '', - $configdir = '', - $initconfigfile = '', - $pidfile = '', - $datadir = '', - $logfile = '', - $logdir = '', - $protocol = '', - $port = '', - $description = '', - $run = '', - $verbose = 'no', - $templatefile = 'puppi/info/module.erb' ) { - + String $packagename = '', + String $servicename = '', + String $processname = '', + String $configfile = '', + String $configdir = '', + String $initconfigfile = '', + String $pidfile = '', + String $datadir = '', + String $logfile = '', + String $logdir = '', + String $protocol = '', + Variant[String,Integer] $port = '', + String $description = '', + String $run = '', + String $verbose = 'no', + String $templatefile = 'puppi/info/module.erb', +) { require puppi require puppi::params file { "${puppi::params::infodir}/${name}": - ensure => present, + ensure => file, mode => '0750', owner => $puppi::params::configfile_owner, group => $puppi::params::configfile_group, @@ -55,5 +55,4 @@ content => template($templatefile), tag => 'puppi_info', } - } diff --git a/manifests/info/readme.pp b/manifests/info/readme.pp index 5cf9950..1a72288 100644 --- a/manifests/info/readme.pp +++ b/manifests/info/readme.pp @@ -10,20 +10,20 @@ # } # define puppi::info::readme ( - $description = '', - $readme = '', - $autoreadme = 'no', - $run = '', - $source_module = 'undefined', - $templatefile = 'puppi/info/readme.erb' ) { - + String $description = '', + String $readme = '', + Variant[String,Boolean] $autoreadme = 'no', + String $run = '', + String $source_module = 'undefined', + String $templatefile = 'puppi/info/readme.erb', +) { require puppi require puppi::params $bool_autoreadme = any2bool($autoreadme) file { "${puppi::params::infodir}/${name}": - ensure => present, + ensure => file, mode => '0750', owner => $puppi::params::configfile_owner, group => $puppi::params::configfile_group, @@ -38,7 +38,7 @@ } file { "${puppi::params::readmedir}/${name}": - ensure => present, + ensure => file, mode => '0644', owner => $puppi::params::configfile_owner, group => $puppi::params::configfile_group, @@ -48,22 +48,21 @@ } if $bool_autoreadme == true { - file { "${puppi::params::readmedir}/${name}-custom": - ensure => present, - mode => '0644', - owner => $puppi::params::configfile_owner, - group => $puppi::params::configfile_group, - require => File['puppi_readmedir'], - source => [ - "puppet:///modules/${source_module}/puppi/info/readme/readme-${::hostname}" , - "puppet:///modules/${source_module}/puppi/info/readme/readme-${::role}" , - "puppet:///modules/${source_module}/puppi/info/readme/readme-default" , - "puppet:///modules/puppi/info/readme/readme-${::hostname}" , - "puppet:///modules/puppi/info/readme/readme-${::role}" , - 'puppet:///modules/puppi/info/readme/readme-default' - ], - tag => 'puppi_info', + file { "${puppi::params::readmedir}/${name}-custom": + ensure => file, + mode => '0644', + owner => $puppi::params::configfile_owner, + group => $puppi::params::configfile_group, + require => File['puppi_readmedir'], + source => [ + "puppet:///modules/${source_module}/puppi/info/readme/readme-${facts['networking']['hostname']}" , + "puppet:///modules/${source_module}/puppi/info/readme/readme-${facts['role']}" , + "puppet:///modules/${source_module}/puppi/info/readme/readme-default" , + "puppet:///modules/puppi/info/readme/readme-${facts['networking']['hostname']}" , + "puppet:///modules/puppi/info/readme/readme-${facts['role']}" , + 'puppet:///modules/puppi/info/readme/readme-default', + ], + tag => 'puppi_info', } } - } diff --git a/manifests/init.pp b/manifests/init.pp index cebceec..8132246 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -34,14 +34,13 @@ # puppi info, check and log # class puppi ( - $version = params_lookup( 'version' ), - $install_dependencies = params_lookup( 'install_dependencies' ), - $template = params_lookup( 'template' ), - $helpers_class = params_lookup( 'helpers_class' ), - $logs_retention_days = params_lookup( 'logs_retention_days' ), - $extra_class = params_lookup( 'extra_class' ) - ) inherits puppi::params { - + String $version = params_lookup( 'version' ), + Variant[String,Boolean] $install_dependencies = params_lookup( 'install_dependencies' ), + String $template = params_lookup( 'template' ), + String $helpers_class = params_lookup( 'helpers_class' ), + String $logs_retention_days = params_lookup( 'logs_retention_days' ), + String $extra_class = params_lookup( 'extra_class' ), +) inherits puppi::params { $bool_install_dependencies=any2bool($install_dependencies) # Manage Version @@ -73,5 +72,4 @@ if $bool_install_dependencies { include puppi::dependencies } - } diff --git a/manifests/initialize.pp b/manifests/initialize.pp index 0fe66af..9fbd5c7 100644 --- a/manifests/initialize.pp +++ b/manifests/initialize.pp @@ -12,13 +12,13 @@ # } # define puppi::initialize ( - $command, - $project, - $arguments = '', - $priority = '50', - $user = 'root', - $enable = true ) { - + String $command, + String $project, + String $arguments = '', + Variant[String,Integer] $priority = '50', + String $user = 'root', + Boolean $enable = true, +) { require puppi require puppi::params @@ -33,5 +33,4 @@ content => "su - ${user} -c \"export project=${project} && ${puppi::params::scriptsdir}/${command} ${arguments}\"\n", tag => 'puppi_initialize', } - } diff --git a/manifests/install_packages.pp b/manifests/install_packages.pp index d9c9618..3ce8a94 100644 --- a/manifests/install_packages.pp +++ b/manifests/install_packages.pp @@ -45,14 +45,14 @@ # } # define puppi::install_packages ( - $packages, - $template = 'puppi/install_packages.erb', - $scripts_dir = '/root/puppi_install_packages', - $autorun = true, - $refreshonly = true, - $timeout = '600', - $ensure = 'present' ) { - + String $packages, + String $template = 'puppi/install_packages.erb', + Srring $scripts_dir = '/root/puppi_install_packages', + Boolean $autorun = true, + Boolean $refreshonly = true, + Variant[String,Integer] $timeout = '600', + String $ensure = 'present', +) { if ! defined(File[$scripts_dir]) { file { $scripts_dir: ensure => directory, @@ -79,5 +79,4 @@ timeout => $timeout, } } - } diff --git a/manifests/log.pp b/manifests/log.pp index 8cfe08a..b50feb6 100644 --- a/manifests/log.pp +++ b/manifests/log.pp @@ -12,9 +12,9 @@ # :include:../README.log # define puppi::log ( - $log, - $description = '' ) { - + Variant[String,Array] $log, + String $description = '', +) { require puppi require puppi::params @@ -24,7 +24,7 @@ } file { "${puppi::params::logsdir}/${name}": - ensure => 'present', + ensure => 'file', mode => '0644', owner => $puppi::params::configfile_owner, group => $puppi::params::configfile_group, @@ -32,5 +32,4 @@ content => template('puppi/log.erb'), tag => 'puppi_log', } - } diff --git a/manifests/mcollective/client.pp b/manifests/mcollective/client.pp index 24f2f63..3862975 100644 --- a/manifests/mcollective/client.pp +++ b/manifests/mcollective/client.pp @@ -18,19 +18,18 @@ # :include:../README.mcollective # class puppi::mcollective::client { - require puppi::params require puppi::mcollective::server # OLD STYLE mc-puppi command file { '/usr/local/bin/mc-puppi': - ensure => 'present', + ensure => 'file', mode => '0755', owner => 'root', group => 'root', source => 'puppet:///modules/puppi/mcollective/mc-puppi', require => Class['mcollective'], - } + } # mco application TODO # file { "${puppi::params::mcollective}/application/puppi.rb": @@ -42,7 +41,7 @@ # } file { '/usr/bin/puppicheck': - ensure => 'present', + ensure => 'file', mode => '0750', owner => $puppi::params::mcollective_user, group => $puppi::params::mcollective_group, @@ -50,11 +49,10 @@ } file { '/usr/bin/puppideploy': - ensure => 'present', + ensure => 'file', mode => '0750', owner => $puppi::params::mcollective_user, group => $puppi::params::mcollective_group, source => 'puppet:///modules/puppi/mcollective/puppideploy', } - } diff --git a/manifests/mcollective/server.pp b/manifests/mcollective/server.pp index 40def16..ecf5cd7 100644 --- a/manifests/mcollective/server.pp +++ b/manifests/mcollective/server.pp @@ -10,11 +10,10 @@ # :include:../README.mcollective # class puppi::mcollective::server { - require puppi::params file { "${puppi::params::mcollective}/agent/puppi.ddl": - ensure => 'present', + ensure => 'file', mode => '0644', owner => 'root', group => 'root', @@ -23,12 +22,11 @@ } file { "${puppi::params::mcollective}/agent/puppi.rb": - ensure => 'present', + ensure => 'file', mode => '0644', owner => 'root', group => 'root', source => 'puppet:///modules/puppi/mcollective/puppi.rb', require => Class['mcollective'], } - } diff --git a/manifests/netinstall.pp b/manifests/netinstall.pp index 9f101fe..9df9e6b 100644 --- a/manifests/netinstall.pp +++ b/manifests/netinstall.pp @@ -60,23 +60,22 @@ # An optional custom command to run after having extracted the file. # define puppi::netinstall ( - $url, - $destination_dir, - $extracted_dir = '', - $retrieve_command = 'wget', - $retrieve_args = '', - $owner = 'root', - $group = 'root', + String $url, + String $destination_dir, + String $extracted_dir = '', + String $retrieve_command = 'wget', + String $retrieve_args = '', + String $owner = 'root', + String $group = 'root', $timeout = '3600', - $work_dir = '/var/tmp', - $path = '/bin:/sbin:/usr/bin:/usr/sbin', - $extract_command = '', - $preextract_command = '', - $postextract_command = '', - $postextract_cwd = '', - $exec_env = [] - ) { - + String $work_dir = '/var/tmp', + String $path = '/bin:/sbin:/usr/bin:/usr/sbin', + String $extract_command = '', + String $preextract_command = '', + String $postextract_command = '', + String $postextract_cwd = '', + Array $exec_env = [], +) { $source_filename = url_parse($url,'filename') $source_filetype = url_parse($url,'filetype') $source_dirname = url_parse($url,'filedir') @@ -166,4 +165,3 @@ } } } - diff --git a/manifests/one.pp b/manifests/one.pp index 47574bc..b5f803d 100644 --- a/manifests/one.pp +++ b/manifests/one.pp @@ -3,12 +3,11 @@ # Installs Puppi 1.0 # class puppi::one { - require puppi::params # Main configuration file file { 'puppi.conf': - ensure => present, + ensure => file, path => "${puppi::params::basedir}/puppi.conf", mode => '0644', owner => $puppi::params::configfile_owner, @@ -19,7 +18,7 @@ # The Puppi 1.0 command file { 'puppi': - ensure => present, + ensure => file, path => '/usr/sbin/puppi.one', mode => '0750', owner => $puppi::params::configfile_owner, @@ -27,5 +26,4 @@ content => template('puppi/puppi.erb'), require => File['puppi_basedir'], } - } diff --git a/manifests/params.pp b/manifests/params.pp index f719572..35349d0 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -2,8 +2,7 @@ # # Sets internal variables and defaults for puppi module # -class puppi::params { - +class puppi::params { ## PARAMETERS $version = '1' $install_dependencies = true @@ -12,7 +11,6 @@ $logs_retention_days = '30' $extra_class = 'puppi::extras' - ## INTERNALVARS $basedir = '/etc/puppi' $scriptsdir = '/etc/puppi/scripts' @@ -35,21 +33,21 @@ # External tools # Directory where are placed the checks scripts # By default we use Nagios plugins - $checkpluginsdir = $::os['name'] ? { - /(?i:RedHat|CentOS|Scientific|Amazon|Linux)/ => $::os['architecture'] ? { - x86_64 => '/usr/lib64/nagios/plugins', + $checkpluginsdir = $facts['os']['name'] ? { + /(?i:RedHat|CentOS|Scientific|Amazon|Linux)/ => $facts['os']['architecture'] ? { + 'x86_64' => '/usr/lib64/nagios/plugins', default => '/usr/lib/nagios/plugins', }, default => '/usr/lib/nagios/plugins', } - $package_nagiosplugins = $::os['name'] ? { + $package_nagiosplugins = $facts['os']['name'] ? { /(?i:RedHat|CentOS|Scientific|Amazon|Linux|Fedora)/ => 'nagios-plugins-all', /(?i:Debian|Ubuntu|Mint)/ => 'monitoring-plugins', default => 'nagios-plugins', } - $package_mail = $::os['name'] ? { + $package_mail = $facts['os']['name'] ? { /(?i:Debian|Ubuntu|Mint)/ => 'bsd-mailx', default => 'mailx', } @@ -59,31 +57,29 @@ # Mcollective paths # TODO: Add Paths for Puppet Enterprise: # /opt/puppet/libexec/mcollective/mcollective/ - $mcollective = $::os['name'] ? { - debian => '/usr/share/mcollective/plugins/mcollective', - ubuntu => '/usr/share/mcollective/plugins/mcollective', - centos => '/usr/libexec/mcollective/mcollective', - redhat => '/usr/libexec/mcollective/mcollective', + $mcollective = $facts['os']['name'] ? { + 'debian' => '/usr/share/mcollective/plugins/mcollective', + 'ubuntu' => '/usr/share/mcollective/plugins/mcollective', + 'centos' => '/usr/libexec/mcollective/mcollective', + 'redhat' => '/usr/libexec/mcollective/mcollective', default => '/usr/libexec/mcollective/mcollective', } $mcollective_user = 'root' $mcollective_group = 'root' - # Commands used in puppi info templates - $info_package_query = $::os['name'] ? { + $info_package_query = $facts['os']['name'] ? { /(?i:RedHat|CentOS|Scientific|Amazon|Linux)/ => 'rpm -qi', /(?i:Ubuntu|Debian|Mint)/ => 'dpkg -s', default => 'echo', } - $info_package_list = $::os['name'] ? { + $info_package_list = $facts['os']['name'] ? { /(?i:RedHat|CentOS|Scientific|Amazon|Linux)/ => 'rpm -ql', /(?i:Ubuntu|Debian|Mint)/ => 'dpkg -L', default => 'echo', } - $info_service_check = $::os['name'] ? { + $info_service_check = $facts['os']['name'] ? { default => '/etc/init.d/', } - } diff --git a/manifests/project.pp b/manifests/project.pp index 287ce7c..11fd869 100644 --- a/manifests/project.pp +++ b/manifests/project.pp @@ -5,22 +5,22 @@ # to to build up the commands list # define puppi::project ( - $deploy_root = undef, - $source = undef, - $user = 'root', - $predeploy_customcommand = '', - $postdeploy_customcommand = '', - $init_script = '', - $disable_services = '', - $firewall_src_ip = '', - $firewall_dst_port = 0, - $report_email = '', - $files_prefix = undef, - $source_baseurl = undef, - $document_root = '', - $config_root = undef, - $enable = true ) { - + Optional[String] $deploy_root = undef, + Optional[String] $source = undef, + String $user = 'root', + String $predeploy_customcommand = '', + String $postdeploy_customcommand = '', + String $init_script = '', + String $disable_services = '', + String $firewall_src_ip = '', + Variant[Integer,String] $firewall_dst_port = 0, + String $report_email = '', + Optional[String] $files_prefix = undef, + Optional[String] $source_baseurl = undef, + String $document_root = '', + Optional[String] $config_root = undef, + Boolean $enable = true, +) { require puppi::params $ensure = any2bool($enable) ? { @@ -110,5 +110,4 @@ group => $puppi::params::configfile_group, require => File["${puppi::params::projectsdir}/${name}"]; } - } diff --git a/manifests/project/archive.pp b/manifests/project/archive.pp index 2924362..73f7346 100644 --- a/manifests/project/archive.pp +++ b/manifests/project/archive.pp @@ -103,29 +103,29 @@ # Puppet runs. Default: 'false' # define puppi::project::archive ( - $source, - $deploy_root, - $user = 'root', - $predeploy_customcommand = '', - $predeploy_user = '', - $predeploy_priority = '39', - $postdeploy_customcommand = '', - $postdeploy_user = '', - $postdeploy_priority = '41', - $disable_services = '', - $firewall_src_ip = '', - $firewall_dst_port = '0', - $firewall_delay = '1', - $report_email = '', - $clean_deploy = false, - $backup_enable = true, - $backup_rsync_options = '--exclude .snapshot', - $backup_retention = '5', - $run_checks = true, - $always_deploy = true, - $auto_deploy = false, - $enable = true ) { - + String $source, + String $deploy_root, + String $user = 'root', + String $predeploy_customcommand = '', + String $predeploy_user = '', + String $predeploy_priority = '39', + String $postdeploy_customcommand = '', + String $postdeploy_user = '', + Variant[String,Integer] $postdeploy_priority = '41', + String $disable_services = '', + String $firewall_src_ip = '', + Variant[String,Integer] $firewall_dst_port = '0', + Variant[String,Integer] $firewall_delay = '1', + String $report_email = '', + Boolean $clean_deploy = false, + Boolean $backup_enable = true, + String $backup_rsync_options = '--exclude .snapshot', + Variant[String,Integer] $backup_retention = '5', + Boolean $run_checks = true, + Boolean $always_deploy = true, + Boolean $auto_deploy = false, + Boolean $enable = true, +) { require puppi require puppi::params @@ -145,7 +145,6 @@ true => 'yes', } - $bool_run_checks = any2bool($run_checks) $bool_clean_deploy = any2bool($clean_deploy) $bool_backup_enable = any2bool($backup_enable) @@ -162,18 +161,18 @@ } ### CREATE PROJECT - puppi::project { $name: - source => $source, - deploy_root => $deploy_root, - user => $user, - predeploy_customcommand => $predeploy_customcommand, - postdeploy_customcommand => $postdeploy_customcommand, - disable_services => $disable_services, - firewall_src_ip => $firewall_src_ip, - firewall_dst_port => $firewall_dst_port, - report_email => $report_email, - enable => $enable , - } + puppi::project { $name: + source => $source, + deploy_root => $deploy_root, + user => $user, + predeploy_customcommand => $predeploy_customcommand, + postdeploy_customcommand => $postdeploy_customcommand, + disable_services => $disable_services, + firewall_src_ip => $firewall_src_ip, + firewall_dst_port => $firewall_dst_port, + report_email => $report_email, + enable => $enable , + } ### DEPLOY SEQUENCE if ($bool_run_checks == true) { @@ -187,23 +186,23 @@ } } - # Here source file is retrieved - puppi::deploy { "${name}-Retrieve_Archive": - priority => '20' , - command => 'get_file.sh' , - arguments => "-s ${source} -t ${real_source_type} -a ${real_always_deploy}" , - user => 'root' , - project => $name , - enable => $enable , - } + # Here source file is retrieved + puppi::deploy { "${name}-Retrieve_Archive": + priority => '20' , + command => 'get_file.sh' , + arguments => "-s ${source} -t ${real_source_type} -a ${real_always_deploy}" , + user => 'root' , + project => $name , + enable => $enable , + } - puppi::deploy { "${name}-PreDeploy_Archive": - priority => '25' , - command => 'predeploy.sh' , - user => 'root' , - project => $name , - enable => $enable , - } + puppi::deploy { "${name}-PreDeploy_Archive": + priority => '25' , + command => 'predeploy.sh' , + user => 'root' , + project => $name , + enable => $enable , + } if ($firewall_src_ip != '') { puppi::deploy { "${name}-Load_Balancer_Block": @@ -249,15 +248,15 @@ } } - # Here is done the deploy on $deploy_root - puppi::deploy { "${name}-Deploy": - priority => '40' , - command => 'deploy_files.sh' , - arguments => "-d ${deploy_root} -c ${bool_clean_deploy}", - user => $user , - project => $name , - enable => $enable , - } + # Here is done the deploy on $deploy_root + puppi::deploy { "${name}-Deploy": + priority => '40' , + command => 'deploy_files.sh' , + arguments => "-d ${deploy_root} -c ${bool_clean_deploy}", + user => $user , + project => $name , + enable => $enable , + } if ($postdeploy_customcommand != '') { puppi::deploy { "${name}-Run_Custom_PostDeploy_Script": @@ -303,7 +302,6 @@ } } - ### ROLLBACK PROCEDURE if ($bool_backup_enable == true) { @@ -411,5 +409,4 @@ if ($bool_auto_deploy == true) { puppi::run { $name: } } - } diff --git a/manifests/project/builder.pp b/manifests/project/builder.pp index ffa207c..544b3a4 100644 --- a/manifests/project/builder.pp +++ b/manifests/project/builder.pp @@ -127,31 +127,31 @@ # Puppet runs. Default: 'false' # define puppi::project::builder ( - $source, - $source_type, - $deploy_root, - $init_source = '', - $user = 'root', - $magicfix = '', - $predeploy_customcommand = '', - $predeploy_user = '', - $predeploy_priority = '39', - $postdeploy_customcommand = '', - $postdeploy_user = '', - $postdeploy_priority = '41', - $disable_services = '', - $firewall_src_ip = '', - $firewall_dst_port = '0', - $firewall_delay = '1', - $report_email = '', - $backup = 'full', - $backup_rsync_options = '--exclude .snapshot', - $backup_retention = '5', - $run_checks = true, - $always_deploy = true, - $auto_deploy = false, - $enable = true ) { - + String $source, + String $source_type, + String $deploy_root, + String $init_source = '', + String $user = 'root', + String $magicfix = '', + String $predeploy_customcommand = '', + String $predeploy_user = '', + Variant[String,Integer] $predeploy_priority = '39', + String $postdeploy_customcommand = '', + String $postdeploy_user = '', + Variant[String,Integer] $postdeploy_priority = '41', + Variant[String,Boolean] $disable_services = '', + String $firewall_src_ip = '', + Variant[String,Integer] $firewall_dst_port = '0', + Variant[String,Integer] $firewall_delay = '1', + String $report_email = '', + String $backup = 'full', + String $backup_rsync_options = '--exclude .snapshot', + Variant[String,Integer] $backup_retention = '5', + Boolean $run_checks = true, + Boolean $always_deploy = true, + Boolean $auto_deploy = false, + Boolean $enable = true, +) { require puppi require puppi::params @@ -204,7 +204,6 @@ enable => $enable, } - ### INIT SEQUENCE if ($init_source != '') { puppi::initialize { "${name}-Deploy_Files": @@ -217,7 +216,6 @@ } } - ### DEPLOY SEQUENCE if ($bool_run_checks == true) { puppi::deploy { "${name}-Run_PRE-Checks": @@ -257,7 +255,6 @@ } if ($real_source_type == 'zip') { - puppi::deploy { "${name}-PreDeploy_Zip": priority => '25' , command => 'predeploy.sh' , @@ -364,15 +361,15 @@ } } - # Here is done the deploy on $deploy_root - puppi::deploy { "${name}-Deploy": - priority => '40' , - command => 'deploy.sh' , - arguments => $deploy_root , - user => $user , - project => $name , - enable => $enable , - } + # Here is done the deploy on $deploy_root + puppi::deploy { "${name}-Deploy": + priority => '40' , + command => 'deploy.sh' , + arguments => $deploy_root , + user => $user , + project => $name , + enable => $enable , + } if ($postdeploy_customcommand != '') { puppi::deploy { "${name}-Run_Custom_PostDeploy_Script": @@ -429,7 +426,6 @@ } } - ### ROLLBACK PROCEDURE if ($firewall_src_ip != '') { @@ -550,7 +546,6 @@ } } - ### REPORTING if ($report_email != '') { @@ -568,5 +563,4 @@ if ($bool_auto_deploy == true) { puppi::run { $name: } } - } diff --git a/manifests/project/dir.pp b/manifests/project/dir.pp index 4514b37..c23bc46 100644 --- a/manifests/project/dir.pp +++ b/manifests/project/dir.pp @@ -102,29 +102,29 @@ # Puppet runs. Default: 'false' # define puppi::project::dir ( - $source, - $deploy_root, - $init_source = '', - $user = 'root', - $predeploy_customcommand = '', - $predeploy_user = '', - $predeploy_priority = '39', - $postdeploy_customcommand = '', - $postdeploy_user = '', - $postdeploy_priority = '41', - $init_script = '', - $disable_services = '', - $firewall_src_ip = '', - $firewall_dst_port = '0', - $firewall_delay = '1', - $report_email = '', - $backup_rsync_options = '--exclude .snapshot', - $backup_retention = '5', - $run_checks = true, - $skip_predeploy = false, - $auto_deploy = false, - $enable = true ) { - + String $source, + String $deploy_root, + String $init_source = '', + String $user = 'root', + String $predeploy_customcommand = '', + String $predeploy_user = '', + Variant[String,Integer] $predeploy_priority = '39', + String $postdeploy_customcommand = '', + String $postdeploy_user = '', + Variant[String,Integer] $postdeploy_priority = '41', + String $init_script = '', + String $disable_services = '', + String $firewall_src_ip = '', + Variant[String,Integer] $firewall_dst_port = '0', + Variant[String,Integer] $firewall_delay = '1', + String $report_email = '', + String $backup_rsync_options = '--exclude .snapshot', + Variant[String,Integer] $backup_retention = '5', + Boolean $run_checks = true, + Boolean $skip_predeploy = false, + Boolean $auto_deploy = false, + Boolean $enable = true, +) { require puppi require puppi::params @@ -144,20 +144,19 @@ $bool_auto_deploy = any2bool($auto_deploy) ### CREATE PROJECT - puppi::project { $name: - source => $source, - deploy_root => $deploy_root, - user => $user, - predeploy_customcommand => $predeploy_customcommand, - postdeploy_customcommand => $postdeploy_customcommand, - init_script => $init_script, - disable_services => $disable_services, - firewall_src_ip => $firewall_src_ip, - firewall_dst_port => $firewall_dst_port, - report_email => $report_email, - enable => $enable, - } - + puppi::project { $name: + source => $source, + deploy_root => $deploy_root, + user => $user, + predeploy_customcommand => $predeploy_customcommand, + postdeploy_customcommand => $postdeploy_customcommand, + init_script => $init_script, + disable_services => $disable_services, + firewall_src_ip => $firewall_src_ip, + firewall_dst_port => $firewall_dst_port, + report_email => $report_email, + enable => $enable, + } ### INIT SEQUENCE if ($init_source != '') { @@ -171,7 +170,6 @@ } } - ### DEPLOY SEQUENCE if ($bool_run_checks == true) { puppi::deploy { "${name}-Run_PRE-Checks": @@ -206,14 +204,14 @@ } } - puppi::deploy { "${name}-Backup_existing_Files": - priority => '30' , - command => 'archive.sh' , - arguments => "-b ${deploy_root} -o '${backup_rsync_options}' -n ${backup_retention}" , - user => 'root' , - project => $name , - enable => $enable , - } + puppi::deploy { "${name}-Backup_existing_Files": + priority => '30' , + command => 'archive.sh' , + arguments => "-b ${deploy_root} -o '${backup_rsync_options}' -n ${backup_retention}" , + user => 'root' , + project => $name , + enable => $enable , + } if ($disable_services != '') { puppi::deploy { "${name}-Disable_extra_services": @@ -327,7 +325,6 @@ } } - ### ROLLBACK SEQUENCE if ($firewall_src_ip != '') { @@ -374,14 +371,14 @@ } } - puppi::rollback { "${name}-Recover_Files_To_Deploy": - priority => '40' , - command => 'archive.sh' , - arguments => "-r ${deploy_root} -o '${backup_rsync_options}'" , - user => $user , - project => $name , - enable => $enable , - } + puppi::rollback { "${name}-Recover_Files_To_Deploy": + priority => '40' , + command => 'archive.sh' , + arguments => "-r ${deploy_root} -o '${backup_rsync_options}'" , + user => $user , + project => $name , + enable => $enable , + } if ($postdeploy_customcommand != '') { puppi::rollback { "${name}-Run_Custom_PostDeploy_Script": @@ -438,7 +435,6 @@ } } - ### REPORTING if ($report_email != '') { @@ -456,5 +452,4 @@ if ($bool_auto_deploy == true) { puppi::run { $name: } } - } diff --git a/manifests/project/files.pp b/manifests/project/files.pp index 37c1005..52b017f 100644 --- a/manifests/project/files.pp +++ b/manifests/project/files.pp @@ -117,31 +117,31 @@ # Puppet runs. Default: 'false' # define puppi::project::files ( - $source, - $source_baseurl, - $deploy_root, - $init_source = '', - $files_prefix = '', - $prefix = '', - $user = 'root', - $predeploy_customcommand = '', - $predeploy_user = '', - $predeploy_priority = '39', - $postdeploy_customcommand = '', - $postdeploy_user = '', - $postdeploy_priority = '41', - $init_script = '', - $disable_services = '', - $firewall_src_ip = '', - $firewall_dst_port = '0', - $firewall_delay = '1', - $report_email = '', - $backup_rsync_options = '--exclude .snapshot', - $backup_retention = '5', - $run_checks = true, - $auto_deploy = false, - $enable = true ) { - + String $source, + String $source_baseurl, + String $deploy_root, + String $init_source = '', + String $files_prefix = '', + String $prefix = '', + String $user = 'root', + String $predeploy_customcommand = '', + String $predeploy_user = '', + Variant[String,Integer] $predeploy_priority = '39', + String $postdeploy_customcommand = '', + String $postdeploy_user = '', + Variant[String,Integer] $postdeploy_priority = '41', + String $init_script = '', + String $disable_services = '', + String $firewall_src_ip = '', + Variant[String,Integer] $firewall_dst_port = '0', + Variant[String,Integer] $firewall_delay = '1', + String $report_email = '', + String $backup_rsync_options = '--exclude .snapshot', + Variant[String,Integer] $backup_retention = '5', + Boolean $run_checks = true, + Boolean $auto_deploy = false, + Boolean $enable = true, +) { require puppi require puppi::params @@ -160,22 +160,21 @@ $bool_auto_deploy = any2bool($auto_deploy) ### CREATE PROJECT - puppi::project { $name: - source => $source, - deploy_root => $deploy_root, - user => $user, - predeploy_customcommand => $predeploy_customcommand, - postdeploy_customcommand => $postdeploy_customcommand, - init_script => $init_script, - disable_services => $disable_services, - firewall_src_ip => $firewall_src_ip, - firewall_dst_port => $firewall_dst_port, - report_email => $report_email, - enable => $enable , - files_prefix => $files_prefix, - source_baseurl => $source_baseurl, - } - + puppi::project { $name: + source => $source, + deploy_root => $deploy_root, + user => $user, + predeploy_customcommand => $predeploy_customcommand, + postdeploy_customcommand => $postdeploy_customcommand, + init_script => $init_script, + disable_services => $disable_services, + firewall_src_ip => $firewall_src_ip, + firewall_dst_port => $firewall_dst_port, + report_email => $report_email, + enable => $enable , + files_prefix => $files_prefix, + source_baseurl => $source_baseurl, + } ### INIT SEQUENCE if ($init_source != '') { @@ -189,7 +188,6 @@ } } - ### DEPLOY SEQUENCE if ($bool_run_checks == true) { puppi::deploy { "${name}-Run_PRE-Checks": @@ -202,46 +200,46 @@ } } - puppi::deploy { "${name}-Retrieve_File_List": - priority => '20' , - command => 'get_file.sh' , - arguments => "-s ${source} -t list" , - user => 'root' , - project => $name , - enable => $enable , - } + puppi::deploy { "${name}-Retrieve_File_List": + priority => '20' , + command => 'get_file.sh' , + arguments => "-s ${source} -t list" , + user => 'root' , + project => $name , + enable => $enable , + } - $args_prefix = $prefix ? { - '' => '', - default => "-m ${prefix}", - } + $args_prefix = $prefix ? { + '' => '', + default => "-m ${prefix}", + } - puppi::deploy { "${name}-Extract_File_Metadata": - priority => '22' , - command => 'get_metadata.sh' , - arguments => $args_prefix, - user => 'root' , - project => $name , - enable => $enable , - } + puppi::deploy { "${name}-Extract_File_Metadata": + priority => '22' , + command => 'get_metadata.sh' , + arguments => $args_prefix, + user => 'root' , + project => $name , + enable => $enable , + } - puppi::deploy { "${name}-Clean_File_List": - priority => '24' , - command => 'clean_filelist.sh' , - arguments => $files_prefix , - user => 'root' , - project => $name , - enable => $enable , - } + puppi::deploy { "${name}-Clean_File_List": + priority => '24' , + command => 'clean_filelist.sh' , + arguments => $files_prefix , + user => 'root' , + project => $name , + enable => $enable , + } - puppi::deploy { "${name}-Retrieve_Files": - priority => '25' , - command => 'get_filesfromlist.sh' , - arguments => $source_baseurl , - user => 'root' , - project => $name , - enable => $enable , - } + puppi::deploy { "${name}-Retrieve_Files": + priority => '25' , + command => 'get_filesfromlist.sh' , + arguments => $source_baseurl , + user => 'root' , + project => $name , + enable => $enable , + } if ($firewall_src_ip != '') { puppi::deploy { "${name}-Load_Balancer_Block": @@ -254,14 +252,14 @@ } } - puppi::deploy { "${name}-Backup_existing_Files": - priority => '30' , - command => 'archive.sh' , - arguments => "-b ${deploy_root} -o '${backup_rsync_options}' -n ${backup_retention}" , - user => 'root' , - project => $name , - enable => $enable , - } + puppi::deploy { "${name}-Backup_existing_Files": + priority => '30' , + command => 'archive.sh' , + arguments => "-b ${deploy_root} -o '${backup_rsync_options}' -n ${backup_retention}" , + user => 'root' , + project => $name , + enable => $enable , + } if ($disable_services != '') { puppi::deploy { "${name}-Disable_extra_services": @@ -297,14 +295,14 @@ } # Here is done the deploy on $deploy_root - puppi::deploy { "${name}-Deploy": - priority => '40' , - command => 'deploy.sh' , - arguments => $deploy_root , - user => $user , - project => $name , - enable => $enable , - } + puppi::deploy { "${name}-Deploy": + priority => '40' , + command => 'deploy.sh' , + arguments => $deploy_root , + user => $user , + project => $name , + enable => $enable , + } if ($postdeploy_customcommand != '') { puppi::deploy { "${name}-Run_Custom_PostDeploy_Script": @@ -361,7 +359,6 @@ } } - ### ROLLBACK SEQUENCE if ($firewall_src_ip != '') { @@ -408,14 +405,14 @@ } } - puppi::rollback { "${name}-Recover_Files_To_Deploy": - priority => '40' , - command => 'archive.sh' , - arguments => "-r ${deploy_root} -o '${backup_rsync_options}'" , - user => $user , - project => $name , - enable => $enable , - } + puppi::rollback { "${name}-Recover_Files_To_Deploy": + priority => '40' , + command => 'archive.sh' , + arguments => "-r ${deploy_root} -o '${backup_rsync_options}'" , + user => $user , + project => $name , + enable => $enable , + } if ($postdeploy_customcommand != '') { puppi::rollback { "${name}-Run_Custom_PostDeploy_Script": @@ -472,7 +469,6 @@ } } - ### REPORTING if ($report_email != '') { @@ -490,5 +486,4 @@ if ($bool_auto_deploy == true) { puppi::run { $name: } } - } diff --git a/manifests/project/git.pp b/manifests/project/git.pp old mode 100644 new mode 100755 index 041a3f9..17bb66b --- a/manifests/project/git.pp +++ b/manifests/project/git.pp @@ -126,33 +126,33 @@ # Puppet runs. Default: 'false' # define puppi::project::git ( - $source, - $deploy_root, - $install_git = true, - $git_subdir = 'undefined', - $tag = 'undefined', - $branch = 'master', - $commit = 'undefined', - $keep_gitdata = true, - $verbose = true, - $user = 'root', - $predeploy_customcommand = '', - $predeploy_user = '', - $predeploy_priority = '39', - $postdeploy_customcommand = '', - $postdeploy_user = '', - $postdeploy_priority = '41', - $disable_services = '', - $firewall_src_ip = '', - $firewall_dst_port = '0', - $firewall_delay = '1', - $report_email = '', - $backup_rsync_options = '--exclude .snapshot', - $backup_retention = '5', - $run_checks = true, - $auto_deploy = false, - $enable = true ) { - + String $source, + String $deploy_root, + Boolean $install_git = true, + String $git_subdir = 'undefined', + String $tag = 'undefined', + String $branch = 'master', + String $commit = 'undefined', + Boolean $keep_gitdata = true, + Boolean $verbose = true, + String $user = 'root', + String $predeploy_customcommand = '', + String $predeploy_user = '', + Variant[String,Integer] $predeploy_priority = '39', + String $postdeploy_customcommand = '', + String $postdeploy_user = '', + Variant[String,Integer] $postdeploy_priority = '41', + String $disable_services = '', + String $firewall_src_ip = '', + Variant[String,Integer] $firewall_dst_port = '0', + Variant[String,Integer] $firewall_delay = '1', + String $report_email = '', + String $backup_rsync_options = '--exclude .snapshot', + Variant[String,Integer] $backup_retention = '5', + Boolean $run_checks = true, + Boolean $auto_deploy = false, + Boolean $enable = true, +) { require puppi require puppi::params @@ -179,19 +179,18 @@ } ### CREATE PROJECT - puppi::project { $name: - enable => $enable , - source => $source, - deploy_root => $deploy_root, - user => $user, - predeploy_customcommand => $predeploy_customcommand, - postdeploy_customcommand => $postdeploy_customcommand, - disable_services => $disable_services, - firewall_src_ip => $firewall_src_ip, - firewall_dst_port => $firewall_dst_port, - report_email => $report_email, - } - + puppi::project { $name: + enable => $enable , + source => $source, + deploy_root => $deploy_root, + user => $user, + predeploy_customcommand => $predeploy_customcommand, + postdeploy_customcommand => $postdeploy_customcommand, + disable_services => $disable_services, + firewall_src_ip => $firewall_src_ip, + firewall_dst_port => $firewall_dst_port, + report_email => $report_email, + } ### DEPLOY SEQUENCE if ($bool_run_checks == true) { @@ -249,15 +248,15 @@ } } - # Here is done the deploy on $deploy_root - puppi::deploy { "${name}-Deploy_Files": - priority => '40' , - command => 'git.sh' , - arguments => "-a deploy -s ${source} -d ${deploy_root} -u ${user} -gs ${git_subdir} -t ${tag} -b ${branch} -c ${commit} -v ${bool_verbose} -k ${bool_keep_gitdata}" , - user => 'root' , - project => $name , - enable => $enable , - } + # Here is done the deploy on $deploy_root + puppi::deploy { "${name}-Deploy_Files": + priority => '40' , + command => 'git.sh' , + arguments => "-a deploy -s ${source} -d ${deploy_root} -u ${user} -gs ${git_subdir} -t ${tag} -b ${branch} -c ${commit} -v ${bool_verbose} -k ${bool_keep_gitdata}" , + user => 'root' , + project => $name , + enable => $enable , + } if ($postdeploy_customcommand != '') { puppi::deploy { "${name}-Run_Custom_PostDeploy_Script": @@ -303,7 +302,6 @@ } } - ### ROLLBACK PROCEDURE if ($firewall_src_ip != '') { @@ -405,7 +403,6 @@ } } - ### REPORTING if ($report_email != '') { @@ -423,5 +420,4 @@ if ($bool_auto_deploy == true) { puppi::run { $name: } } - } diff --git a/manifests/project/hg.pp b/manifests/project/hg.pp index d296024..7eac5af 100644 --- a/manifests/project/hg.pp +++ b/manifests/project/hg.pp @@ -121,32 +121,32 @@ # Puppet runs. Default: 'false' # define puppi::project::hg ( - $source, - $deploy_root, - $install_hg = true, - $tag = 'undefined', - $branch = 'default', - $commit = 'undefined', - $keep_hgdata = true, - $verbose = true, - $user = 'root', - $predeploy_customcommand = '', - $predeploy_user = '', - $predeploy_priority = '39', - $postdeploy_customcommand = '', - $postdeploy_user = '', - $postdeploy_priority = '41', - $disable_services = '', - $firewall_src_ip = '', - $firewall_dst_port = '0', - $firewall_delay = '1', - $report_email = '', - $backup_rsync_options = '--exclude .snapshot', - $backup_retention = '5', - $run_checks = true, - $auto_deploy = false, - $enable = true ) { - + String $source, + String $deploy_root, + Boolean $install_hg = true, + String $tag = 'undefined', + String $branch = 'default', + String $commit = 'undefined', + Boolean $keep_hgdata = true, + Boolean$verbose = true, + String $user = 'root', + String $predeploy_customcommand = '', + String $predeploy_user = '', + Variant[String,Integer] $predeploy_priority = '39', + String $postdeploy_customcommand = '', + String $postdeploy_user = '', + Variant[String,Integer] $postdeploy_priority = '41', + String $disable_services = '', + String $firewall_src_ip = '', + Variant[String,Integer] $firewall_dst_port = '0', + Variant[String,Integer] $firewall_delay = '1', + String $report_email = '', + String $backup_rsync_options = '--exclude .snapshot', + Variant[String,Integer] $backup_retention = '5', + Boolean $run_checks = true, + Boolean $auto_deploy = false, + Boolean $enable = true, +) { require puppi require puppi::params @@ -173,19 +173,18 @@ } ### CREATE PROJECT - puppi::project { $name: - source => $source, - deploy_root => $deploy_root, - user => $user, - predeploy_customcommand => $predeploy_customcommand, - postdeploy_customcommand => $postdeploy_customcommand, - disable_services => $disable_services, - firewall_src_ip => $firewall_src_ip, - firewall_dst_port => $firewall_dst_port, - report_email => $report_email, - enable => $enable , - } - + puppi::project { $name: + source => $source, + deploy_root => $deploy_root, + user => $user, + predeploy_customcommand => $predeploy_customcommand, + postdeploy_customcommand => $postdeploy_customcommand, + disable_services => $disable_services, + firewall_src_ip => $firewall_src_ip, + firewall_dst_port => $firewall_dst_port, + report_email => $report_email, + enable => $enable , + } ### DEPLOY SEQUENCE if ($bool_run_checks == true) { @@ -243,15 +242,15 @@ } } - # Here is done the deploy on $deploy_root - puppi::deploy { "${name}-Deploy_Files": - priority => '40' , - command => 'hg.sh' , - arguments => "-a deploy -s ${source} -d ${deploy_root} -u ${user} -t ${tag} -b ${branch} -c ${commit} -v ${bool_verbose} -k ${bool_keep_hgdata}" , - user => 'root' , - project => $name , - enable => $enable , - } + # Here is done the deploy on $deploy_root + puppi::deploy { "${name}-Deploy_Files": + priority => '40' , + command => 'hg.sh' , + arguments => "-a deploy -s ${source} -d ${deploy_root} -u ${user} -t ${tag} -b ${branch} -c ${commit} -v ${bool_verbose} -k ${bool_keep_hgdata}" , + user => 'root' , + project => $name , + enable => $enable , + } if ($postdeploy_customcommand != '') { puppi::deploy { "${name}-Run_Custom_PostDeploy_Script": @@ -297,7 +296,6 @@ } } - ### ROLLBACK PROCEDURE if ($firewall_src_ip != '') { @@ -399,7 +397,6 @@ } } - ### REPORTING if ($report_email != '') { @@ -417,5 +414,4 @@ if ($bool_auto_deploy == true) { puppi::run { $name: } } - } diff --git a/manifests/project/maven.pp b/manifests/project/maven.pp index 9dbe6ee..24a8a43 100644 --- a/manifests/project/maven.pp +++ b/manifests/project/maven.pp @@ -175,48 +175,48 @@ # Puppet runs. Default: 'false' # define puppi::project::maven ( - $source, - $http_user = '', - $http_password = '', - $artifact_type = 'release', - $deploy_root = '', - $user = 'root', - $war_suffix = 'suffixnotset', - $zip_root = '', - $zip_user = '', - $zip_suffix = 'suffixnotset', - $jar_root = '', - $jar_user = '', - $jar_suffix = 'suffixnotset', - $document_root = '', - $document_user = '', - $document_suffix = 'suffixnotset', - $document_init_source = '', - $config_root = '', - $config_user = '', - $config_suffix = 'suffixnotset', - $config_init_source = '', - $predeploy_customcommand = '', - $predeploy_user = '', - $predeploy_priority = '39', - $postdeploy_customcommand = '', - $postdeploy_user = '', - $postdeploy_priority = '41', - $init_script = '', - $disable_services = '', - $firewall_src_ip = '', - $firewall_dst_port = '0', - $firewall_delay = '1', - $report_email = '', - $report_mongo = '', - $backup_rsync_options = '--exclude .snapshot', - $backup_retention = '5', - $run_checks = true, - $always_deploy = true, - $check_deploy = true, - $auto_deploy = false, - $enable = true ) { - + String $source, + String $http_user = '', + String $http_password = '', + String $artifact_type = 'release', + String $deploy_root = '', + String $user = 'root', + String $war_suffix = 'suffixnotset', + String $zip_root = '', + String $zip_user = '', + String $zip_suffix = 'suffixnotset', + String $jar_root = '', + String $jar_user = '', + String $jar_suffix = 'suffixnotset', + String $document_root = '', + String $document_user = '', + String $document_suffix = 'suffixnotset', + String $document_init_source = '', + String $config_root = '', + String $config_user = '', + String $config_suffix = 'suffixnotset', + String $config_init_source = '', + String $predeploy_customcommand = '', + String $predeploy_user = '', + Variant[String,Integer] $predeploy_priority = '39', + String $postdeploy_customcommand = '', + String $postdeploy_user = '', + Variant[String,Integer] $postdeploy_priority = '41', + String $init_script = '', + String $disable_services = '', + String $firewall_src_ip = '', + Variant[String,Integer] $firewall_dst_port = '0', + Variant[String,Integer] $firewall_delay = '1', + String $report_email = '', + String $report_mongo = '', + String $backup_rsync_options = '--exclude .snapshot', + Variant[String,Integer] $backup_retention = '5', + Boolean $run_checks = true, + Boolean $always_deploy = true, + Boolean $check_deploy = true, + Boolean $auto_deploy = false, + Boolean $enable = true, +) { require puppi require puppi::params @@ -260,24 +260,22 @@ $bool_check_deploy = any2bool($check_deploy) $bool_auto_deploy = any2bool($auto_deploy) - ### CREATE PROJECT - puppi::project { $name: - source => $source, - deploy_root => $deploy_root, - user => $user, - predeploy_customcommand => $predeploy_customcommand, - postdeploy_customcommand => $postdeploy_customcommand, - init_script => $init_script, - disable_services => $disable_services, - firewall_src_ip => $firewall_src_ip, - firewall_dst_port => $firewall_dst_port, - report_email => $report_email, - enable => $enable, - document_root => $document_root, - config_root => $config_root, - } - + puppi::project { $name: + source => $source, + deploy_root => $deploy_root, + user => $user, + predeploy_customcommand => $predeploy_customcommand, + postdeploy_customcommand => $postdeploy_customcommand, + init_script => $init_script, + disable_services => $disable_services, + firewall_src_ip => $firewall_src_ip, + firewall_dst_port => $firewall_dst_port, + report_email => $report_email, + enable => $enable, + document_root => $document_root, + config_root => $config_root, + } ### INIT SEQUENCE if ($document_init_source != '') { @@ -396,7 +394,7 @@ puppi::deploy { "${name}-Get_Maven_Files_ZIP": priority => '25' , command => 'get_maven_files.sh' , - arguments => $real_arguments, + arguments => $real_arguments, user => 'root' , project => $name , enable => $enable , @@ -636,7 +634,6 @@ } } - ### ROLLBACK PROCEDURE if ($firewall_src_ip != '') { @@ -793,7 +790,6 @@ } } - ### REPORTING if ($report_email != '') { @@ -822,5 +818,4 @@ if ($bool_auto_deploy == true) { puppi::run { $name: } } - } diff --git a/manifests/project/mysql.pp b/manifests/project/mysql.pp index 8a3c493..9ad8853 100644 --- a/manifests/project/mysql.pp +++ b/manifests/project/mysql.pp @@ -100,30 +100,30 @@ # Puppet runs. Default: 'false' # define puppi::project::mysql ( - $source, - $mysql_database, - $mysql_user = 'root', - $mysql_host = 'localhost', - $mysql_password = '', - $init_source = '', - $predeploy_customcommand = '', - $predeploy_user = '', - $predeploy_priority = '39', - $postdeploy_customcommand = '', - $postdeploy_user = '', - $postdeploy_priority = '41', - $disable_services = '', - $firewall_src_ip = '', - $firewall_dst_port = '0', - $firewall_delay = '1', - $report_email = '', - $backup = true, - $backup_retention = '5', - $run_checks = true, - $always_deploy = true, - $auto_deploy = false, - $enable = true ) { - + String $source, + String $mysql_database, + String $mysql_user = 'root', + String $mysql_host = 'localhost', + String $mysql_password = '', + String $init_source = '', + String $predeploy_customcommand = '', + String $predeploy_user = '', + Variant[String,Integer] $predeploy_priority = '39', + String $postdeploy_customcommand = '', + String $postdeploy_user = '', + Variant[String,Integer] $postdeploy_priority = '41', + String $disable_services = '', + String $firewall_src_ip = '', + Variant[String,Integer] $firewall_dst_port = '0', + Variant[String,Integer] $firewall_delay = '1', + String $report_email = '', + Boolean $backup = true, + Variant[String,Integer] $backup_retention = '5', + Boolean $run_checks = true, + Boolean $always_deploy = true, + Boolean $auto_deploy = false, + Boolean $enable = true, +) { require puppi require puppi::params @@ -156,19 +156,18 @@ $source_filename = url_parse($source,'filename') ### CREATE PROJECT - puppi::project { $name: - source => $source, - deploy_root => $deploy_root, - user => $user, - predeploy_customcommand => $predeploy_customcommand, - postdeploy_customcommand => $postdeploy_customcommand, - disable_services => $disable_services, - firewall_src_ip => $firewall_src_ip, - firewall_dst_port => $firewall_dst_port, - report_email => $report_email, - enable => $enable, - } - + puppi::project { $name: + source => $source, + deploy_root => $deploy_root, + user => $user, + predeploy_customcommand => $predeploy_customcommand, + postdeploy_customcommand => $postdeploy_customcommand, + disable_services => $disable_services, + firewall_src_ip => $firewall_src_ip, + firewall_dst_port => $firewall_dst_port, + report_email => $report_email, + enable => $enable, + } ### INIT SEQUENCE if ($init_source != '') { @@ -190,7 +189,6 @@ } } - ### DEPLOY SEQUENCE if ($bool_run_checks == true) { puppi::deploy { "${name}-Run_PRE-Checks": @@ -203,14 +201,14 @@ } } - puppi::deploy { "${name}-Retrieve_SQLFile": - priority => '20' , - command => 'get_file.sh' , - arguments => "-s ${source} -t ${real_source_type} -a ${real_always_deploy}" , - user => 'root' , - project => $name , - enable => $enable , - } + puppi::deploy { "${name}-Retrieve_SQLFile": + priority => '20' , + command => 'get_file.sh' , + arguments => "-s ${source} -t ${real_source_type} -a ${real_always_deploy}" , + user => 'root' , + project => $name , + enable => $enable , + } if ($firewall_src_ip != '') { puppi::deploy { "${name}-Load_Balancer_Block": @@ -256,15 +254,15 @@ } } - # Here is done the db change - puppi::deploy { "${name}-Run_SQL": - priority => '40' , - command => 'database.sh' , - arguments => "-t mysql -a run -u ${mysql_user} -p '${mysql_password}' -d ${mysql_database} -h ${mysql_host}" , - user => 'root' , - project => $name , - enable => $enable , - } + # Here is done the db change + puppi::deploy { "${name}-Run_SQL": + priority => '40' , + command => 'database.sh' , + arguments => "-t mysql -a run -u ${mysql_user} -p '${mysql_password}' -d ${mysql_database} -h ${mysql_host}" , + user => 'root' , + project => $name , + enable => $enable , + } if ($postdeploy_customcommand != '') { puppi::deploy { "${name}-Run_Custom_PostDeploy_Script": @@ -310,7 +308,6 @@ } } - ### ROLLBACK PROCEDURE if ($firewall_src_ip != '') { @@ -412,7 +409,6 @@ } } - ### REPORTING if ($report_email != '') { @@ -430,5 +426,4 @@ if ($bool_auto_deploy == true) { puppi::run { $name: } } - } diff --git a/manifests/project/service.pp b/manifests/project/service.pp index 5131d1b..f9ed05a 100644 --- a/manifests/project/service.pp +++ b/manifests/project/service.pp @@ -76,23 +76,23 @@ # Puppet runs. Default: 'false' # define puppi::project::service ( - $user = 'root', - $predeploy_customcommand = '', - $predeploy_user = '', - $predeploy_priority = '39', - $postdeploy_customcommand = '', - $postdeploy_user = '', - $postdeploy_priority = '41', - $init_script = '', - $disable_services = '', - $firewall_src_ip = '', - $firewall_dst_port = '0', - $firewall_delay = '1', - $report_email = '', - $run_checks = true, - $auto_deploy = false, - $enable = true ) { - + String $user = 'root', + String $predeploy_customcommand = '', + String $predeploy_user = '', + Variant[String,Integer] $predeploy_priority = '39', + String $postdeploy_customcommand = '', + String $postdeploy_user = '', + Variant[String,Integer] $postdeploy_priority = '41', + String $init_script = '', + String $disable_services = '', + String $firewall_src_ip = '', + Variant[String,Integer] $firewall_dst_port = '0', + Variant[String,Integer] $firewall_delay = '1', + String $report_email = '', + Boolean $run_checks = true, + Boolean $auto_deploy = false, + Boolean $enable = true, +) { require puppi require puppi::params @@ -111,18 +111,17 @@ $bool_auto_deploy = any2bool($auto_deploy) ### CREATE PROJECT - puppi::project { $name: - user => $user, - predeploy_customcommand => $predeploy_customcommand, - postdeploy_customcommand => $postdeploy_customcommand, - init_script => $init_script, - disable_services => $disable_services, - firewall_src_ip => $firewall_src_ip, - firewall_dst_port => $firewall_dst_port, - report_email => $report_email, - enable => $enable, - } - + puppi::project { $name: + user => $user, + predeploy_customcommand => $predeploy_customcommand, + postdeploy_customcommand => $postdeploy_customcommand, + init_script => $init_script, + disable_services => $disable_services, + firewall_src_ip => $firewall_src_ip, + firewall_dst_port => $firewall_dst_port, + report_email => $report_email, + enable => $enable, + } ### DEPLOY SEQUENCE if ($bool_run_checks == true) { @@ -180,7 +179,6 @@ } } - if ($postdeploy_customcommand != '') { puppi::deploy { "${name}-Run_Custom_PostDeploy_Script": priority => $postdeploy_priority , @@ -236,7 +234,6 @@ } } - ### ROLLBACK PROCEDURE if ($firewall_src_ip != '') { @@ -338,7 +335,6 @@ } } - ### REPORTING if ($report_email != '') { @@ -356,5 +352,4 @@ if ($bool_auto_deploy == true) { puppi::run { $name: } } - } diff --git a/manifests/project/svn.pp b/manifests/project/svn.pp index 726796b..e275cd7 100644 --- a/manifests/project/svn.pp +++ b/manifests/project/svn.pp @@ -140,37 +140,37 @@ # Puppet runs. Default: 'false' # define puppi::project::svn ( - $source, - $deploy_root, - $install_svn = true, - $svn_user = 'undefined', - $svn_password = 'undefined', - $svn_subdir = 'undefined', - $svn_export = false, - $tag = 'undefined', - $branch = 'master', - $commit = 'undefined', - $keep_svndata = true, - $verbose = true, - $user = 'root', - $predeploy_customcommand = '', - $predeploy_user = '', - $predeploy_priority = '39', - $postdeploy_customcommand = '', - $postdeploy_user = '', - $postdeploy_priority = '41', - $disable_services = '', - $firewall_src_ip = '', - $firewall_dst_port = '0', - $firewall_delay = '1', - $report_email = '', - $backup_enable = true, - $backup_rsync_options = '--exclude .snapshot', - $backup_retention = '5', - $run_checks = true, - $auto_deploy = false, - $enable = true ) { - + String $source, + String $deploy_root, + Boolean $install_svn = true, + String $svn_user = 'undefined', + String $svn_password = 'undefined', + String $svn_subdir = 'undefined', + Boolean $svn_export = false, + String $tag = 'undefined', + String $branch = 'master', + String $commit = 'undefined', + Boolean $keep_svndata = true, + Boolean $verbose = true, + String $user = 'root', + String $predeploy_customcommand = '', + String $predeploy_user = '', + Variant[String,Integer] $predeploy_priority = '39', + String $postdeploy_customcommand = '', + String $postdeploy_user = '', + Variant[String,Integer] $postdeploy_priority = '41', + String $disable_services = '', + String $firewall_src_ip = '', + Variant[String,Integer] $firewall_dst_port = '0', + Variant[String,Integer] $firewall_delay = '1', + String $report_email = '', + Boolean $backup_enable = true, + String $backup_rsync_options = '--exclude .snapshot', + Variant[String,Integer] $backup_retention = '5', + Boolean $run_checks = true, + Boolean $auto_deploy = false, + Boolean $enable = true, +) { require puppi require puppi::params @@ -199,19 +199,18 @@ } ### CREATE PROJECT - puppi::project { $name: - source => $source, - deploy_root => $deploy_root, - user => $user, - predeploy_customcommand => $predeploy_customcommand, - postdeploy_customcommand => $postdeploy_customcommand, - disable_services => $disable_services, - firewall_src_ip => $firewall_src_ip, - firewall_dst_port => $firewall_dst_port, - report_email => $report_email, - enable => $enable, - } - + puppi::project { $name: + source => $source, + deploy_root => $deploy_root, + user => $user, + predeploy_customcommand => $predeploy_customcommand, + postdeploy_customcommand => $postdeploy_customcommand, + disable_services => $disable_services, + firewall_src_ip => $firewall_src_ip, + firewall_dst_port => $firewall_dst_port, + report_email => $report_email, + enable => $enable, + } ### DEPLOY SEQUENCE if ($bool_run_checks == true) { @@ -269,15 +268,15 @@ } } - # Here is done the deploy on $deploy_root - puppi::deploy { "${name}-Deploy_Files": - priority => '40' , - command => 'svn.sh' , - arguments => "-a deploy -s ${source} -d ${deploy_root} -u ${user} -gs ${svn_subdir} -su ${svn_user} -sp ${svn_password} -t ${tag} -b ${branch} -c ${commit} -v ${bool_verbose} -k ${bool_keep_svndata} -e ${bool_svn_export}" , - user => 'root' , - project => $name , - enable => $enable , - } + # Here is done the deploy on $deploy_root + puppi::deploy { "${name}-Deploy_Files": + priority => '40' , + command => 'svn.sh' , + arguments => "-a deploy -s ${source} -d ${deploy_root} -u ${user} -gs ${svn_subdir} -su ${svn_user} -sp ${svn_password} -t ${tag} -b ${branch} -c ${commit} -v ${bool_verbose} -k ${bool_keep_svndata} -e ${bool_svn_export}" , + user => 'root' , + project => $name , + enable => $enable , + } if ($postdeploy_customcommand != '') { puppi::deploy { "${name}-Run_Custom_PostDeploy_Script": @@ -323,11 +322,10 @@ } } - ### ROLLBACK PROCEDURE if ($bool_backup_enable == true) { - if ($firewall_src_ip != '') { + if ($firewall_src_ip != '') { puppi::rollback { "${name}-Load_Balancer_Block": priority => '25' , command => 'firewall.sh' , diff --git a/manifests/project/tar.pp b/manifests/project/tar.pp index 8fa0a57..1144cc5 100644 --- a/manifests/project/tar.pp +++ b/manifests/project/tar.pp @@ -113,32 +113,32 @@ # Puppet runs. Default: 'false' # define puppi::project::tar ( - $source, - $deploy_root, - $init_source = '', - $user = 'root', - $predeploy_customcommand = '', - $predeploy_user = '', - $predeploy_priority = '39', - $postdeploy_customcommand = '', - $postdeploy_user = '', - $postdeploy_priority = '41', - $init_script = '', - $disable_services = '', - $firewall_src_ip = '', - $firewall_dst_port = '0', - $firewall_delay = '1', - $report_email = '', - $clean_deploy = false, - $backup_enable = true, - $backup_rsync_options = '--exclude .snapshot', - $backup_retention = '5', - $run_checks = true, - $always_deploy = true, - $auto_deploy = false, - $verify_ssl = true, - $enable = true ) { - + String $source, + String $deploy_root, + String $init_source = '', + String $user = 'root', + String $predeploy_customcommand = '', + String $predeploy_user = '', + Variant[String,Integer] $predeploy_priority = '39', + String $postdeploy_customcommand = '', + String $postdeploy_user = '', + Variant[String,Integer] $postdeploy_priority = '41', + String $init_script = '', + String $disable_services = '', + String $firewall_src_ip = '', + Variant[String,Integer] $firewall_dst_port = '0', + Variant[String,Integer] $firewall_delay = '1', + String $report_email = '', + Boolean $clean_deploy = false, + Boolean $backup_enable = true, + String $backup_rsync_options = '--exclude .snapshot', + Variant[String,Integer] $backup_retention = '5', + Boolean $run_checks = true, + Boolean $always_deploy = true, + Boolean $auto_deploy = false, + Boolean $verify_ssl = true, + Boolean $enable = true, +) { require puppi require puppi::params @@ -170,26 +170,24 @@ if ($verify_ssl) { $ssl_arg = '' - }else{ + }else { $ssl_arg = '-k' } - ### CREATE PROJECT - puppi::project { $name: - source => $source, - deploy_root => $deploy_root, - user => $user, - predeploy_customcommand => $predeploy_customcommand, - postdeploy_customcommand => $postdeploy_customcommand, - init_script => $init_script, - disable_services => $disable_services, - firewall_src_ip => $firewall_src_ip, - firewall_dst_port => $firewall_dst_port, - report_email => $report_email, - enable => $enable, - } - + puppi::project { $name: + source => $source, + deploy_root => $deploy_root, + user => $user, + predeploy_customcommand => $predeploy_customcommand, + postdeploy_customcommand => $postdeploy_customcommand, + init_script => $init_script, + disable_services => $disable_services, + firewall_src_ip => $firewall_src_ip, + firewall_dst_port => $firewall_dst_port, + report_email => $report_email, + enable => $enable, + } ### INIT SEQUENCE if ($init_source != '') { @@ -203,7 +201,6 @@ } } - ### DEPLOY SEQUENCE if ($bool_run_checks == true) { puppi::deploy { "${name}-Run_PRE-Checks": @@ -216,24 +213,24 @@ } } - # Here source file is retrieved - puppi::deploy { "${name}-Retrieve_TarBall": - priority => '20' , - command => 'get_file.sh' , - arguments => "${ssl_arg} -s '${source}' -t tarball -a ${real_always_deploy}" , - user => 'root' , - project => $name , - enable => $enable , - } + # Here source file is retrieved + puppi::deploy { "${name}-Retrieve_TarBall": + priority => '20' , + command => 'get_file.sh' , + arguments => "${ssl_arg} -s '${source}' -t tarball -a ${real_always_deploy}" , + user => 'root' , + project => $name , + enable => $enable , + } - puppi::deploy { "${name}-PreDeploy_TarBall": - priority => '25' , - command => 'predeploy_tar.sh' , - arguments => 'downloadedfile' , - user => 'root' , - project => $name , - enable => $enable , - } + puppi::deploy { "${name}-PreDeploy_TarBall": + priority => '25' , + command => 'predeploy_tar.sh' , + arguments => 'downloadedfile' , + user => 'root' , + project => $name , + enable => $enable , + } if ($firewall_src_ip != '') { puppi::deploy { "${name}-Load_Balancer_Block": @@ -290,15 +287,15 @@ } } - # Here is done the deploy on $deploy_root - puppi::deploy { "${name}-Deploy": - priority => '40' , - command => 'deploy_files.sh' , - arguments => "-d ${deploy_root} -c ${bool_clean_deploy}", - user => $user , - project => $name , - enable => $enable , - } + # Here is done the deploy on $deploy_root + puppi::deploy { "${name}-Deploy": + priority => '40' , + command => 'deploy_files.sh' , + arguments => "-d ${deploy_root} -c ${bool_clean_deploy}", + user => $user , + project => $name , + enable => $enable , + } if ($postdeploy_customcommand != '') { puppi::deploy { "${name}-Run_Custom_PostDeploy_Script": @@ -355,7 +352,6 @@ } } - ### ROLLBACK PROCEDURE if ($bool_backup_enable == true) { @@ -403,14 +399,14 @@ } } - puppi::rollback { "${name}-Recover_Files_To_Deploy": - priority => '40' , - command => 'archive.sh' , - arguments => "-r ${deploy_root} -o '${backup_rsync_options}'" , - user => $user , - project => $name , - enable => $enable , - } + puppi::rollback { "${name}-Recover_Files_To_Deploy": + priority => '40' , + command => 'archive.sh' , + arguments => "-r ${deploy_root} -o '${backup_rsync_options}'" , + user => $user , + project => $name , + enable => $enable , + } if ($postdeploy_customcommand != '') { puppi::rollback { "${name}-Run_Custom_PostDeploy_Script": @@ -485,5 +481,4 @@ if ($bool_auto_deploy == true) { puppi::run { $name: } } - } diff --git a/manifests/project/war.pp b/manifests/project/war.pp index 8b7517b..0d5d109 100644 --- a/manifests/project/war.pp +++ b/manifests/project/war.pp @@ -115,32 +115,32 @@ # Puppet runs. Default: 'false' # define puppi::project::war ( - $source, - $deploy_root, - $init_source = '', - $user = 'root', - $predeploy_customcommand = '', - $predeploy_user = '', - $predeploy_priority = '39', - $postdeploy_customcommand = '', - $postdeploy_user = '', - $postdeploy_priority = '41', - $init_script = '', - $disable_services = '', - $firewall_src_ip = '', - $firewall_dst_port = '0', - $firewall_delay = '1', - $report_email = '', - $clean_deploy = false, - $backup_enable = true, - $backup_rsync_options = '--exclude .snapshot', - $backup_retention = '5', - $run_checks = true, - $always_deploy = true, - $check_deploy = true, - $auto_deploy = false, - $enable = true ) { - + String $source, + String $deploy_root, + String $init_source = '', + String $user = 'root', + String $predeploy_customcommand = '', + String $predeploy_user = '', + Variant[String,Integer] $predeploy_priority = '39', + String $postdeploy_customcommand = '', + String $postdeploy_user = '', + Variant[String,Integer] $postdeploy_priority = '41', + String $init_script = '', + String $disable_services = '', + String $firewall_src_ip = '', + Variant[String,Integer] $firewall_dst_port = '0', + Variant[String,Integer] $firewall_delay = '1', + String $report_email = '', + Boolean $clean_deploy = false, + Boolean $backup_enable = true, + String $backup_rsync_options = '--exclude .snapshot', + Variant[String,Integer] $backup_retention = '5', + Boolean $run_checks = true, + Boolean $always_deploy = true, + Boolean $check_deploy = true, + Boolean $auto_deploy = false, + Boolean $enable = true, +) { require puppi require puppi::params @@ -175,22 +175,20 @@ $war_file = url_parse($source,'filename') - ### CREATE PROJECT - puppi::project { $name: - source => $source, - deploy_root => $deploy_root, - user => $user, - predeploy_customcommand => $predeploy_customcommand, - postdeploy_customcommand => $postdeploy_customcommand, - init_script => $init_script, - disable_services => $disable_services, - firewall_src_ip => $firewall_src_ip, - firewall_dst_port => $firewall_dst_port, - report_email => $report_email, - enable => $enable, - } - + puppi::project { $name: + source => $source, + deploy_root => $deploy_root, + user => $user, + predeploy_customcommand => $predeploy_customcommand, + postdeploy_customcommand => $postdeploy_customcommand, + init_script => $init_script, + disable_services => $disable_services, + firewall_src_ip => $firewall_src_ip, + firewall_dst_port => $firewall_dst_port, + report_email => $report_email, + enable => $enable, + } ### INIT SEQUENCE if ($init_source != '') { @@ -204,7 +202,6 @@ } } - ### DEPLOY SEQUENCE if ($bool_run_checks == true) { puppi::deploy { "${name}-Run_PRE-Checks": @@ -217,15 +214,15 @@ } } - # Here source file is retrieved - puppi::deploy { "${name}-Retrieve_WAR": - priority => '20' , - command => 'get_file.sh' , - arguments => "-s '${source}' -a '${real_always_deploy}'" , - user => 'root' , - project => $name , - enable => $enable , - } + # Here source file is retrieved + puppi::deploy { "${name}-Retrieve_WAR": + priority => '20' , + command => 'get_file.sh' , + arguments => "-s '${source}' -a '${real_always_deploy}'" , + user => 'root' , + project => $name , + enable => $enable , + } if ($firewall_src_ip != '') { puppi::deploy { "${name}-Load_Balancer_Block": @@ -247,7 +244,7 @@ project => $name , enable => $enable , } -} + } if ($bool_check_deploy == true) { puppi::deploy { "${name}-Check_undeploy": @@ -293,15 +290,15 @@ } } - # Here is done the deploy on $deploy_root - puppi::deploy { "${name}-Deploy_WAR": - priority => '40' , - command => 'deploy_files.sh' , - arguments => "-d '${deploy_root}' -c '${bool_clean_deploy}'", - user => $user , - project => $name , - enable => $enable , - } + # Here is done the deploy on $deploy_root + puppi::deploy { "${name}-Deploy_WAR": + priority => '40' , + command => 'deploy_files.sh' , + arguments => "-d '${deploy_root}' -c '${bool_clean_deploy}'", + user => $user , + project => $name , + enable => $enable , + } if ($postdeploy_customcommand != '') { puppi::deploy { "${name}-Run_Custom_PostDeploy_Script": @@ -369,11 +366,9 @@ } } - ### ROLLBACK PROCEDURE if ($bool_backup_enable == true) { - if ($firewall_src_ip != '') { puppi::rollback { "${name}-Load_Balancer_Block": priority => '25' , @@ -385,14 +380,14 @@ } } - puppi::rollback { "${name}-Remove_existing_WAR": - priority => '30' , - command => 'delete.sh' , - arguments => "'${deploy_root}/${war_file}'" , - user => 'root' , - project => $name , - enable => $enable , - } + puppi::rollback { "${name}-Remove_existing_WAR": + priority => '30' , + command => 'delete.sh' , + arguments => "'${deploy_root}/${war_file}'" , + user => 'root' , + project => $name , + enable => $enable , + } if ($bool_check_deploy == true) { puppi::rollback { "${name}-Check_undeploy": @@ -438,14 +433,14 @@ } } - puppi::rollback { "${name}-Recover_Files_To_Deploy": - priority => '40' , - command => 'archive.sh' , - arguments => "-r '${deploy_root}' -t war -o '${backup_rsync_options}'" , - user => $user , - project => $name , - enable => $enable , - } + puppi::rollback { "${name}-Recover_Files_To_Deploy": + priority => '40' , + command => 'archive.sh' , + arguments => "-r '${deploy_root}' -t war -o '${backup_rsync_options}'" , + user => $user , + project => $name , + enable => $enable , + } if ($postdeploy_customcommand != '') { puppi::rollback { "${name}-Run_Custom_PostDeploy_Script": @@ -531,5 +526,4 @@ if ($bool_auto_deploy == true) { puppi::run { $name: } } - } diff --git a/manifests/project/y4maven.pp b/manifests/project/y4maven.pp index 403514d..0117eb5 100644 --- a/manifests/project/y4maven.pp +++ b/manifests/project/y4maven.pp @@ -164,45 +164,45 @@ # Puppet runs. Default: 'false' # define puppi::project::y4maven ( - $source, - $http_user = '', - $http_password = '', - $artifact_type = 'release', - $deploy_root = '', - $user = 'root', - $war_suffix = 'suffixnotset', - $zip_suffix = 'suffixnotset', - $jar_root = '', - $jar_user = '', - $jar_suffix = 'suffixnotset', - $document_root = '', - $document_user = '', - $document_suffix = 'suffixnotset', - $document_init_source = '', - $config_root = '', - $config_user = '', - $config_suffix = 'suffixnotset', - $config_init_source = '', - $predeploy_customcommand = '', - $predeploy_user = '', - $predeploy_priority = '39', - $postdeploy_customcommand = '', - $postdeploy_user = '', - $postdeploy_priority = '41', - $init_script = '', - $disable_services = '', - $firewall_src_ip = '', - $firewall_dst_port = '0', - $firewall_delay = '1', - $report_email = '', - $backup_rsync_options = '--exclude .snapshot', - $backup_retention = '5', - $run_checks = true, - $always_deploy = true, - $check_deploy = true, - $auto_deploy = false, - $enable = true ) { - + String $source, + String $http_user = '', + String $http_password = '', + String $artifact_type = 'release', + String $deploy_root = '', + String $user = 'root', + String $war_suffix = 'suffixnotset', + String $zip_suffix = 'suffixnotset', + String $jar_root = '', + String $jar_user = '', + String $jar_suffix = 'suffixnotset', + String $document_root = '', + String $document_user = '', + String $document_suffix = 'suffixnotset', + String $document_init_source = '', + String $config_root = '', + String $config_user = '', + String $config_suffix = 'suffixnotset', + String $config_init_source = '', + String $predeploy_customcommand = '', + String $predeploy_user = '', + Variant[String,Integer] $predeploy_priority = '39', + String $postdeploy_customcommand = '', + String $postdeploy_user = '', + Variant[String,Integer] $postdeploy_priority = '41', + String $init_script = '', + String $disable_services = '', + String $firewall_src_ip = '', + Variant[String,Integer] $firewall_dst_port = '0', + Variant[String,Integer] $firewall_delay = '1', + String $report_email = '', + String $backup_rsync_options = '--exclude .snapshot', + Variant[String,Integer] $backup_retention = '5', + Boolean $run_checks = true, + Boolean $always_deploy = true, + Boolean $check_deploy = true, + Boolean $auto_deploy = false, + Boolean $enable = true, +) { require puppi require puppi::params @@ -241,22 +241,20 @@ $bool_check_deploy = any2bool($check_deploy) $bool_auto_deploy = any2bool($auto_deploy) - ### CREATE PROJECT - puppi::project { $name: - source => $source, - deploy_root => $deploy_root, - user => $user, - predeploy_customcommand => $predeploy_customcommand, - postdeploy_customcommand => $postdeploy_customcommand, - init_script => $init_script, - disable_services => $disable_services, - report_email => $report_email, - enable => $enable, - document_root => $document_root, - config_root => $config_root, - } - + puppi::project { $name: + source => $source, + deploy_root => $deploy_root, + user => $user, + predeploy_customcommand => $predeploy_customcommand, + postdeploy_customcommand => $postdeploy_customcommand, + init_script => $init_script, + disable_services => $disable_services, + report_email => $report_email, + enable => $enable, + document_root => $document_root, + config_root => $config_root, + } ### INIT SEQUENCE if ($document_init_source != '') { @@ -293,29 +291,29 @@ } } - # First: hybrisServer-Platform - $platform_metadata_arguments = $http_password ? { - '' => "-s ${source}/hybrisServer-Platform/maven-metadata.xml -t maven-metadata -a ${real_always_deploy}" , - default => "-s ${source}/hybrisServer-Platform/maven-metadata.xml -t maven-metadata -a ${real_always_deploy} -u ${http_user} -p ${http_password}" - } + # First: hybrisServer-Platform + $platform_metadata_arguments = $http_password ? { + '' => "-s ${source}/hybrisServer-Platform/maven-metadata.xml -t maven-metadata -a ${real_always_deploy}" , + default => "-s ${source}/hybrisServer-Platform/maven-metadata.xml -t maven-metadata -a ${real_always_deploy} -u ${http_user} -p ${http_password}" + } - puppi::deploy { "${name}-Get_Maven_Metadata_hybrisServer-Platform_File": - priority => '20' , - command => 'get_file.sh' , - arguments => $platform_metadata_arguments, - user => 'root' , - project => $name , - enable => $enable , - } + puppi::deploy { "${name}-Get_Maven_Metadata_hybrisServer-Platform_File": + priority => '20' , + command => 'get_file.sh' , + arguments => $platform_metadata_arguments, + user => 'root' , + project => $name , + enable => $enable , + } - puppi::deploy { "${name}-Extract_Maven_Metadata_hybrisServer-Platform": - priority => '21' , - command => 'get_metadata.sh' , - arguments => "-m ${document_suffix} -mc ${config_suffix} -mj ${jar_suffix} -mw ${war_suffix} -mz ${zip_suffix} -at ${artifact_type}" , - user => 'root' , - project => $name , - enable => $enable , - } + puppi::deploy { "${name}-Extract_Maven_Metadata_hybrisServer-Platform": + priority => '21' , + command => 'get_metadata.sh' , + arguments => "-m ${document_suffix} -mc ${config_suffix} -mj ${jar_suffix} -mw ${war_suffix} -mz ${zip_suffix} -at ${artifact_type}" , + user => 'root' , + project => $name , + enable => $enable , + } # Files retrieval $platform_zipfile_arguments = $http_password ? { @@ -334,29 +332,29 @@ } } - # Second: hybrisServer-AllExtensions - $extensions_metadata_arguments = $http_password ? { - '' => "-s ${source}/hybrisServer-AllExtensions/maven-metadata.xml -t maven-metadata -a ${real_always_deploy}", - default => "-s ${source}/hybrisServer-AllExtensions/maven-metadata.xml -t maven-metadata -a ${real_always_deploy} -u ${http_user} -p ${http_password}", - } + # Second: hybrisServer-AllExtensions + $extensions_metadata_arguments = $http_password ? { + '' => "-s ${source}/hybrisServer-AllExtensions/maven-metadata.xml -t maven-metadata -a ${real_always_deploy}", + default => "-s ${source}/hybrisServer-AllExtensions/maven-metadata.xml -t maven-metadata -a ${real_always_deploy} -u ${http_user} -p ${http_password}", + } - puppi::deploy { "${name}-Get_Maven_Metadata_hybrisServer-AllExtensions_File": - priority => '23' , - command => 'get_file.sh' , - arguments => $extensions_metadata_arguments, - user => 'root' , - project => $name , - enable => $enable , - } + puppi::deploy { "${name}-Get_Maven_Metadata_hybrisServer-AllExtensions_File": + priority => '23' , + command => 'get_file.sh' , + arguments => $extensions_metadata_arguments, + user => 'root' , + project => $name , + enable => $enable , + } - puppi::deploy { "${name}-Extract_Maven_Metadata_hybrisServer-AllExtensions": - priority => '24' , - command => 'get_metadata.sh' , - arguments => "-m ${document_suffix} -mc ${config_suffix} -mj ${jar_suffix} -mw ${war_suffix} -mz ${zip_suffix} -at ${artifact_type}" , - user => 'root' , - project => $name , - enable => $enable , - } + puppi::deploy { "${name}-Extract_Maven_Metadata_hybrisServer-AllExtensions": + priority => '24' , + command => 'get_metadata.sh' , + arguments => "-m ${document_suffix} -mc ${config_suffix} -mj ${jar_suffix} -mw ${war_suffix} -mz ${zip_suffix} -at ${artifact_type}" , + user => 'root' , + project => $name , + enable => $enable , + } # Files retrieval if ($deploy_root != '') { @@ -375,7 +373,6 @@ } } - if ($config_root != '') { # Third: config-tarball (optional, right now not supported) $config_metadata_arguments = $http_password ? { @@ -587,7 +584,6 @@ } } - ### ROLLBACK PROCEDURE if ($firewall_src_ip != '') { @@ -711,7 +707,6 @@ } } - ### REPORTING if ($report_email != '') { @@ -729,5 +724,4 @@ if ($bool_auto_deploy == true) { puppi::run { $name: } } - } diff --git a/manifests/project/yum.pp b/manifests/project/yum.pp index cf48623..8ff155d 100644 --- a/manifests/project/yum.pp +++ b/manifests/project/yum.pp @@ -85,26 +85,26 @@ # Puppet runs. Default: 'false' # define puppi::project::yum ( - $rpm, - $rpm_version = 'latest', - $install_root = '/', - $predeploy_customcommand = '', - $predeploy_user = '', - $predeploy_priority = '39', - $postdeploy_customcommand = '', - $postdeploy_user = '', - $postdeploy_priority = '41', - $disable_services = '', - $firewall_src_ip = '', - $firewall_dst_port = '0', - $firewall_delay = '1', - $report_email = '', - $run_checks = true, - $checks_required = false, - $always_deploy = true, - $auto_deploy = false, - $enable = true ) { - + String $rpm, + String $rpm_version = 'latest', + String $install_root = '/', + String $predeploy_customcommand = '', + String $predeploy_user = '', + Variant[String,Integer] $predeploy_priority = '39', + String $postdeploy_customcommand = '', + String $postdeploy_user = '', + Variant[String,Integer] $postdeploy_priority = '41', + String $disable_services = '', + String $firewall_src_ip = '', + Variant[String,Integer] $firewall_dst_port = '0', + Variant[String,Integer] $firewall_delay = '1', + String $report_email = '', + Boolean $run_checks = true, + Boolean $checks_required = false, + Boolean $always_deploy = true, + Boolean $auto_deploy = false, + Boolean $enable = true, +) { require puppi require puppi::params @@ -133,15 +133,15 @@ $bool_auto_deploy = any2bool($auto_deploy) ### CREATE PROJECT - puppi::project { $name: - predeploy_customcommand => $predeploy_customcommand, - postdeploy_customcommand => $postdeploy_customcommand, - disable_services => $disable_services, - firewall_src_ip => $firewall_src_ip, - firewall_dst_port => $firewall_dst_port, - report_email => $report_email, - enable => $enable, - } + puppi::project { $name: + predeploy_customcommand => $predeploy_customcommand, + postdeploy_customcommand => $postdeploy_customcommand, + disable_services => $disable_services, + firewall_src_ip => $firewall_src_ip, + firewall_dst_port => $firewall_dst_port, + report_email => $report_email, + enable => $enable, + } ### DEPLOY SEQUENCE if ($bool_run_checks == true) { @@ -188,15 +188,15 @@ } } - # Here is done the deploy on $deploy_root - puppi::deploy { "${name}-Deploy": - priority => '40' , - command => 'yum.sh' , - arguments => "-a deploy -n ${rpm} -r ${install_root} -v ${rpm_version}" , - user => root , - project => $name , - enable => $enable , - } + # Here is done the deploy on $deploy_root + puppi::deploy { "${name}-Deploy": + priority => '40' , + command => 'yum.sh' , + arguments => "-a deploy -n ${rpm} -r ${install_root} -v ${rpm_version}" , + user => root , + project => $name , + enable => $enable , + } if ($postdeploy_customcommand != '') { puppi::deploy { "${name}-Run_Custom_PostDeploy_Script": @@ -242,7 +242,6 @@ } } - ### ROLLBACK PROCEDURE if ($firewall_src_ip != '') { @@ -278,14 +277,14 @@ } } - puppi::rollback { "${name}-Rollback": - priority => '40' , - command => 'yum.sh' , - arguments => "-a rollback -n ${rpm} -r ${install_root} -v ${rpm_version}" , - user => 'root' , - project => $name , - enable => $enable , - } + puppi::rollback { "${name}-Rollback": + priority => '40' , + command => 'yum.sh' , + arguments => "-a rollback -n ${rpm} -r ${install_root} -v ${rpm_version}" , + user => 'root' , + project => $name , + enable => $enable , + } if ($postdeploy_customcommand != '') { puppi::rollback { "${name}-Run_Custom_PostDeploy_Script": @@ -331,7 +330,6 @@ } } - ### REPORTING if ($report_email != '') { @@ -349,5 +347,4 @@ if ($bool_auto_deploy == true) { puppi::run { $name: } } - } diff --git a/manifests/report.pp b/manifests/report.pp index 4f8651e..31d86c3 100644 --- a/manifests/report.pp +++ b/manifests/report.pp @@ -12,13 +12,13 @@ # } # define puppi::report ( - $project, - $command, - $arguments = '', - $priority = '50', - $user = 'root', - $enable = true ) { - + String $project, + String $command, + String $arguments = '', + Variant[String,Integer] $priority = '50', + String $user = 'root', + Boolean $enable = true, +) { require puppi::params # Autoinclude the puppi class @@ -34,5 +34,4 @@ content => "su - ${user} -c \"export project=${project} && ${puppi::params::scriptsdir}/${command} ${arguments}\"\n", tag => 'puppi_report', } - } diff --git a/manifests/rollback.pp b/manifests/rollback.pp index b09692d..15ad6e4 100644 --- a/manifests/rollback.pp +++ b/manifests/rollback.pp @@ -12,13 +12,13 @@ # } # define puppi::rollback ( - $project, - $command, - $arguments = '', - $priority = '50', - $user = 'root', - $enable = true ) { - + String $project, + String $command, + String $arguments = '', + Variant[String,Integer] $priority = '50', + String $user = 'root', + Boolean $enable = true, +) { require puppi require puppi::params @@ -32,5 +32,4 @@ content => "su - ${user} -c \"export project=${project} && ${puppi::params::scriptsdir}/${command} ${arguments}\"\n", tag => 'puppi_rollback', } - } diff --git a/manifests/run.pp b/manifests/run.pp index 01556d6..ebc03a5 100644 --- a/manifests/run.pp +++ b/manifests/run.pp @@ -15,9 +15,9 @@ # puppi::run { "myapp": } # define puppi::run ( - $project = '', - $timeout = 300) { - + String $project = '', + Integer $timeout = 300, +) { require puppi exec { "Run_Puppi_${name}": @@ -27,5 +27,4 @@ timeout => $timeout, # require => File[ tag == 'puppi_deploy' ], } - } diff --git a/manifests/runscript.pp b/manifests/runscript.pp index 01aa36c..ee20ad8 100644 --- a/manifests/runscript.pp +++ b/manifests/runscript.pp @@ -98,23 +98,23 @@ # } # define puppi::runscript ( - $source = undef, - $content = undef, - $destination_path = '', - $parameters = '', - $autorun = true, - $refreshonly = true, - $creates = undef, - $onlyif = undef, - $unless = undef, - $basedir = '/usr/local/sbin', - $cron = '', - $cron_user = 'root', - $owner = 'root', - $group = 'root', - $mode = '0755', - $ensure = 'present' ) { - + Optional[String] $source = undef, + Optional[String] $content = undef, + String $destination_path = '', + String $parameters = '', + Boolean $autorun = true, + Boolean $refreshonly = true, + Optional[String] $creates = undef, + Optional[String] $onlyif = undef, + Optional[String] $unless = undef, + String $asedir = '/usr/local/sbin', + String $cron = '', + String $cron_user = 'root', + String $owner = 'root', + String $group = 'root', + String $mode = '0755', + String $ensure = 'present', +) { $real_command = $destination_path ? { '' => "${basedir}/${name}", default => $destination_path, diff --git a/manifests/skel.pp b/manifests/skel.pp index 840ed86..23c162a 100644 --- a/manifests/skel.pp +++ b/manifests/skel.pp @@ -4,7 +4,6 @@ # Creates the base Puppi dirs # class puppi::skel { - require puppi::params file { 'puppi_basedir': @@ -143,7 +142,7 @@ # MailPuppiCheck script file { '/usr/bin/mailpuppicheck': - ensure => 'present', + ensure => 'file', mode => '0750', owner => $puppi::params::configfile_owner, group => $puppi::params::configfile_group, @@ -152,7 +151,7 @@ # Puppi common scripts file { 'puppi.scripts': - ensure => present, + ensure => file, path => "${puppi::params::scriptsdir}/", mode => '0755', owner => $puppi::params::configfile_owner, diff --git a/manifests/todo.pp b/manifests/todo.pp index 6fff380..f6c7440 100644 --- a/manifests/todo.pp +++ b/manifests/todo.pp @@ -28,11 +28,11 @@ # } # define puppi::todo ( - $description = '', - $notes = '', - $check_command = '', - $run = '' ) { - + String $description = '', + String $notes = '', + String $check_command = '', + String $run = '', +) { require puppi require puppi::params @@ -45,7 +45,7 @@ } file { "${puppi::params::tododir}/${name}": - ensure => present, + ensure => file, mode => '0750', owner => $puppi::params::configfile_owner, group => $puppi::params::configfile_group, @@ -53,5 +53,4 @@ content => template('puppi/todo.erb'), tag => 'puppi_todo', } - } diff --git a/manifests/two.pp b/manifests/two.pp index 1bbe5fc..8954f6a 100644 --- a/manifests/two.pp +++ b/manifests/two.pp @@ -3,11 +3,9 @@ # Installs Puppi NextGen # class puppi::two { - # The Puppi command package { 'puppi': ensure => present, provider => 'gem', } - } diff --git a/manifests/ze.pp b/manifests/ze.pp index 5f62e1d..3d89e1f 100644 --- a/manifests/ze.pp +++ b/manifests/ze.pp @@ -15,11 +15,11 @@ # } # define puppi::ze ( - $variables, - $helper = 'standard', - $filter = '.*content.*|.*password.*', - $ensure = 'present' ) { - + Hash $variables, + String $helper = 'standard', + String $filter = '.*content.*|.*password.*', + String $ensure = 'present', +) { require puppi require puppi::params @@ -31,5 +31,4 @@ group => $puppi::params::configfile_group, content => inline_template("---\n<%= Hash[@variables].reject{ |k,v| k.to_s =~ /(${filter})/ }.keys.sort.map{|k| Array({k => @variables[k]}.to_yaml)[1..-1].join}.join(\"\n\") %>\n"), } - } From 111fd0facaecd805d74fff224c95ac3d4573a654 Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Tue, 24 Sep 2024 11:43:51 +0200 Subject: [PATCH 03/22] updated major version --- .github/workflows/codeql-analysis.yml | 71 +++++++++++++++++++++++++++ .github/workflows/pr.yml | 49 ++++++++++++++++++ .github/workflows/release.yml | 29 +++++++++++ metadata.json | 27 +++++++--- 4 files changed, 168 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/codeql-analysis.yml create mode 100644 .github/workflows/pr.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..adca811 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,71 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master ] + schedule: + - cron: '38 21 * * 1' + + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'ruby' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..d9092c8 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,49 @@ +--- +name: PR tests + +on: pull_request + +jobs: + static: + name: 'Syntax validation' + runs-on: ubuntu-latest + timeout-minutes: 10 + container: puppet/pdk:3.3.0.0 + steps: + - uses: actions/checkout@v4 + - name: Run static validations + run: /usr/local/bin/pdk bundle exec rake validate lint check + env: + BUNDLE_WITHOUT: development:system_tests:release + + unit: + name: 'Unit tests' + runs-on: ubuntu-latest + timeout-minutes: 60 +# container: puppet/puppet-dev-tools:4.x + container: puppet/pdk:3.3.0.0 + steps: + - uses: actions/checkout@v4 + - name: Run unit tests on Puppet 8 + run: /usr/local/bin/pdk test unit --puppet-version=8 + env: + BUNDLE_WITHOUT: development:system_tests:release + continue-on-error: true + - name: Run unit tests on Puppet 7 + run: /usr/local/bin/pdk test unit --puppet-version=7 + env: + BUNDLE_WITHOUT: development:system_tests:release + continue-on-error: true + + unit_legacy: + name: 'Unit tests Legacy Puppet' + runs-on: ubuntu-latest + timeout-minutes: 60 + container: puppet/puppet-dev-tools:4.x + steps: + - uses: actions/checkout@v4 + - name: Run unit tests on Puppet 6 + run: /usr/local/bin/pdk test unit --puppet-version=6 + env: + BUNDLE_WITHOUT: development:system_tests:release + continue-on-error: true \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f743ee9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,29 @@ +--- +name: Release + +on: + push: + tags: + - '*' + +env: + BUNDLE_WITHOUT: development:test:system_tests + +jobs: + deploy: + name: 'Deploy to forge' + runs-on: ubuntu-latest + if: github.repository_owner == 'example42' + container: puppet/pdk:3.3.0.0 + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: "PDK Build" + uses: docker://puppet/pdk:3.3.0.0 + with: + args: 'build' + - name: "Push to Forge" + uses: docker://puppet/pdk:3.3.0.0 + with: + args: 'release publish --forge-token ${{ secrets.PUPPET_FORGE_API_KEY }} --force' + diff --git a/metadata.json b/metadata.json index 6245f52..9ce3c4d 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "example42-puppi", - "version": "2.2.11", + "version": "3.0.0", "author": "Alessandro Franceschi", "summary": "Installs and configures Puppi", "license": "Apache-2.0", @@ -10,7 +10,7 @@ "dependencies": [ { "name": "puppetlabs/stdlib", - "version_requirement": ">= 3.2.0 < 7.0.0" + "version_requirement": ">= 3.2.0 < 10.0.0" } ], "operatingsystem_support": [ @@ -18,21 +18,26 @@ "operatingsystem": "RedHat", "operatingsystemrelease": [ "6", - "7" + "7", + "8", + "9" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "6", - "7" + "7", + "8" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "6", - "7" + "7", + "8", + "9" ] }, { @@ -47,7 +52,10 @@ "operatingsystemrelease": [ "7", "8", - "9" + "9", + "10", + "11", + "12" ] }, { @@ -55,14 +63,17 @@ "operatingsystemrelease": [ "14.04", "16.04", - "18.04" + "18.04", + "20.04", + "22.04", + "24.04" ] } ], "requirements": [ { "name": "puppet", - "version_requirement": ">= 3.0.0 < 6.0.0" + "version_requirement": ">= 3.0.0 < 9.0.0" } ], "description": "This module provides the Puppi libraries required by Example42 modules and, if explicitly included, the puppi command, its working environment, the defines and procedures to deploy applications", From e3fb2348f29f9c21bcfd81a3682b45c603710850 Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Tue, 24 Sep 2024 13:25:26 +0200 Subject: [PATCH 04/22] more lints --- .puppet-lint.rc | 3 ++- manifests/netinstall.pp | 4 ++-- manifests/project/git.pp | 4 ++-- manifests/project/hg.pp | 4 ++-- manifests/project/mysql.pp | 2 ++ manifests/project/svn.pp | 4 ++-- manifests/project/tar.pp | 2 +- manifests/project/y4maven.pp | 6 +++--- manifests/runscript.pp | 2 +- 9 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.puppet-lint.rc b/.puppet-lint.rc index 8d66c08..15a070c 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1,2 +1,3 @@ --relative ---ignore-lint-parameter_documentation \ No newline at end of file +--no-parameter_documentation +--no-params_empty_string \ No newline at end of file diff --git a/manifests/netinstall.pp b/manifests/netinstall.pp index 9df9e6b..9803c6a 100644 --- a/manifests/netinstall.pp +++ b/manifests/netinstall.pp @@ -67,7 +67,7 @@ String $retrieve_args = '', String $owner = 'root', String $group = 'root', - $timeout = '3600', + Variant[String,Integer] $timeout = '3600', String $work_dir = '/var/tmp', String $path = '/bin:/sbin:/usr/bin:/usr/sbin', String $extract_command = '', @@ -133,7 +133,7 @@ } exec { "Extract ${source_filename} from ${work_dir} - ${title}": - command => "mkdir -p ${destination_dir} && cd ${destination_dir} && ${real_extract_command} ${work_dir}/${source_filename} ${extract_command_second_arg}", + command => "mkdir -p ${destination_dir} && cd ${destination_dir} && ${real_extract_command} ${work_dir}/${source_filename} ${extract_command_second_arg}", # lint:ignore:140chars unless => "ls ${destination_dir}/${real_extracted_dir}", creates => "${destination_dir}/${real_extracted_dir}", timeout => $timeout, diff --git a/manifests/project/git.pp b/manifests/project/git.pp index 17bb66b..74635d1 100755 --- a/manifests/project/git.pp +++ b/manifests/project/git.pp @@ -252,7 +252,7 @@ puppi::deploy { "${name}-Deploy_Files": priority => '40' , command => 'git.sh' , - arguments => "-a deploy -s ${source} -d ${deploy_root} -u ${user} -gs ${git_subdir} -t ${tag} -b ${branch} -c ${commit} -v ${bool_verbose} -k ${bool_keep_gitdata}" , + arguments => "-a deploy -s ${source} -d ${deploy_root} -u ${user} -gs ${git_subdir} -t ${tag} -b ${branch} -c ${commit} -v ${bool_verbose} -k ${bool_keep_gitdata}" , # lint:ignore:140chars user => 'root' , project => $name , enable => $enable , @@ -352,7 +352,7 @@ puppi::rollback { "${name}-Rollback_Files": priority => '40' , command => 'git.sh' , - arguments => "-a rollback -s ${source} -d ${deploy_root} -gs ${git_subdir} -t ${tag} -b ${branch} -c ${commit} -v ${bool_verbose} -k ${bool_keep_gitdata}" , + arguments => "-a rollback -s ${source} -d ${deploy_root} -gs ${git_subdir} -t ${tag} -b ${branch} -c ${commit} -v ${bool_verbose} -k ${bool_keep_gitdata}" , # lint:ignore:140chars user => $user , project => $name , enable => $enable , diff --git a/manifests/project/hg.pp b/manifests/project/hg.pp index 7eac5af..4b7df6c 100644 --- a/manifests/project/hg.pp +++ b/manifests/project/hg.pp @@ -246,7 +246,7 @@ puppi::deploy { "${name}-Deploy_Files": priority => '40' , command => 'hg.sh' , - arguments => "-a deploy -s ${source} -d ${deploy_root} -u ${user} -t ${tag} -b ${branch} -c ${commit} -v ${bool_verbose} -k ${bool_keep_hgdata}" , + arguments => "-a deploy -s ${source} -d ${deploy_root} -u ${user} -t ${tag} -b ${branch} -c ${commit} -v ${bool_verbose} -k ${bool_keep_hgdata}" , # lint:ignore:140chars user => 'root' , project => $name , enable => $enable , @@ -346,7 +346,7 @@ puppi::rollback { "${name}-Rollback_Files": priority => '40' , command => 'hg.sh' , - arguments => "-a rollback -s ${source} -d ${deploy_root} -t ${tag} -b ${branch} -c ${commit} -v ${bool_verbose} -k ${bool_keep_hgdata}" , + arguments => "-a rollback -s ${source} -d ${deploy_root} -t ${tag} -b ${branch} -c ${commit} -v ${bool_verbose} -k ${bool_keep_hgdata}" , # lint:ignore:140chars user => $user , project => $name , enable => $enable , diff --git a/manifests/project/mysql.pp b/manifests/project/mysql.pp index 9ad8853..138ad7d 100644 --- a/manifests/project/mysql.pp +++ b/manifests/project/mysql.pp @@ -102,6 +102,8 @@ define puppi::project::mysql ( String $source, String $mysql_database, + String $deploy_root = '', + String $user = 'root', String $mysql_user = 'root', String $mysql_host = 'localhost', String $mysql_password = '', diff --git a/manifests/project/svn.pp b/manifests/project/svn.pp index e275cd7..059f54c 100644 --- a/manifests/project/svn.pp +++ b/manifests/project/svn.pp @@ -272,7 +272,7 @@ puppi::deploy { "${name}-Deploy_Files": priority => '40' , command => 'svn.sh' , - arguments => "-a deploy -s ${source} -d ${deploy_root} -u ${user} -gs ${svn_subdir} -su ${svn_user} -sp ${svn_password} -t ${tag} -b ${branch} -c ${commit} -v ${bool_verbose} -k ${bool_keep_svndata} -e ${bool_svn_export}" , + arguments => "-a deploy -s ${source} -d ${deploy_root} -u ${user} -gs ${svn_subdir} -su ${svn_user} -sp ${svn_password} -t ${tag} -b ${branch} -c ${commit} -v ${bool_verbose} -k ${bool_keep_svndata} -e ${bool_svn_export}" , # lint:ignore:140chars user => 'root' , project => $name , enable => $enable , @@ -373,7 +373,7 @@ puppi::rollback { "${name}-Rollback_Files": priority => '40' , command => 'svn.sh' , - arguments => "-a rollback -s ${source} -d ${deploy_root} -gs ${svn_subdir} -t ${tag} -b ${branch} -c ${commit} -v ${bool_verbose} -k ${bool_keep_svndata}" , + arguments => "-a rollback -s ${source} -d ${deploy_root} -gs ${svn_subdir} -t ${tag} -b ${branch} -c ${commit} -v ${bool_verbose} -k ${bool_keep_svndata}" , # lint:ignore:140chars user => $user , project => $name , enable => $enable , diff --git a/manifests/project/tar.pp b/manifests/project/tar.pp index 1144cc5..10b83cb 100644 --- a/manifests/project/tar.pp +++ b/manifests/project/tar.pp @@ -170,7 +170,7 @@ if ($verify_ssl) { $ssl_arg = '' - }else { + } else { $ssl_arg = '-k' } diff --git a/manifests/project/y4maven.pp b/manifests/project/y4maven.pp index 0117eb5..8c92fa9 100644 --- a/manifests/project/y4maven.pp +++ b/manifests/project/y4maven.pp @@ -293,8 +293,8 @@ # First: hybrisServer-Platform $platform_metadata_arguments = $http_password ? { - '' => "-s ${source}/hybrisServer-Platform/maven-metadata.xml -t maven-metadata -a ${real_always_deploy}" , - default => "-s ${source}/hybrisServer-Platform/maven-metadata.xml -t maven-metadata -a ${real_always_deploy} -u ${http_user} -p ${http_password}" + '' => "-s ${source}/hybrisServer-Platform/maven-metadata.xml -t maven-metadata -a ${real_always_deploy}" , + default => "-s ${source}/hybrisServer-Platform/maven-metadata.xml -t maven-metadata -a ${real_always_deploy} -u ${http_user} -p ${http_password}", # lint:ignore:140chars } puppi::deploy { "${name}-Get_Maven_Metadata_hybrisServer-Platform_File": @@ -335,7 +335,7 @@ # Second: hybrisServer-AllExtensions $extensions_metadata_arguments = $http_password ? { '' => "-s ${source}/hybrisServer-AllExtensions/maven-metadata.xml -t maven-metadata -a ${real_always_deploy}", - default => "-s ${source}/hybrisServer-AllExtensions/maven-metadata.xml -t maven-metadata -a ${real_always_deploy} -u ${http_user} -p ${http_password}", + default => "-s ${source}/hybrisServer-AllExtensions/maven-metadata.xml -t maven-metadata -a ${real_always_deploy} -u ${http_user} -p ${http_password}", # lint:ignore:140chars } puppi::deploy { "${name}-Get_Maven_Metadata_hybrisServer-AllExtensions_File": diff --git a/manifests/runscript.pp b/manifests/runscript.pp index ee20ad8..7e2e0f3 100644 --- a/manifests/runscript.pp +++ b/manifests/runscript.pp @@ -107,7 +107,7 @@ Optional[String] $creates = undef, Optional[String] $onlyif = undef, Optional[String] $unless = undef, - String $asedir = '/usr/local/sbin', + String $basedir = '/usr/local/sbin', String $cron = '', String $cron_user = 'root', String $owner = 'root', From f68d16197caa5ab69fa633b7787ccce9d2a331a5 Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Tue, 24 Sep 2024 14:38:24 +0200 Subject: [PATCH 05/22] removed .project --- .project | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 .project diff --git a/.project b/.project deleted file mode 100644 index b606184..0000000 --- a/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - puppi - - - - - - org.cloudsmith.geppetto.pp.dsl.ui.modulefileBuilder - - - - - org.eclipse.xtext.ui.shared.xtextBuilder - - - - - - org.cloudsmith.geppetto.pp.dsl.ui.puppetNature - org.eclipse.xtext.ui.shared.xtextNature - - From ccdd609db3538202101f54db4bb03e0d9ae04fcd Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Tue, 24 Sep 2024 14:40:21 +0200 Subject: [PATCH 06/22] Fixed fixtures --- .fixtures.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index 96cb39d..fb42c62 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,6 +1,4 @@ fixtures: repositories: - "concat": "git://github.com/puppetlabs/puppetlabs-concat.git" - "stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git" - symlinks: - "puppi": "#{source_dir}" + "stdlib": "https://github.com/puppetlabs/puppetlabs-stdlib.git" + "concat": "https://github.com/puppetlabs/puppetlabs-concat.git" From 11094fd932d8e6847994078505c267fd1f7222f8 Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Tue, 24 Sep 2024 19:46:38 +0200 Subject: [PATCH 07/22] pdk convert + tests --- .puppet-lint.rc | 2 -- .sync.yml | 8 ++++++++ CHANGELOG.md | 11 +++++++++++ data/common.yaml | 1 + hiera.yaml | 21 ++++++++++++++++++++ manifests/check.pp | 2 +- manifests/configure.pp | 2 +- manifests/deploy.pp | 2 +- manifests/initialize.pp | 2 +- manifests/project.pp | 2 +- manifests/project/archive.pp | 2 +- manifests/project/builder.pp | 2 +- manifests/project/dir.pp | 2 +- manifests/project/files.pp | 2 +- manifests/project/git.pp | 2 +- manifests/project/hg.pp | 2 +- manifests/project/maven.pp | 2 +- manifests/project/mysql.pp | 2 +- manifests/project/service.pp | 2 +- manifests/project/svn.pp | 2 +- manifests/project/tar.pp | 2 +- manifests/project/war.pp | 2 +- manifests/project/y4maven.pp | 2 +- manifests/project/yum.pp | 2 +- manifests/report.pp | 2 +- manifests/rollback.pp | 2 +- spec/classes/dependencies_spec.rb | 13 +++++++++++++ spec/classes/extras_spec.rb | 13 +++++++++++++ spec/classes/helpers_spec.rb | 13 +++++++++++++ spec/classes/mcollective/client_spec.rb | 13 +++++++++++++ spec/classes/mcollective/server_spec.rb | 13 +++++++++++++ spec/classes/one_spec.rb | 13 +++++++++++++ spec/classes/params_spec.rb | 13 +++++++++++++ spec/classes/puppi_spec.rb | 18 +++++++---------- spec/classes/skel_spec.rb | 13 +++++++++++++ spec/classes/two_spec.rb | 13 +++++++++++++ spec/defines/check_spec.rb | 18 +++++++++++++++++ spec/defines/configure_spec.rb | 18 +++++++++++++++++ spec/defines/deploy_spec.rb | 18 +++++++++++++++++ spec/defines/helper_spec.rb | 18 +++++++++++++++++ spec/defines/info/instance_spec.rb | 18 +++++++++++++++++ spec/defines/info/module_spec.rb | 18 +++++++++++++++++ spec/defines/info/readme_spec.rb | 18 +++++++++++++++++ spec/defines/info_spec.rb | 18 +++++++++++++++++ spec/defines/initialize_spec.rb | 18 +++++++++++++++++ spec/defines/install_packages_spec.rb | 18 +++++++++++++++++ spec/defines/log_spec.rb | 18 +++++++++++++++++ spec/defines/netinstall_spec.rb | 18 +++++++++++++++++ spec/defines/project/archive_spec.rb | 18 +++++++++++++++++ spec/defines/project/builder_spec.rb | 18 +++++++++++++++++ spec/defines/project/dir_spec.rb | 18 +++++++++++++++++ spec/defines/project/files_spec.rb | 18 +++++++++++++++++ spec/defines/project/git_spec.rb | 18 +++++++++++++++++ spec/defines/project/hg_spec.rb | 18 +++++++++++++++++ spec/defines/project/maven_spec.rb | 18 +++++++++++++++++ spec/defines/project/mysql_spec.rb | 18 +++++++++++++++++ spec/defines/project/service_spec.rb | 18 +++++++++++++++++ spec/defines/project/svn_spec.rb | 18 +++++++++++++++++ spec/defines/project/tar_spec.rb | 18 +++++++++++++++++ spec/defines/project/war_spec.rb | 18 +++++++++++++++++ spec/defines/project/y4maven_spec.rb | 18 +++++++++++++++++ spec/defines/project/yum_spec.rb | 18 +++++++++++++++++ spec/defines/project_spec.rb | 18 +++++++++++++++++ spec/defines/puppi_check_spec.rb | 26 ------------------------- spec/defines/puppi_deploy_spec.rb | 25 ------------------------ spec/defines/puppi_helper_spec.rb | 20 ------------------- spec/defines/puppi_info_spec.rb | 24 ----------------------- spec/defines/puppi_initialize_spec.rb | 25 ------------------------ spec/defines/puppi_log_spec.rb | 22 --------------------- spec/defines/puppi_project_spec.rb | 25 ------------------------ spec/defines/puppi_report_spec.rb | 25 ------------------------ spec/defines/puppi_rollback_spec.rb | 25 ------------------------ spec/defines/puppi_run_spec.rb | 17 ---------------- spec/defines/puppi_todo_spec.rb | 24 ----------------------- spec/defines/puppi_ze_spec.rb | 20 ------------------- spec/defines/report_spec.rb | 18 +++++++++++++++++ spec/defines/rollback_spec.rb | 18 +++++++++++++++++ spec/defines/run_spec.rb | 18 +++++++++++++++++ spec/defines/runscript_spec.rb | 18 +++++++++++++++++ spec/defines/todo_spec.rb | 18 +++++++++++++++++ spec/defines/ze_spec.rb | 18 +++++++++++++++++ 81 files changed, 780 insertions(+), 312 deletions(-) create mode 100644 .sync.yml create mode 100644 CHANGELOG.md create mode 100644 data/common.yaml create mode 100644 hiera.yaml create mode 100644 spec/classes/dependencies_spec.rb create mode 100644 spec/classes/extras_spec.rb create mode 100644 spec/classes/helpers_spec.rb create mode 100644 spec/classes/mcollective/client_spec.rb create mode 100644 spec/classes/mcollective/server_spec.rb create mode 100644 spec/classes/one_spec.rb create mode 100644 spec/classes/params_spec.rb create mode 100644 spec/classes/skel_spec.rb create mode 100644 spec/classes/two_spec.rb create mode 100644 spec/defines/check_spec.rb create mode 100644 spec/defines/configure_spec.rb create mode 100644 spec/defines/deploy_spec.rb create mode 100644 spec/defines/helper_spec.rb create mode 100644 spec/defines/info/instance_spec.rb create mode 100644 spec/defines/info/module_spec.rb create mode 100644 spec/defines/info/readme_spec.rb create mode 100644 spec/defines/info_spec.rb create mode 100644 spec/defines/initialize_spec.rb create mode 100644 spec/defines/install_packages_spec.rb create mode 100644 spec/defines/log_spec.rb create mode 100644 spec/defines/netinstall_spec.rb create mode 100644 spec/defines/project/archive_spec.rb create mode 100644 spec/defines/project/builder_spec.rb create mode 100644 spec/defines/project/dir_spec.rb create mode 100644 spec/defines/project/files_spec.rb create mode 100644 spec/defines/project/git_spec.rb create mode 100644 spec/defines/project/hg_spec.rb create mode 100644 spec/defines/project/maven_spec.rb create mode 100644 spec/defines/project/mysql_spec.rb create mode 100644 spec/defines/project/service_spec.rb create mode 100644 spec/defines/project/svn_spec.rb create mode 100644 spec/defines/project/tar_spec.rb create mode 100644 spec/defines/project/war_spec.rb create mode 100644 spec/defines/project/y4maven_spec.rb create mode 100644 spec/defines/project/yum_spec.rb create mode 100644 spec/defines/project_spec.rb delete mode 100644 spec/defines/puppi_check_spec.rb delete mode 100644 spec/defines/puppi_deploy_spec.rb delete mode 100644 spec/defines/puppi_helper_spec.rb delete mode 100644 spec/defines/puppi_info_spec.rb delete mode 100644 spec/defines/puppi_initialize_spec.rb delete mode 100644 spec/defines/puppi_log_spec.rb delete mode 100644 spec/defines/puppi_project_spec.rb delete mode 100644 spec/defines/puppi_report_spec.rb delete mode 100644 spec/defines/puppi_rollback_spec.rb delete mode 100644 spec/defines/puppi_run_spec.rb delete mode 100644 spec/defines/puppi_todo_spec.rb delete mode 100644 spec/defines/puppi_ze_spec.rb create mode 100644 spec/defines/report_spec.rb create mode 100644 spec/defines/rollback_spec.rb create mode 100644 spec/defines/run_spec.rb create mode 100644 spec/defines/runscript_spec.rb create mode 100644 spec/defines/todo_spec.rb create mode 100644 spec/defines/ze_spec.rb diff --git a/.puppet-lint.rc b/.puppet-lint.rc index 15a070c..cc96ece 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1,3 +1 @@ --relative ---no-parameter_documentation ---no-params_empty_string \ No newline at end of file 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/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9e5c7de --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +## Release 3.0.0 + +**Features** + +**Bugfixes** + +**Known Issues** 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/manifests/check.pp b/manifests/check.pp index 5ae3661..a127ead 100644 --- a/manifests/check.pp +++ b/manifests/check.pp @@ -18,7 +18,7 @@ String $hostwide = 'no', Variant[String,Integer] $priority = '50', String $project = 'default', - Boolean $enable = true, + Variant[Boolean,String] $enable = true, ) { require puppi require puppi::params diff --git a/manifests/configure.pp b/manifests/configure.pp index fd95f6c..77f48d4 100644 --- a/manifests/configure.pp +++ b/manifests/configure.pp @@ -19,7 +19,7 @@ String $arguments = '', Variant[String,Integer] $priority = '50', String $user = 'root', - Boolean $enable = true, + Variant[Boolean,String] $enable = true, ) { require puppi require puppi::params diff --git a/manifests/deploy.pp b/manifests/deploy.pp index 9e43f50..a7d45e5 100644 --- a/manifests/deploy.pp +++ b/manifests/deploy.pp @@ -19,7 +19,7 @@ String $arguments = '', Variant[String,Integer] $priority = '50', String $user = 'root', - Boolean $enable = true, + Variant[Boolean,String] $enable = true, ) { require puppi require puppi::params diff --git a/manifests/initialize.pp b/manifests/initialize.pp index 9fbd5c7..75e4406 100644 --- a/manifests/initialize.pp +++ b/manifests/initialize.pp @@ -17,7 +17,7 @@ String $arguments = '', Variant[String,Integer] $priority = '50', String $user = 'root', - Boolean $enable = true, + Variant[Boolean,String] $enable = true, ) { require puppi require puppi::params diff --git a/manifests/project.pp b/manifests/project.pp index 11fd869..a7638da 100644 --- a/manifests/project.pp +++ b/manifests/project.pp @@ -19,7 +19,7 @@ Optional[String] $source_baseurl = undef, String $document_root = '', Optional[String] $config_root = undef, - Boolean $enable = true, + Variant[Boolean,String] $enable = true, ) { require puppi::params diff --git a/manifests/project/archive.pp b/manifests/project/archive.pp index 73f7346..b7f4e1c 100644 --- a/manifests/project/archive.pp +++ b/manifests/project/archive.pp @@ -124,7 +124,7 @@ Boolean $run_checks = true, Boolean $always_deploy = true, Boolean $auto_deploy = false, - Boolean $enable = true, + Variant[Boolean,String] $enable = true, ) { require puppi require puppi::params diff --git a/manifests/project/builder.pp b/manifests/project/builder.pp index 544b3a4..4867b69 100644 --- a/manifests/project/builder.pp +++ b/manifests/project/builder.pp @@ -150,7 +150,7 @@ Boolean $run_checks = true, Boolean $always_deploy = true, Boolean $auto_deploy = false, - Boolean $enable = true, + Variant[Boolean,String] $enable = true, ) { require puppi require puppi::params diff --git a/manifests/project/dir.pp b/manifests/project/dir.pp index c23bc46..a840d7d 100644 --- a/manifests/project/dir.pp +++ b/manifests/project/dir.pp @@ -123,7 +123,7 @@ Boolean $run_checks = true, Boolean $skip_predeploy = false, Boolean $auto_deploy = false, - Boolean $enable = true, + Variant[Boolean,String] $enable = true, ) { require puppi require puppi::params diff --git a/manifests/project/files.pp b/manifests/project/files.pp index 52b017f..6722b33 100644 --- a/manifests/project/files.pp +++ b/manifests/project/files.pp @@ -140,7 +140,7 @@ Variant[String,Integer] $backup_retention = '5', Boolean $run_checks = true, Boolean $auto_deploy = false, - Boolean $enable = true, + Variant[Boolean,String] $enable = true, ) { require puppi require puppi::params diff --git a/manifests/project/git.pp b/manifests/project/git.pp index 74635d1..8a3fc70 100755 --- a/manifests/project/git.pp +++ b/manifests/project/git.pp @@ -151,7 +151,7 @@ Variant[String,Integer] $backup_retention = '5', Boolean $run_checks = true, Boolean $auto_deploy = false, - Boolean $enable = true, + Variant[Boolean,String] $enable = true, ) { require puppi require puppi::params diff --git a/manifests/project/hg.pp b/manifests/project/hg.pp index 4b7df6c..35a3af6 100644 --- a/manifests/project/hg.pp +++ b/manifests/project/hg.pp @@ -145,7 +145,7 @@ Variant[String,Integer] $backup_retention = '5', Boolean $run_checks = true, Boolean $auto_deploy = false, - Boolean $enable = true, + Variant[Boolean,String] $enable = true, ) { require puppi require puppi::params diff --git a/manifests/project/maven.pp b/manifests/project/maven.pp index 24a8a43..db760b1 100644 --- a/manifests/project/maven.pp +++ b/manifests/project/maven.pp @@ -215,7 +215,7 @@ Boolean $always_deploy = true, Boolean $check_deploy = true, Boolean $auto_deploy = false, - Boolean $enable = true, + Variant[Boolean,String] $enable = true, ) { require puppi require puppi::params diff --git a/manifests/project/mysql.pp b/manifests/project/mysql.pp index 138ad7d..16450ad 100644 --- a/manifests/project/mysql.pp +++ b/manifests/project/mysql.pp @@ -124,7 +124,7 @@ Boolean $run_checks = true, Boolean $always_deploy = true, Boolean $auto_deploy = false, - Boolean $enable = true, + Variant[Boolean,String] $enable = true, ) { require puppi require puppi::params diff --git a/manifests/project/service.pp b/manifests/project/service.pp index f9ed05a..793bd37 100644 --- a/manifests/project/service.pp +++ b/manifests/project/service.pp @@ -91,7 +91,7 @@ String $report_email = '', Boolean $run_checks = true, Boolean $auto_deploy = false, - Boolean $enable = true, + Variant[Boolean,String] $enable = true, ) { require puppi require puppi::params diff --git a/manifests/project/svn.pp b/manifests/project/svn.pp index 059f54c..af30df3 100644 --- a/manifests/project/svn.pp +++ b/manifests/project/svn.pp @@ -169,7 +169,7 @@ Variant[String,Integer] $backup_retention = '5', Boolean $run_checks = true, Boolean $auto_deploy = false, - Boolean $enable = true, + Variant[Boolean,String] $enable = true, ) { require puppi require puppi::params diff --git a/manifests/project/tar.pp b/manifests/project/tar.pp index 10b83cb..8cc32a2 100644 --- a/manifests/project/tar.pp +++ b/manifests/project/tar.pp @@ -137,7 +137,7 @@ Boolean $always_deploy = true, Boolean $auto_deploy = false, Boolean $verify_ssl = true, - Boolean $enable = true, + Variant[Boolean,String] $enable = true, ) { require puppi require puppi::params diff --git a/manifests/project/war.pp b/manifests/project/war.pp index 0d5d109..6888be5 100644 --- a/manifests/project/war.pp +++ b/manifests/project/war.pp @@ -139,7 +139,7 @@ Boolean $always_deploy = true, Boolean $check_deploy = true, Boolean $auto_deploy = false, - Boolean $enable = true, + Variant[Boolean,String] $enable = true, ) { require puppi require puppi::params diff --git a/manifests/project/y4maven.pp b/manifests/project/y4maven.pp index 8c92fa9..fec9278 100644 --- a/manifests/project/y4maven.pp +++ b/manifests/project/y4maven.pp @@ -201,7 +201,7 @@ Boolean $always_deploy = true, Boolean $check_deploy = true, Boolean $auto_deploy = false, - Boolean $enable = true, + Variant[Boolean,String] $enable = true, ) { require puppi require puppi::params diff --git a/manifests/project/yum.pp b/manifests/project/yum.pp index 8ff155d..bbfc6c8 100644 --- a/manifests/project/yum.pp +++ b/manifests/project/yum.pp @@ -103,7 +103,7 @@ Boolean $checks_required = false, Boolean $always_deploy = true, Boolean $auto_deploy = false, - Boolean $enable = true, + Variant[Boolean,String] $enable = true, ) { require puppi require puppi::params diff --git a/manifests/report.pp b/manifests/report.pp index 31d86c3..17f4f12 100644 --- a/manifests/report.pp +++ b/manifests/report.pp @@ -17,7 +17,7 @@ String $arguments = '', Variant[String,Integer] $priority = '50', String $user = 'root', - Boolean $enable = true, + Variant[Boolean,String] $enable = true, ) { require puppi::params diff --git a/manifests/rollback.pp b/manifests/rollback.pp index 15ad6e4..780f91c 100644 --- a/manifests/rollback.pp +++ b/manifests/rollback.pp @@ -17,7 +17,7 @@ String $arguments = '', Variant[String,Integer] $priority = '50', String $user = 'root', - Boolean $enable = true, + Variant[Boolean,String] $enable = true, ) { require puppi require puppi::params diff --git a/spec/classes/dependencies_spec.rb b/spec/classes/dependencies_spec.rb new file mode 100644 index 0000000..0e0b0e9 --- /dev/null +++ b/spec/classes/dependencies_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::dependencies' do + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile.with_all_deps } + end + end +end diff --git a/spec/classes/extras_spec.rb b/spec/classes/extras_spec.rb new file mode 100644 index 0000000..c386a0b --- /dev/null +++ b/spec/classes/extras_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::extras' do + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile.with_all_deps } + end + end +end diff --git a/spec/classes/helpers_spec.rb b/spec/classes/helpers_spec.rb new file mode 100644 index 0000000..5918cef --- /dev/null +++ b/spec/classes/helpers_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::helpers' do + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile.with_all_deps } + end + end +end diff --git a/spec/classes/mcollective/client_spec.rb b/spec/classes/mcollective/client_spec.rb new file mode 100644 index 0000000..59a6f64 --- /dev/null +++ b/spec/classes/mcollective/client_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::mcollective::client' do + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile.with_all_deps } + end + end +end diff --git a/spec/classes/mcollective/server_spec.rb b/spec/classes/mcollective/server_spec.rb new file mode 100644 index 0000000..2c0b3d7 --- /dev/null +++ b/spec/classes/mcollective/server_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::mcollective::server' do + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile.with_all_deps } + end + end +end diff --git a/spec/classes/one_spec.rb b/spec/classes/one_spec.rb new file mode 100644 index 0000000..29a6225 --- /dev/null +++ b/spec/classes/one_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::one' do + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile.with_all_deps } + end + end +end diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb new file mode 100644 index 0000000..64a9ea6 --- /dev/null +++ b/spec/classes/params_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::params' do + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile.with_all_deps } + end + end +end diff --git a/spec/classes/puppi_spec.rb b/spec/classes/puppi_spec.rb index 903f593..e049524 100644 --- a/spec/classes/puppi_spec.rb +++ b/spec/classes/puppi_spec.rb @@ -1,17 +1,13 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'puppi' do + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } - let(:node) { 'rspec.example42.com' } - let(:node) { 'rspec.example42.com' } - let(:facts) { { :ipaddress => '10.42.42.42' } } - - describe 'Test standard installation' do - it { should contain_file('puppi').with_ensure('present') } - it { should contain_file('puppi.conf').with_ensure('present') } - it { should contain_file('puppi.scripts').with_ensure('present') } - it { should contain_file('puppi_basedir').with_ensure('directory') } - it { should contain_file('puppi_datadir').with_ensure('directory') } + it { is_expected.to compile.with_all_deps } + end end - end diff --git a/spec/classes/skel_spec.rb b/spec/classes/skel_spec.rb new file mode 100644 index 0000000..d96180a --- /dev/null +++ b/spec/classes/skel_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::skel' do + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile.with_all_deps } + end + end +end diff --git a/spec/classes/two_spec.rb b/spec/classes/two_spec.rb new file mode 100644 index 0000000..1a824c9 --- /dev/null +++ b/spec/classes/two_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::two' do + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile.with_all_deps } + end + end +end diff --git a/spec/defines/check_spec.rb b/spec/defines/check_spec.rb new file mode 100644 index 0000000..4478e6d --- /dev/null +++ b/spec/defines/check_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::check' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/configure_spec.rb b/spec/defines/configure_spec.rb new file mode 100644 index 0000000..fbac888 --- /dev/null +++ b/spec/defines/configure_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::configure' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/deploy_spec.rb b/spec/defines/deploy_spec.rb new file mode 100644 index 0000000..da68180 --- /dev/null +++ b/spec/defines/deploy_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::deploy' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/helper_spec.rb b/spec/defines/helper_spec.rb new file mode 100644 index 0000000..024457e --- /dev/null +++ b/spec/defines/helper_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::helper' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/info/instance_spec.rb b/spec/defines/info/instance_spec.rb new file mode 100644 index 0000000..acf626a --- /dev/null +++ b/spec/defines/info/instance_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::info::instance' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/info/module_spec.rb b/spec/defines/info/module_spec.rb new file mode 100644 index 0000000..d67447d --- /dev/null +++ b/spec/defines/info/module_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::info::module' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/info/readme_spec.rb b/spec/defines/info/readme_spec.rb new file mode 100644 index 0000000..b8088e0 --- /dev/null +++ b/spec/defines/info/readme_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::info::readme' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/info_spec.rb b/spec/defines/info_spec.rb new file mode 100644 index 0000000..9f1f923 --- /dev/null +++ b/spec/defines/info_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::info' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/initialize_spec.rb b/spec/defines/initialize_spec.rb new file mode 100644 index 0000000..e6e983b --- /dev/null +++ b/spec/defines/initialize_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::initialize' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/install_packages_spec.rb b/spec/defines/install_packages_spec.rb new file mode 100644 index 0000000..deb2939 --- /dev/null +++ b/spec/defines/install_packages_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::install_packages' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/log_spec.rb b/spec/defines/log_spec.rb new file mode 100644 index 0000000..295f8e5 --- /dev/null +++ b/spec/defines/log_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::log' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/netinstall_spec.rb b/spec/defines/netinstall_spec.rb new file mode 100644 index 0000000..7730112 --- /dev/null +++ b/spec/defines/netinstall_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::netinstall' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/project/archive_spec.rb b/spec/defines/project/archive_spec.rb new file mode 100644 index 0000000..a8e5b63 --- /dev/null +++ b/spec/defines/project/archive_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::project::archive' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/project/builder_spec.rb b/spec/defines/project/builder_spec.rb new file mode 100644 index 0000000..aa6cf19 --- /dev/null +++ b/spec/defines/project/builder_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::project::builder' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/project/dir_spec.rb b/spec/defines/project/dir_spec.rb new file mode 100644 index 0000000..8a84651 --- /dev/null +++ b/spec/defines/project/dir_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::project::dir' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/project/files_spec.rb b/spec/defines/project/files_spec.rb new file mode 100644 index 0000000..5483032 --- /dev/null +++ b/spec/defines/project/files_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::project::files' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/project/git_spec.rb b/spec/defines/project/git_spec.rb new file mode 100644 index 0000000..96f5595 --- /dev/null +++ b/spec/defines/project/git_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::project::git' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/project/hg_spec.rb b/spec/defines/project/hg_spec.rb new file mode 100644 index 0000000..6a285ca --- /dev/null +++ b/spec/defines/project/hg_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::project::hg' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/project/maven_spec.rb b/spec/defines/project/maven_spec.rb new file mode 100644 index 0000000..b13e8de --- /dev/null +++ b/spec/defines/project/maven_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::project::maven' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/project/mysql_spec.rb b/spec/defines/project/mysql_spec.rb new file mode 100644 index 0000000..c3be39b --- /dev/null +++ b/spec/defines/project/mysql_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::project::mysql' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/project/service_spec.rb b/spec/defines/project/service_spec.rb new file mode 100644 index 0000000..ed7163f --- /dev/null +++ b/spec/defines/project/service_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::project::service' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/project/svn_spec.rb b/spec/defines/project/svn_spec.rb new file mode 100644 index 0000000..52d9d05 --- /dev/null +++ b/spec/defines/project/svn_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::project::svn' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/project/tar_spec.rb b/spec/defines/project/tar_spec.rb new file mode 100644 index 0000000..56e504a --- /dev/null +++ b/spec/defines/project/tar_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::project::tar' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/project/war_spec.rb b/spec/defines/project/war_spec.rb new file mode 100644 index 0000000..c8a85a3 --- /dev/null +++ b/spec/defines/project/war_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::project::war' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/project/y4maven_spec.rb b/spec/defines/project/y4maven_spec.rb new file mode 100644 index 0000000..3c271d1 --- /dev/null +++ b/spec/defines/project/y4maven_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::project::y4maven' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/project/yum_spec.rb b/spec/defines/project/yum_spec.rb new file mode 100644 index 0000000..dbbe7c7 --- /dev/null +++ b/spec/defines/project/yum_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::project::yum' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/project_spec.rb b/spec/defines/project_spec.rb new file mode 100644 index 0000000..7b5110c --- /dev/null +++ b/spec/defines/project_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::project' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/puppi_check_spec.rb b/spec/defines/puppi_check_spec.rb deleted file mode 100644 index 749fbd9..0000000 --- a/spec/defines/puppi_check_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'spec_helper' - -describe 'puppi::check' do - - let(:title) { 'puppi::check' } - let(:node) { 'rspec.example42.com' } - let(:facts) { { :arch => 'i386' } } - let(:params) { - { 'enable' => 'true', - 'name' => 'get', - 'command' => 'echo', - 'priority' => '50', - 'project' => 'myapp', - } - } - - describe 'Test puppi check step file creation' do - it 'should create a puppi::check step file' do - should contain_file('Puppi_check_myapp_50_get').with_ensure('present') - end - it 'should populate correctly the puppi::check step file' do - should contain_file('Puppi_check_myapp_50_get').with_content(/\/usr\/lib64\/nagios\/plugins\/echo/) - end - end - -end diff --git a/spec/defines/puppi_deploy_spec.rb b/spec/defines/puppi_deploy_spec.rb deleted file mode 100644 index 2563b0c..0000000 --- a/spec/defines/puppi_deploy_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' - -describe 'puppi::deploy' do - - let(:title) { 'puppi::deploy' } - let(:node) { 'rspec.example42.com' } - let(:params) { - { 'enable' => 'true', - 'name' => 'get', - 'command' => 'echo', - 'priority' => '50', - 'project' => 'myapp', - } - } - - describe 'Test puppi deploy step file creation' do - it 'should create a puppi::deploy step file' do - should contain_file('/etc/puppi/projects/myapp/deploy/50-get').with_ensure('present') - end - it 'should populate correctly the puppi::deploy step file' do - should contain_file('/etc/puppi/projects/myapp/deploy/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") - end - end - -end diff --git a/spec/defines/puppi_helper_spec.rb b/spec/defines/puppi_helper_spec.rb deleted file mode 100644 index 2fc08b9..0000000 --- a/spec/defines/puppi_helper_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'spec_helper' - -describe 'puppi::helper' do - - let(:title) { 'spec' } - let(:node) { 'rspec.example42.com' } - let(:params) { - { 'template' => 'puppi/helpers/standard.yml.erb' } - } - - describe 'Test puppi helper file creation' do - it 'should create a puppi helper file' do - should contain_file('puppi_helper_spec').with_ensure('present') - end - it 'should populate correctly the helper file' do - should contain_file('puppi_helper_spec').with_content(/info/) - end - end - -end diff --git a/spec/defines/puppi_info_spec.rb b/spec/defines/puppi_info_spec.rb deleted file mode 100644 index 10ea20e..0000000 --- a/spec/defines/puppi_info_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper' - -describe 'puppi::info' do - - let(:title) { 'puppi::info' } - let(:node) { 'rspec.example42.com' } - let(:params) { - { 'name' => 'sample', - 'description' => 'Sample Info', - 'templatefile' => 'puppi/info.erb', - 'run' => 'myownscript', - } - } - - describe 'Test puppi info step file creation' do - it 'should create a puppi::info step file' do - should contain_file('/etc/puppi/info/sample').with_ensure('present') - end - it 'should populate correctly the puppi::info step file' do - should contain_file('/etc/puppi/info/sample').with_content(/myownscript/) - end - end - -end diff --git a/spec/defines/puppi_initialize_spec.rb b/spec/defines/puppi_initialize_spec.rb deleted file mode 100644 index f314880..0000000 --- a/spec/defines/puppi_initialize_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' - -describe 'puppi::initialize' do - - let(:title) { 'puppi::initialize' } - let(:node) { 'rspec.example42.com' } - let(:params) { - { 'enable' => 'true', - 'name' => 'get', - 'command' => 'echo', - 'priority' => '50', - 'project' => 'myapp', - } - } - - describe 'Test puppi initialize step file creation' do - it 'should create a puppi::initialize step file' do - should contain_file('/etc/puppi/projects/myapp/initialize/50-get').with_ensure('present') - end - it 'should populate correctly the puppi::initialize step file' do - should contain_file('/etc/puppi/projects/myapp/initialize/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") - end - end - -end diff --git a/spec/defines/puppi_log_spec.rb b/spec/defines/puppi_log_spec.rb deleted file mode 100644 index e67188c..0000000 --- a/spec/defines/puppi_log_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' - -describe 'puppi::log' do - - let(:title) { 'mylog' } - let(:node) { 'rspec.example42.com' } - let(:params) { - { 'log' => '/var/log/mylog.log', - 'description' => 'My Log', - } - } - - describe 'Test puppi log file creation' do - it 'should create a puppi::log file' do - should contain_file('/etc/puppi/logs/mylog').with_ensure('present') - end - it 'should populate correctly the puppi::log step file' do - should contain_file('/etc/puppi/logs/mylog').with_content(/mylog.log/) - end - end - -end diff --git a/spec/defines/puppi_project_spec.rb b/spec/defines/puppi_project_spec.rb deleted file mode 100644 index b37cb80..0000000 --- a/spec/defines/puppi_project_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' - -describe 'puppi::report' do - - let(:title) { 'puppi::report' } - let(:node) { 'rspec.example42.com' } - let(:params) { - { 'enable' => 'true', - 'name' => 'get', - 'command' => 'echo', - 'priority' => '50', - 'project' => 'myapp', - } - } - - describe 'Test puppi report step file creation' do - it 'should create a puppi::report step file' do - should contain_file('/etc/puppi/projects/myapp/report/50-get').with_ensure('present') - end - it 'should populate correctly the puppi::report step file' do - should contain_file('/etc/puppi/projects/myapp/report/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") - end - end - -end diff --git a/spec/defines/puppi_report_spec.rb b/spec/defines/puppi_report_spec.rb deleted file mode 100644 index b37cb80..0000000 --- a/spec/defines/puppi_report_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' - -describe 'puppi::report' do - - let(:title) { 'puppi::report' } - let(:node) { 'rspec.example42.com' } - let(:params) { - { 'enable' => 'true', - 'name' => 'get', - 'command' => 'echo', - 'priority' => '50', - 'project' => 'myapp', - } - } - - describe 'Test puppi report step file creation' do - it 'should create a puppi::report step file' do - should contain_file('/etc/puppi/projects/myapp/report/50-get').with_ensure('present') - end - it 'should populate correctly the puppi::report step file' do - should contain_file('/etc/puppi/projects/myapp/report/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") - end - end - -end diff --git a/spec/defines/puppi_rollback_spec.rb b/spec/defines/puppi_rollback_spec.rb deleted file mode 100644 index c67e5c4..0000000 --- a/spec/defines/puppi_rollback_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' - -describe 'puppi::rollback' do - - let(:title) { 'puppi::rollback' } - let(:node) { 'rspec.example42.com' } - let(:params) { - { 'enable' => 'true', - 'name' => 'get', - 'command' => 'echo', - 'priority' => '50', - 'project' => 'myapp', - } - } - - describe 'Test puppi rollback step file creation' do - it 'should create a puppi::rollback step file' do - should contain_file('/etc/puppi/projects/myapp/rollback/50-get').with_ensure('present') - end - it 'should populate correctly the puppi::rollback step file' do - should contain_file('/etc/puppi/projects/myapp/rollback/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") - end - end - -end diff --git a/spec/defines/puppi_run_spec.rb b/spec/defines/puppi_run_spec.rb deleted file mode 100644 index 40aa274..0000000 --- a/spec/defines/puppi_run_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'spec_helper' - -describe 'puppi::run' do - - let(:title) { 'myapp' } - let(:node) { 'rspec.example42.com' } - let(:params) { - { - 'project' => 'myapp', - } - } - - describe 'Test puppi run exe creation' do - it { should contain_exec('Run_Puppi_myapp').with_command(/puppi deploy myapp/) } - end - -end diff --git a/spec/defines/puppi_todo_spec.rb b/spec/defines/puppi_todo_spec.rb deleted file mode 100644 index 249e151..0000000 --- a/spec/defines/puppi_todo_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper' - -describe 'puppi::todo' do - - let(:title) { 'mytodo' } - let(:node) { 'rspec.example42.com' } - let(:params) { - { 'notes' => 'Test Notes', - 'description' => 'Test Description', - 'check_command' => 'check_test', - 'run' => 'test', - } - } - - describe 'Test puppi todo file creation' do - it 'should create a puppi::todo file' do - should contain_file('/etc/puppi/todo/mytodo').with_ensure('present') - end - it 'should populate correctly the puppi::todo step file' do - should contain_file('/etc/puppi/todo/mytodo').with_content(/check_test/) - end - end - -end diff --git a/spec/defines/puppi_ze_spec.rb b/spec/defines/puppi_ze_spec.rb deleted file mode 100644 index e941b9a..0000000 --- a/spec/defines/puppi_ze_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'spec_helper' - -describe 'puppi::ze' do - - let(:title) { 'sample' } - let(:node) { 'rspec.example42.com' } - let(:params) { - { 'helper' => 'mytest', - 'variables' => { 'var1' => 'get', 'var2' => 'got' }, - 'name' => 'sample', - } - } - - describe 'Test puppi ze data file creation' do - it 'should create a puppi::ze step file' do - should contain_file('puppize_sample').with_ensure('present') - end - end - -end diff --git a/spec/defines/report_spec.rb b/spec/defines/report_spec.rb new file mode 100644 index 0000000..de9f16b --- /dev/null +++ b/spec/defines/report_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::report' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/rollback_spec.rb b/spec/defines/rollback_spec.rb new file mode 100644 index 0000000..bf90e75 --- /dev/null +++ b/spec/defines/rollback_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::rollback' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/run_spec.rb b/spec/defines/run_spec.rb new file mode 100644 index 0000000..e5104e4 --- /dev/null +++ b/spec/defines/run_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::run' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/runscript_spec.rb b/spec/defines/runscript_spec.rb new file mode 100644 index 0000000..cc44c10 --- /dev/null +++ b/spec/defines/runscript_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::runscript' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/todo_spec.rb b/spec/defines/todo_spec.rb new file mode 100644 index 0000000..5984063 --- /dev/null +++ b/spec/defines/todo_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::todo' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end diff --git a/spec/defines/ze_spec.rb b/spec/defines/ze_spec.rb new file mode 100644 index 0000000..768f521 --- /dev/null +++ b/spec/defines/ze_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'puppi::ze' do + let(:title) { 'namevar' } + let(:params) do + {} + end + + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile } + end + end +end From d3b29d03b952f07a8c1dc67ce2a4721f2c9c625f Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Tue, 24 Sep 2024 22:45:00 +0200 Subject: [PATCH 08/22] Working on spec testds --- .puppet-lint.rc | 2 ++ spec/classes/dependencies_spec.rb | 1 + spec/classes/extras_spec.rb | 1 + spec/classes/helpers_spec.rb | 1 + spec/classes/one_spec.rb | 1 + spec/classes/params_spec.rb | 1 + spec/classes/puppi_spec.rb | 1 + spec/classes/skel_spec.rb | 1 + spec/classes/two_spec.rb | 1 + spec/defines/check_spec.rb | 23 +++++++++++++++++++---- spec/defines/configure_spec.rb | 1 + spec/defines/deploy_spec.rb | 21 ++++++++++++++++++--- spec/defines/helper_spec.rb | 16 +++++++++++++--- spec/defines/info/instance_spec.rb | 1 + spec/defines/info/module_spec.rb | 1 + spec/defines/info/readme_spec.rb | 1 + spec/defines/info_spec.rb | 20 +++++++++++++++++--- spec/defines/initialize_spec.rb | 14 ++++++++++---- spec/defines/install_packages_spec.rb | 1 + spec/defines/log_spec.rb | 18 +++++++++++++++--- spec/defines/netinstall_spec.rb | 1 + spec/defines/project_spec.rb | 21 ++++++++++++++++++--- spec/defines/report_spec.rb | 21 ++++++++++++++++++--- spec/defines/rollback_spec.rb | 21 ++++++++++++++++++--- spec/defines/run_spec.rb | 13 ++++++++++--- spec/defines/runscript_spec.rb | 1 + spec/defines/todo_spec.rb | 20 +++++++++++++++++--- spec/defines/ze_spec.rb | 16 +++++++++++++--- 28 files changed, 203 insertions(+), 38 deletions(-) diff --git a/.puppet-lint.rc b/.puppet-lint.rc index cc96ece..cb0859c 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1 +1,3 @@ --relative +--no-parameter_documentation +--no-params_empty_string diff --git a/spec/classes/dependencies_spec.rb b/spec/classes/dependencies_spec.rb index 0e0b0e9..625b88c 100644 --- a/spec/classes/dependencies_spec.rb +++ b/spec/classes/dependencies_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' describe 'puppi::dependencies' do + let(:node) { 'rspec.example42.com' } on_supported_os.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/classes/extras_spec.rb b/spec/classes/extras_spec.rb index c386a0b..07e2f05 100644 --- a/spec/classes/extras_spec.rb +++ b/spec/classes/extras_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' describe 'puppi::extras' do + let(:node) { 'rspec.example42.com' } on_supported_os.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/classes/helpers_spec.rb b/spec/classes/helpers_spec.rb index 5918cef..ade512f 100644 --- a/spec/classes/helpers_spec.rb +++ b/spec/classes/helpers_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' describe 'puppi::helpers' do + let(:node) { 'rspec.example42.com' } on_supported_os.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/classes/one_spec.rb b/spec/classes/one_spec.rb index 29a6225..9679ddf 100644 --- a/spec/classes/one_spec.rb +++ b/spec/classes/one_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' describe 'puppi::one' do + let(:node) { 'rspec.example42.com' } on_supported_os.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb index 64a9ea6..f561bbd 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' describe 'puppi::params' do + let(:node) { 'rspec.example42.com' } on_supported_os.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/classes/puppi_spec.rb b/spec/classes/puppi_spec.rb index e049524..f944595 100644 --- a/spec/classes/puppi_spec.rb +++ b/spec/classes/puppi_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' describe 'puppi' do + let(:node) { 'rspec.example42.com' } on_supported_os.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/classes/skel_spec.rb b/spec/classes/skel_spec.rb index d96180a..34d13a9 100644 --- a/spec/classes/skel_spec.rb +++ b/spec/classes/skel_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' describe 'puppi::skel' do + let(:node) { 'rspec.example42.com' } on_supported_os.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/classes/two_spec.rb b/spec/classes/two_spec.rb index 1a824c9..121f84e 100644 --- a/spec/classes/two_spec.rb +++ b/spec/classes/two_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' describe 'puppi::two' do + let(:node) { 'rspec.example42.com' } on_supported_os.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/check_spec.rb b/spec/defines/check_spec.rb index 4478e6d..f9c4a86 100644 --- a/spec/defines/check_spec.rb +++ b/spec/defines/check_spec.rb @@ -3,11 +3,26 @@ require 'spec_helper' describe 'puppi::check' do - let(:title) { 'namevar' } - let(:params) do - {} - end + let(:title) { 'puppi::check' } + let(:node) { 'rspec.example42.com' } + let(:params) { + { 'enable' => 'true', + 'name' => 'get', + 'command' => 'echo', + 'priority' => '50', + 'project' => 'myapp', + } + } + describe 'Test puppi check step file creation' do + it 'should create a puppi::check step file' do + should contain_file('Puppi_check_myapp_50_get').with_ensure('present') + end + it 'should populate correctly the puppi::check step file' do + should contain_file('Puppi_check_myapp_50_get').with_content(/\/usr\/lib64\/nagios\/plugins\/echo/) + end + end + on_supported_os.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/configure_spec.rb b/spec/defines/configure_spec.rb index fbac888..c7e2952 100644 --- a/spec/defines/configure_spec.rb +++ b/spec/defines/configure_spec.rb @@ -4,6 +4,7 @@ describe 'puppi::configure' do let(:title) { 'namevar' } + let(:node) { 'rspec.example42.com' } let(:params) do {} end diff --git a/spec/defines/deploy_spec.rb b/spec/defines/deploy_spec.rb index da68180..3166c5d 100644 --- a/spec/defines/deploy_spec.rb +++ b/spec/defines/deploy_spec.rb @@ -3,9 +3,24 @@ require 'spec_helper' describe 'puppi::deploy' do - let(:title) { 'namevar' } - let(:params) do - {} + let(:title) { 'puppi::deploy' } + let(:node) { 'rspec.example42.com' } + let(:params) { + { 'enable' => 'true', + 'name' => 'get', + 'command' => 'echo', + 'priority' => '50', + 'project' => 'myapp', + } + } + + describe 'Test puppi deploy step file creation' do + it 'should create a puppi::deploy step file' do + should contain_file('/etc/puppi/projects/myapp/deploy/50-get').with_ensure('present') + end + it 'should populate correctly the puppi::deploy step file' do + should contain_file('/etc/puppi/projects/myapp/deploy/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") + end end on_supported_os.each do |os, os_facts| diff --git a/spec/defines/helper_spec.rb b/spec/defines/helper_spec.rb index 024457e..4c95220 100644 --- a/spec/defines/helper_spec.rb +++ b/spec/defines/helper_spec.rb @@ -3,9 +3,19 @@ require 'spec_helper' describe 'puppi::helper' do - let(:title) { 'namevar' } - let(:params) do - {} + let(:title) { 'spec' } + let(:node) { 'rspec.example42.com' } + let(:params) { + { 'template' => 'puppi/helpers/standard.yml.erb' } + } + + describe 'Test puppi helper file creation' do + it 'should create a puppi helper file' do + should contain_file('puppi_helper_spec').with_ensure('present') + end + it 'should populate correctly the helper file' do + should contain_file('puppi_helper_spec').with_content(/info/) + end end on_supported_os.each do |os, os_facts| diff --git a/spec/defines/info/instance_spec.rb b/spec/defines/info/instance_spec.rb index acf626a..3b26d45 100644 --- a/spec/defines/info/instance_spec.rb +++ b/spec/defines/info/instance_spec.rb @@ -4,6 +4,7 @@ describe 'puppi::info::instance' do let(:title) { 'namevar' } + let(:node) { 'rspec.example42.com' } let(:params) do {} end diff --git a/spec/defines/info/module_spec.rb b/spec/defines/info/module_spec.rb index d67447d..f8172a9 100644 --- a/spec/defines/info/module_spec.rb +++ b/spec/defines/info/module_spec.rb @@ -4,6 +4,7 @@ describe 'puppi::info::module' do let(:title) { 'namevar' } + let(:node) { 'rspec.example42.com' } let(:params) do {} end diff --git a/spec/defines/info/readme_spec.rb b/spec/defines/info/readme_spec.rb index b8088e0..d4b58e9 100644 --- a/spec/defines/info/readme_spec.rb +++ b/spec/defines/info/readme_spec.rb @@ -4,6 +4,7 @@ describe 'puppi::info::readme' do let(:title) { 'namevar' } + let(:node) { 'rspec.example42.com' } let(:params) do {} end diff --git a/spec/defines/info_spec.rb b/spec/defines/info_spec.rb index 9f1f923..3b16e5e 100644 --- a/spec/defines/info_spec.rb +++ b/spec/defines/info_spec.rb @@ -3,9 +3,23 @@ require 'spec_helper' describe 'puppi::info' do - let(:title) { 'namevar' } - let(:params) do - {} + let(:title) { 'puppi::info' } + let(:node) { 'rspec.example42.com' } + let(:params) { + { 'name' => 'sample', + 'description' => 'Sample Info', + 'templatefile' => 'puppi/info.erb', + 'run' => 'myownscript', + } + } + + describe 'Test puppi info step file creation' do + it 'should create a puppi::info step file' do + should contain_file('/etc/puppi/info/sample').with_ensure('present') + end + it 'should populate correctly the puppi::info step file' do + should contain_file('/etc/puppi/info/sample').with_content(/myownscript/) + end end on_supported_os.each do |os, os_facts| diff --git a/spec/defines/initialize_spec.rb b/spec/defines/initialize_spec.rb index e6e983b..8c6a042 100644 --- a/spec/defines/initialize_spec.rb +++ b/spec/defines/initialize_spec.rb @@ -3,10 +3,16 @@ require 'spec_helper' describe 'puppi::initialize' do - let(:title) { 'namevar' } - let(:params) do - {} - end + let(:title) { 'puppi::initialize' } + let(:node) { 'rspec.example42.com' } + let(:params) { + { 'enable' => 'true', + 'name' => 'get', + 'command' => 'echo', + 'priority' => '50', + 'project' => 'myapp', + } + } on_supported_os.each do |os, os_facts| context "on #{os}" do diff --git a/spec/defines/install_packages_spec.rb b/spec/defines/install_packages_spec.rb index deb2939..c867ea1 100644 --- a/spec/defines/install_packages_spec.rb +++ b/spec/defines/install_packages_spec.rb @@ -4,6 +4,7 @@ describe 'puppi::install_packages' do let(:title) { 'namevar' } + let(:node) { 'rspec.example42.com' } let(:params) do {} end diff --git a/spec/defines/log_spec.rb b/spec/defines/log_spec.rb index 295f8e5..7477287 100644 --- a/spec/defines/log_spec.rb +++ b/spec/defines/log_spec.rb @@ -3,9 +3,21 @@ require 'spec_helper' describe 'puppi::log' do - let(:title) { 'namevar' } - let(:params) do - {} + let(:title) { 'mylog' } + let(:node) { 'rspec.example42.com' } + let(:params) { + { 'log' => '/var/log/mylog.log', + 'description' => 'My Log', + } + } + + describe 'Test puppi log file creation' do + it 'should create a puppi::log file' do + should contain_file('/etc/puppi/logs/mylog').with_ensure('present') + end + it 'should populate correctly the puppi::log step file' do + should contain_file('/etc/puppi/logs/mylog').with_content(/mylog.log/) + end end on_supported_os.each do |os, os_facts| diff --git a/spec/defines/netinstall_spec.rb b/spec/defines/netinstall_spec.rb index 7730112..49d3206 100644 --- a/spec/defines/netinstall_spec.rb +++ b/spec/defines/netinstall_spec.rb @@ -4,6 +4,7 @@ describe 'puppi::netinstall' do let(:title) { 'namevar' } + let(:node) { 'rspec.example42.com' } let(:params) do {} end diff --git a/spec/defines/project_spec.rb b/spec/defines/project_spec.rb index 7b5110c..836138c 100644 --- a/spec/defines/project_spec.rb +++ b/spec/defines/project_spec.rb @@ -3,9 +3,24 @@ require 'spec_helper' describe 'puppi::project' do - let(:title) { 'namevar' } - let(:params) do - {} + let(:title) { 'puppi::project' } + let(:node) { 'rspec.example42.com' } + let(:params) { + { 'enable' => 'true', + 'name' => 'get', + 'command' => 'echo', + 'priority' => '50', + 'project' => 'myapp', + } + } + + describe 'Test puppi report step file creation' do + it 'should create a puppi::report step file' do + should contain_file('/etc/puppi/projects/myapp/report/50-get').with_ensure('present') + end + it 'should populate correctly the puppi::report step file' do + should contain_file('/etc/puppi/projects/myapp/report/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") + end end on_supported_os.each do |os, os_facts| diff --git a/spec/defines/report_spec.rb b/spec/defines/report_spec.rb index de9f16b..a00dd17 100644 --- a/spec/defines/report_spec.rb +++ b/spec/defines/report_spec.rb @@ -3,9 +3,24 @@ require 'spec_helper' describe 'puppi::report' do - let(:title) { 'namevar' } - let(:params) do - {} + let(:title) { 'puppi::report' } + let(:node) { 'rspec.example42.com' } + let(:params) { + { 'enable' => 'true', + 'name' => 'get', + 'command' => 'echo', + 'priority' => '50', + 'project' => 'myapp', + } + } + + describe 'Test puppi report step file creation' do + it 'should create a puppi::report step file' do + should contain_file('/etc/puppi/projects/myapp/report/50-get').with_ensure('present') + end + it 'should populate correctly the puppi::report step file' do + should contain_file('/etc/puppi/projects/myapp/report/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") + end end on_supported_os.each do |os, os_facts| diff --git a/spec/defines/rollback_spec.rb b/spec/defines/rollback_spec.rb index bf90e75..e84d8c2 100644 --- a/spec/defines/rollback_spec.rb +++ b/spec/defines/rollback_spec.rb @@ -3,9 +3,24 @@ require 'spec_helper' describe 'puppi::rollback' do - let(:title) { 'namevar' } - let(:params) do - {} + let(:title) { 'puppi::rollback' } + let(:node) { 'rspec.example42.com' } + let(:params) { + { 'enable' => 'true', + 'name' => 'get', + 'command' => 'echo', + 'priority' => '50', + 'project' => 'myapp', + } + } + + describe 'Test puppi rollback step file creation' do + it 'should create a puppi::rollback step file' do + should contain_file('/etc/puppi/projects/myapp/rollback/50-get').with_ensure('present') + end + it 'should populate correctly the puppi::rollback step file' do + should contain_file('/etc/puppi/projects/myapp/rollback/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") + end end on_supported_os.each do |os, os_facts| diff --git a/spec/defines/run_spec.rb b/spec/defines/run_spec.rb index e5104e4..7bfb1c1 100644 --- a/spec/defines/run_spec.rb +++ b/spec/defines/run_spec.rb @@ -3,9 +3,16 @@ require 'spec_helper' describe 'puppi::run' do - let(:title) { 'namevar' } - let(:params) do - {} + let(:title) { 'myapp' } + let(:node) { 'rspec.example42.com' } + let(:params) { + { + 'project' => 'myapp', + } + } + + describe 'Test puppi run exe creation' do + it { should contain_exec('Run_Puppi_myapp').with_command(/puppi deploy myapp/) } end on_supported_os.each do |os, os_facts| diff --git a/spec/defines/runscript_spec.rb b/spec/defines/runscript_spec.rb index cc44c10..ce65e0e 100644 --- a/spec/defines/runscript_spec.rb +++ b/spec/defines/runscript_spec.rb @@ -4,6 +4,7 @@ describe 'puppi::runscript' do let(:title) { 'namevar' } + let(:node) { 'rspec.example42.com' } let(:params) do {} end diff --git a/spec/defines/todo_spec.rb b/spec/defines/todo_spec.rb index 5984063..8eb91f5 100644 --- a/spec/defines/todo_spec.rb +++ b/spec/defines/todo_spec.rb @@ -3,9 +3,23 @@ require 'spec_helper' describe 'puppi::todo' do - let(:title) { 'namevar' } - let(:params) do - {} + let(:title) { 'mytodo' } + let(:node) { 'rspec.example42.com' } + let(:params) { + { 'notes' => 'Test Notes', + 'description' => 'Test Description', + 'check_command' => 'check_test', + 'run' => 'test', + } + } + + describe 'Test puppi todo file creation' do + it 'should create a puppi::todo file' do + should contain_file('/etc/puppi/todo/mytodo').with_ensure('present') + end + it 'should populate correctly the puppi::todo step file' do + should contain_file('/etc/puppi/todo/mytodo').with_content(/check_test/) + end end on_supported_os.each do |os, os_facts| diff --git a/spec/defines/ze_spec.rb b/spec/defines/ze_spec.rb index 768f521..2aeea94 100644 --- a/spec/defines/ze_spec.rb +++ b/spec/defines/ze_spec.rb @@ -3,9 +3,19 @@ require 'spec_helper' describe 'puppi::ze' do - let(:title) { 'namevar' } - let(:params) do - {} + let(:title) { 'sample' } + let(:node) { 'rspec.example42.com' } + let(:params) { + { 'helper' => 'mytest', + 'variables' => { 'var1' => 'get', 'var2' => 'got' }, + 'name' => 'sample', + } + } + + describe 'Test puppi ze data file creation' do + it 'should create a puppi::ze step file' do + should contain_file('puppize_sample').with_ensure('present') + end end on_supported_os.each do |os, os_facts| From b172b14027b0996c80e85f95a4c62b930d9dfa6d Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Wed, 25 Sep 2024 08:26:31 +0200 Subject: [PATCH 09/22] spec refines --- spec/classes/dependencies_spec.rb | 3 ++- spec/classes/extras_spec.rb | 3 ++- spec/classes/helpers_spec.rb | 3 ++- spec/classes/mcollective/client_spec.rb | 2 +- spec/classes/mcollective/server_spec.rb | 2 +- spec/classes/one_spec.rb | 3 ++- spec/classes/params_spec.rb | 3 ++- spec/classes/puppi_spec.rb | 3 ++- spec/classes/skel_spec.rb | 3 ++- spec/classes/two_spec.rb | 3 ++- spec/defines/check_spec.rb | 3 ++- spec/defines/configure_spec.rb | 3 ++- spec/defines/deploy_spec.rb | 3 ++- spec/defines/helper_spec.rb | 3 ++- spec/defines/info/instance_spec.rb | 3 ++- spec/defines/info/module_spec.rb | 3 ++- spec/defines/info/readme_spec.rb | 3 ++- spec/defines/info_spec.rb | 3 ++- spec/defines/initialize_spec.rb | 3 ++- spec/defines/install_packages_spec.rb | 3 ++- spec/defines/log_spec.rb | 3 ++- spec/defines/netinstall_spec.rb | 3 ++- spec/defines/project/archive_spec.rb | 2 +- spec/defines/project/builder_spec.rb | 2 +- spec/defines/project/dir_spec.rb | 2 +- spec/defines/project/files_spec.rb | 2 +- spec/defines/project/git_spec.rb | 2 +- spec/defines/project/hg_spec.rb | 2 +- spec/defines/project/maven_spec.rb | 2 +- spec/defines/project/mysql_spec.rb | 2 +- spec/defines/project/service_spec.rb | 2 +- spec/defines/project/svn_spec.rb | 2 +- spec/defines/project/tar_spec.rb | 2 +- spec/defines/project/war_spec.rb | 2 +- spec/defines/project/y4maven_spec.rb | 2 +- spec/defines/project/yum_spec.rb | 2 +- spec/defines/project_spec.rb | 3 ++- spec/defines/report_spec.rb | 3 ++- spec/defines/rollback_spec.rb | 3 ++- spec/defines/run_spec.rb | 3 ++- spec/defines/runscript_spec.rb | 3 ++- spec/defines/todo_spec.rb | 3 ++- spec/defines/ze_spec.rb | 3 ++- 43 files changed, 70 insertions(+), 43 deletions(-) diff --git a/spec/classes/dependencies_spec.rb b/spec/classes/dependencies_spec.rb index 625b88c..b1eace5 100644 --- a/spec/classes/dependencies_spec.rb +++ b/spec/classes/dependencies_spec.rb @@ -4,7 +4,8 @@ describe 'puppi::dependencies' do let(:node) { 'rspec.example42.com' } - on_supported_os.each do |os, os_facts| + let(:pre_condition) { 'include puppi' } + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/classes/extras_spec.rb b/spec/classes/extras_spec.rb index 07e2f05..879bfe9 100644 --- a/spec/classes/extras_spec.rb +++ b/spec/classes/extras_spec.rb @@ -4,7 +4,8 @@ describe 'puppi::extras' do let(:node) { 'rspec.example42.com' } - on_supported_os.each do |os, os_facts| + let(:pre_condition) { 'include puppi' } + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/classes/helpers_spec.rb b/spec/classes/helpers_spec.rb index ade512f..7864bfc 100644 --- a/spec/classes/helpers_spec.rb +++ b/spec/classes/helpers_spec.rb @@ -4,7 +4,8 @@ describe 'puppi::helpers' do let(:node) { 'rspec.example42.com' } - on_supported_os.each do |os, os_facts| + let(:pre_condition) { 'include puppi' } + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/classes/mcollective/client_spec.rb b/spec/classes/mcollective/client_spec.rb index 59a6f64..d1c9a8b 100644 --- a/spec/classes/mcollective/client_spec.rb +++ b/spec/classes/mcollective/client_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe 'puppi::mcollective::client' do - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/classes/mcollective/server_spec.rb b/spec/classes/mcollective/server_spec.rb index 2c0b3d7..98184c0 100644 --- a/spec/classes/mcollective/server_spec.rb +++ b/spec/classes/mcollective/server_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe 'puppi::mcollective::server' do - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/classes/one_spec.rb b/spec/classes/one_spec.rb index 9679ddf..7a9348e 100644 --- a/spec/classes/one_spec.rb +++ b/spec/classes/one_spec.rb @@ -4,7 +4,8 @@ describe 'puppi::one' do let(:node) { 'rspec.example42.com' } - on_supported_os.each do |os, os_facts| + let(:pre_condition) { 'include puppi' } + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb index f561bbd..bc3799d 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -4,7 +4,8 @@ describe 'puppi::params' do let(:node) { 'rspec.example42.com' } - on_supported_os.each do |os, os_facts| + let(:pre_condition) { 'include puppi' } + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/classes/puppi_spec.rb b/spec/classes/puppi_spec.rb index f944595..aa7f459 100644 --- a/spec/classes/puppi_spec.rb +++ b/spec/classes/puppi_spec.rb @@ -4,7 +4,8 @@ describe 'puppi' do let(:node) { 'rspec.example42.com' } - on_supported_os.each do |os, os_facts| + let(:pre_condition) { 'include puppi' } + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/classes/skel_spec.rb b/spec/classes/skel_spec.rb index 34d13a9..230a235 100644 --- a/spec/classes/skel_spec.rb +++ b/spec/classes/skel_spec.rb @@ -4,7 +4,8 @@ describe 'puppi::skel' do let(:node) { 'rspec.example42.com' } - on_supported_os.each do |os, os_facts| + let(:pre_condition) { 'include puppi' } + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/classes/two_spec.rb b/spec/classes/two_spec.rb index 121f84e..99f72cc 100644 --- a/spec/classes/two_spec.rb +++ b/spec/classes/two_spec.rb @@ -4,7 +4,8 @@ describe 'puppi::two' do let(:node) { 'rspec.example42.com' } - on_supported_os.each do |os, os_facts| + let(:pre_condition) { 'include puppi' } + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/check_spec.rb b/spec/defines/check_spec.rb index f9c4a86..23674a1 100644 --- a/spec/defines/check_spec.rb +++ b/spec/defines/check_spec.rb @@ -5,6 +5,7 @@ describe 'puppi::check' do let(:title) { 'puppi::check' } let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } let(:params) { { 'enable' => 'true', 'name' => 'get', @@ -23,7 +24,7 @@ end end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/configure_spec.rb b/spec/defines/configure_spec.rb index c7e2952..fa1b5bd 100644 --- a/spec/defines/configure_spec.rb +++ b/spec/defines/configure_spec.rb @@ -5,11 +5,12 @@ describe 'puppi::configure' do let(:title) { 'namevar' } let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } let(:params) do {} end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/deploy_spec.rb b/spec/defines/deploy_spec.rb index 3166c5d..e323335 100644 --- a/spec/defines/deploy_spec.rb +++ b/spec/defines/deploy_spec.rb @@ -5,6 +5,7 @@ describe 'puppi::deploy' do let(:title) { 'puppi::deploy' } let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } let(:params) { { 'enable' => 'true', 'name' => 'get', @@ -23,7 +24,7 @@ end end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/helper_spec.rb b/spec/defines/helper_spec.rb index 4c95220..fb00346 100644 --- a/spec/defines/helper_spec.rb +++ b/spec/defines/helper_spec.rb @@ -5,6 +5,7 @@ describe 'puppi::helper' do let(:title) { 'spec' } let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } let(:params) { { 'template' => 'puppi/helpers/standard.yml.erb' } } @@ -18,7 +19,7 @@ end end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/info/instance_spec.rb b/spec/defines/info/instance_spec.rb index 3b26d45..e2e34dd 100644 --- a/spec/defines/info/instance_spec.rb +++ b/spec/defines/info/instance_spec.rb @@ -5,11 +5,12 @@ describe 'puppi::info::instance' do let(:title) { 'namevar' } let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } let(:params) do {} end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/info/module_spec.rb b/spec/defines/info/module_spec.rb index f8172a9..fbbf789 100644 --- a/spec/defines/info/module_spec.rb +++ b/spec/defines/info/module_spec.rb @@ -5,11 +5,12 @@ describe 'puppi::info::module' do let(:title) { 'namevar' } let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } let(:params) do {} end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/info/readme_spec.rb b/spec/defines/info/readme_spec.rb index d4b58e9..0156b55 100644 --- a/spec/defines/info/readme_spec.rb +++ b/spec/defines/info/readme_spec.rb @@ -5,11 +5,12 @@ describe 'puppi::info::readme' do let(:title) { 'namevar' } let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } let(:params) do {} end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/info_spec.rb b/spec/defines/info_spec.rb index 3b16e5e..c97442b 100644 --- a/spec/defines/info_spec.rb +++ b/spec/defines/info_spec.rb @@ -5,6 +5,7 @@ describe 'puppi::info' do let(:title) { 'puppi::info' } let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } let(:params) { { 'name' => 'sample', 'description' => 'Sample Info', @@ -22,7 +23,7 @@ end end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/initialize_spec.rb b/spec/defines/initialize_spec.rb index 8c6a042..74bb2f2 100644 --- a/spec/defines/initialize_spec.rb +++ b/spec/defines/initialize_spec.rb @@ -5,6 +5,7 @@ describe 'puppi::initialize' do let(:title) { 'puppi::initialize' } let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } let(:params) { { 'enable' => 'true', 'name' => 'get', @@ -14,7 +15,7 @@ } } - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/install_packages_spec.rb b/spec/defines/install_packages_spec.rb index c867ea1..e3805c5 100644 --- a/spec/defines/install_packages_spec.rb +++ b/spec/defines/install_packages_spec.rb @@ -5,11 +5,12 @@ describe 'puppi::install_packages' do let(:title) { 'namevar' } let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } let(:params) do {} end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/log_spec.rb b/spec/defines/log_spec.rb index 7477287..9af6fbc 100644 --- a/spec/defines/log_spec.rb +++ b/spec/defines/log_spec.rb @@ -5,6 +5,7 @@ describe 'puppi::log' do let(:title) { 'mylog' } let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } let(:params) { { 'log' => '/var/log/mylog.log', 'description' => 'My Log', @@ -20,7 +21,7 @@ end end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/netinstall_spec.rb b/spec/defines/netinstall_spec.rb index 49d3206..7f28a75 100644 --- a/spec/defines/netinstall_spec.rb +++ b/spec/defines/netinstall_spec.rb @@ -5,11 +5,12 @@ describe 'puppi::netinstall' do let(:title) { 'namevar' } let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } let(:params) do {} end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/project/archive_spec.rb b/spec/defines/project/archive_spec.rb index a8e5b63..4a7bff5 100644 --- a/spec/defines/project/archive_spec.rb +++ b/spec/defines/project/archive_spec.rb @@ -8,7 +8,7 @@ {} end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/project/builder_spec.rb b/spec/defines/project/builder_spec.rb index aa6cf19..e928a5b 100644 --- a/spec/defines/project/builder_spec.rb +++ b/spec/defines/project/builder_spec.rb @@ -8,7 +8,7 @@ {} end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/project/dir_spec.rb b/spec/defines/project/dir_spec.rb index 8a84651..c815989 100644 --- a/spec/defines/project/dir_spec.rb +++ b/spec/defines/project/dir_spec.rb @@ -8,7 +8,7 @@ {} end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/project/files_spec.rb b/spec/defines/project/files_spec.rb index 5483032..8dd2884 100644 --- a/spec/defines/project/files_spec.rb +++ b/spec/defines/project/files_spec.rb @@ -8,7 +8,7 @@ {} end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/project/git_spec.rb b/spec/defines/project/git_spec.rb index 96f5595..4c3ded8 100644 --- a/spec/defines/project/git_spec.rb +++ b/spec/defines/project/git_spec.rb @@ -8,7 +8,7 @@ {} end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/project/hg_spec.rb b/spec/defines/project/hg_spec.rb index 6a285ca..5d2f19e 100644 --- a/spec/defines/project/hg_spec.rb +++ b/spec/defines/project/hg_spec.rb @@ -8,7 +8,7 @@ {} end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/project/maven_spec.rb b/spec/defines/project/maven_spec.rb index b13e8de..cf2c09e 100644 --- a/spec/defines/project/maven_spec.rb +++ b/spec/defines/project/maven_spec.rb @@ -8,7 +8,7 @@ {} end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/project/mysql_spec.rb b/spec/defines/project/mysql_spec.rb index c3be39b..515a404 100644 --- a/spec/defines/project/mysql_spec.rb +++ b/spec/defines/project/mysql_spec.rb @@ -8,7 +8,7 @@ {} end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/project/service_spec.rb b/spec/defines/project/service_spec.rb index ed7163f..1e45c1c 100644 --- a/spec/defines/project/service_spec.rb +++ b/spec/defines/project/service_spec.rb @@ -8,7 +8,7 @@ {} end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/project/svn_spec.rb b/spec/defines/project/svn_spec.rb index 52d9d05..a01e1f7 100644 --- a/spec/defines/project/svn_spec.rb +++ b/spec/defines/project/svn_spec.rb @@ -8,7 +8,7 @@ {} end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/project/tar_spec.rb b/spec/defines/project/tar_spec.rb index 56e504a..642947e 100644 --- a/spec/defines/project/tar_spec.rb +++ b/spec/defines/project/tar_spec.rb @@ -8,7 +8,7 @@ {} end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/project/war_spec.rb b/spec/defines/project/war_spec.rb index c8a85a3..9341403 100644 --- a/spec/defines/project/war_spec.rb +++ b/spec/defines/project/war_spec.rb @@ -8,7 +8,7 @@ {} end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/project/y4maven_spec.rb b/spec/defines/project/y4maven_spec.rb index 3c271d1..8e4e9f0 100644 --- a/spec/defines/project/y4maven_spec.rb +++ b/spec/defines/project/y4maven_spec.rb @@ -8,7 +8,7 @@ {} end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/project/yum_spec.rb b/spec/defines/project/yum_spec.rb index dbbe7c7..147b9fc 100644 --- a/spec/defines/project/yum_spec.rb +++ b/spec/defines/project/yum_spec.rb @@ -8,7 +8,7 @@ {} end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/project_spec.rb b/spec/defines/project_spec.rb index 836138c..892577b 100644 --- a/spec/defines/project_spec.rb +++ b/spec/defines/project_spec.rb @@ -5,6 +5,7 @@ describe 'puppi::project' do let(:title) { 'puppi::project' } let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } let(:params) { { 'enable' => 'true', 'name' => 'get', @@ -23,7 +24,7 @@ end end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/report_spec.rb b/spec/defines/report_spec.rb index a00dd17..b4b8295 100644 --- a/spec/defines/report_spec.rb +++ b/spec/defines/report_spec.rb @@ -5,6 +5,7 @@ describe 'puppi::report' do let(:title) { 'puppi::report' } let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } let(:params) { { 'enable' => 'true', 'name' => 'get', @@ -23,7 +24,7 @@ end end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/rollback_spec.rb b/spec/defines/rollback_spec.rb index e84d8c2..59017ce 100644 --- a/spec/defines/rollback_spec.rb +++ b/spec/defines/rollback_spec.rb @@ -5,6 +5,7 @@ describe 'puppi::rollback' do let(:title) { 'puppi::rollback' } let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } let(:params) { { 'enable' => 'true', 'name' => 'get', @@ -23,7 +24,7 @@ end end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/run_spec.rb b/spec/defines/run_spec.rb index 7bfb1c1..5ef9bff 100644 --- a/spec/defines/run_spec.rb +++ b/spec/defines/run_spec.rb @@ -5,6 +5,7 @@ describe 'puppi::run' do let(:title) { 'myapp' } let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } let(:params) { { 'project' => 'myapp', @@ -15,7 +16,7 @@ it { should contain_exec('Run_Puppi_myapp').with_command(/puppi deploy myapp/) } end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/runscript_spec.rb b/spec/defines/runscript_spec.rb index ce65e0e..fcf1ff2 100644 --- a/spec/defines/runscript_spec.rb +++ b/spec/defines/runscript_spec.rb @@ -5,11 +5,12 @@ describe 'puppi::runscript' do let(:title) { 'namevar' } let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } let(:params) do {} end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/todo_spec.rb b/spec/defines/todo_spec.rb index 8eb91f5..b279aaf 100644 --- a/spec/defines/todo_spec.rb +++ b/spec/defines/todo_spec.rb @@ -5,6 +5,7 @@ describe 'puppi::todo' do let(:title) { 'mytodo' } let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } let(:params) { { 'notes' => 'Test Notes', 'description' => 'Test Description', @@ -22,7 +23,7 @@ end end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/defines/ze_spec.rb b/spec/defines/ze_spec.rb index 2aeea94..f6ce152 100644 --- a/spec/defines/ze_spec.rb +++ b/spec/defines/ze_spec.rb @@ -5,6 +5,7 @@ describe 'puppi::ze' do let(:title) { 'sample' } let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } let(:params) { { 'helper' => 'mytest', 'variables' => { 'var1' => 'get', 'var2' => 'got' }, @@ -18,7 +19,7 @@ end end - on_supported_os.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } From f64d4ae0d516628a664d59508d11c5011ec32069 Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Wed, 25 Sep 2024 08:54:19 +0200 Subject: [PATCH 10/22] Test data --- manifests/info.pp | 2 +- spec/classes/mcollective/client_spec.rb | 13 ------- spec/classes/mcollective/server_spec.rb | 13 ------- spec/classes/puppi_spec.rb2 | 17 ++++++++++ spec/defines/check_spec.rb | 45 ++++++++++++------------- spec/defines/configure_spec.rb | 13 ++++--- spec/defines/deploy_spec.rb | 41 +++++++++++----------- spec/defines/helper_spec.rb | 32 +++++++++--------- spec/defines/info_spec.rb | 40 +++++++++++----------- spec/defines/initialize_spec.rb | 24 ++++++------- spec/defines/install_packages_spec.rb | 14 ++++---- spec/defines/log_spec.rb | 35 ++++++++++--------- spec/defines/netinstall_spec.rb | 14 ++++---- spec/defines/project/archive_spec.rb | 9 +++-- spec/defines/project/builder_spec.rb | 10 ++++-- spec/defines/project/dir_spec.rb | 9 +++-- spec/defines/project/files_spec.rb | 10 ++++-- spec/defines/project/git_spec.rb | 9 +++-- spec/defines/project/hg_spec.rb | 9 +++-- spec/defines/project/maven_spec.rb | 9 +++-- spec/defines/project/mysql_spec.rb | 9 +++-- spec/defines/project/svn_spec.rb | 9 +++-- spec/defines/project/tar_spec.rb | 9 +++-- spec/defines/project/war_spec.rb | 9 +++-- spec/defines/project/y4maven_spec.rb | 9 +++-- spec/defines/project/yum_spec.rb | 8 +++-- spec/defines/project_spec.rb | 41 +++++++++++----------- spec/defines/report_spec.rb | 43 ++++++++++++----------- spec/defines/rollback_spec.rb | 41 +++++++++++----------- spec/defines/run_spec.rb | 25 +++++++------- spec/defines/runscript_spec.rb | 13 ++++--- spec/defines/todo_spec.rb | 41 +++++++++++----------- spec/defines/ze_spec.rb | 33 +++++++++--------- 33 files changed, 334 insertions(+), 324 deletions(-) delete mode 100644 spec/classes/mcollective/client_spec.rb delete mode 100644 spec/classes/mcollective/server_spec.rb create mode 100644 spec/classes/puppi_spec.rb2 diff --git a/manifests/info.pp b/manifests/info.pp index d7116b7..07b00f3 100644 --- a/manifests/info.pp +++ b/manifests/info.pp @@ -20,7 +20,7 @@ define puppi::info ( String $description = '', String $templatefile = 'puppi/info.erb', - String $run = '', + Variant[String,Array] $run = '', ) { require puppi require puppi::params diff --git a/spec/classes/mcollective/client_spec.rb b/spec/classes/mcollective/client_spec.rb deleted file mode 100644 index d1c9a8b..0000000 --- a/spec/classes/mcollective/client_spec.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'puppi::mcollective::client' do - on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| - context "on #{os}" do - let(:facts) { os_facts } - - it { is_expected.to compile.with_all_deps } - end - end -end diff --git a/spec/classes/mcollective/server_spec.rb b/spec/classes/mcollective/server_spec.rb deleted file mode 100644 index 98184c0..0000000 --- a/spec/classes/mcollective/server_spec.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'puppi::mcollective::server' do - on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| - context "on #{os}" do - let(:facts) { os_facts } - - it { is_expected.to compile.with_all_deps } - end - end -end diff --git a/spec/classes/puppi_spec.rb2 b/spec/classes/puppi_spec.rb2 new file mode 100644 index 0000000..903f593 --- /dev/null +++ b/spec/classes/puppi_spec.rb2 @@ -0,0 +1,17 @@ +require 'spec_helper' + +describe 'puppi' do + + let(:node) { 'rspec.example42.com' } + let(:node) { 'rspec.example42.com' } + let(:facts) { { :ipaddress => '10.42.42.42' } } + + describe 'Test standard installation' do + it { should contain_file('puppi').with_ensure('present') } + it { should contain_file('puppi.conf').with_ensure('present') } + it { should contain_file('puppi.scripts').with_ensure('present') } + it { should contain_file('puppi_basedir').with_ensure('directory') } + it { should contain_file('puppi_datadir').with_ensure('directory') } + end + +end diff --git a/spec/defines/check_spec.rb b/spec/defines/check_spec.rb index 23674a1..fc9c5d0 100644 --- a/spec/defines/check_spec.rb +++ b/spec/defines/check_spec.rb @@ -3,32 +3,31 @@ require 'spec_helper' describe 'puppi::check' do - let(:title) { 'puppi::check' } - let(:node) { 'rspec.example42.com' } - let(:pre_condition) { 'include puppi' } - let(:params) { - { 'enable' => 'true', - 'name' => 'get', - 'command' => 'echo', - 'priority' => '50', - 'project' => 'myapp', - } - } - describe 'Test puppi check step file creation' do - it 'should create a puppi::check step file' do - should contain_file('Puppi_check_myapp_50_get').with_ensure('present') - end - it 'should populate correctly the puppi::check step file' do - should contain_file('Puppi_check_myapp_50_get').with_content(/\/usr\/lib64\/nagios\/plugins\/echo/) - end - end - - on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| + on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do - let(:facts) { os_facts } - + let(:facts) { os_facts } + let(:title) { 'puppi::check' } + let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } + let(:params) { + { 'enable' => 'true', + 'name' => 'get', + 'command' => 'echo', + 'priority' => '50', + 'project' => 'myapp', + } + } it { is_expected.to compile } + describe 'Test puppi check step file creation' do + it 'should create a puppi::check step file' do + should contain_file('Puppi_check_myapp_50_get').with_ensure('present') + end + it 'should populate correctly the puppi::check step file' do + should contain_file('Puppi_check_myapp_50_get').with_content(/\/usr\/lib64\/nagios\/plugins\/echo/) + end + end + end end end diff --git a/spec/defines/configure_spec.rb b/spec/defines/configure_spec.rb index fa1b5bd..80959d2 100644 --- a/spec/defines/configure_spec.rb +++ b/spec/defines/configure_spec.rb @@ -3,17 +3,16 @@ require 'spec_helper' describe 'puppi::configure' do - let(:title) { 'namevar' } - let(:node) { 'rspec.example42.com' } - let(:pre_condition) { 'include puppi' } - let(:params) do - {} - end on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } - + let(:title) { 'namevar' } + let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } + let(:params) do + {} + end it { is_expected.to compile } end end diff --git a/spec/defines/deploy_spec.rb b/spec/defines/deploy_spec.rb index e323335..78e0117 100644 --- a/spec/defines/deploy_spec.rb +++ b/spec/defines/deploy_spec.rb @@ -3,30 +3,29 @@ require 'spec_helper' describe 'puppi::deploy' do - let(:title) { 'puppi::deploy' } - let(:node) { 'rspec.example42.com' } - let(:pre_condition) { 'include puppi' } - let(:params) { - { 'enable' => 'true', - 'name' => 'get', - 'command' => 'echo', - 'priority' => '50', - 'project' => 'myapp', - } - } - - describe 'Test puppi deploy step file creation' do - it 'should create a puppi::deploy step file' do - should contain_file('/etc/puppi/projects/myapp/deploy/50-get').with_ensure('present') - end - it 'should populate correctly the puppi::deploy step file' do - should contain_file('/etc/puppi/projects/myapp/deploy/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") - end - end - on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } + let(:title) { 'puppi::deploy' } + let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } + let(:params) { + { 'enable' => 'true', + 'name' => 'get', + 'command' => 'echo', + 'priority' => '50', + 'project' => 'myapp', + } + } + + describe 'Test puppi deploy step file creation' do + it 'should create a puppi::deploy step file' do + should contain_file('/etc/puppi/projects/myapp/deploy/50-get').with_ensure('present') + end + it 'should populate correctly the puppi::deploy step file' do + should contain_file('/etc/puppi/projects/myapp/deploy/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") + end + end it { is_expected.to compile } end diff --git a/spec/defines/helper_spec.rb b/spec/defines/helper_spec.rb index fb00346..2573c49 100644 --- a/spec/defines/helper_spec.rb +++ b/spec/defines/helper_spec.rb @@ -3,26 +3,24 @@ require 'spec_helper' describe 'puppi::helper' do - let(:title) { 'spec' } - let(:node) { 'rspec.example42.com' } - let(:pre_condition) { 'include puppi' } - let(:params) { - { 'template' => 'puppi/helpers/standard.yml.erb' } - } - - describe 'Test puppi helper file creation' do - it 'should create a puppi helper file' do - should contain_file('puppi_helper_spec').with_ensure('present') - end - it 'should populate correctly the helper file' do - should contain_file('puppi_helper_spec').with_content(/info/) - end - end - on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } - + let(:title) { 'spec' } + let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } + let(:params) { + { 'template' => 'puppi/helpers/standard.yml.erb' } + } + + describe 'Test puppi helper file creation' do + it 'should create a puppi helper file' do + should contain_file('puppi_helper_spec').with_ensure('present') + end + it 'should populate correctly the helper file' do + should contain_file('puppi_helper_spec').with_content(/info/) + end + end it { is_expected.to compile } end end diff --git a/spec/defines/info_spec.rb b/spec/defines/info_spec.rb index c97442b..87587ae 100644 --- a/spec/defines/info_spec.rb +++ b/spec/defines/info_spec.rb @@ -3,30 +3,28 @@ require 'spec_helper' describe 'puppi::info' do - let(:title) { 'puppi::info' } - let(:node) { 'rspec.example42.com' } - let(:pre_condition) { 'include puppi' } - let(:params) { - { 'name' => 'sample', - 'description' => 'Sample Info', - 'templatefile' => 'puppi/info.erb', - 'run' => 'myownscript', - } - } - - describe 'Test puppi info step file creation' do - it 'should create a puppi::info step file' do - should contain_file('/etc/puppi/info/sample').with_ensure('present') - end - it 'should populate correctly the puppi::info step file' do - should contain_file('/etc/puppi/info/sample').with_content(/myownscript/) - end - end - on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } - + let(:title) { 'puppi::info' } + let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } + let(:params) { + { 'name' => 'sample', + 'description' => 'Sample Info', + 'templatefile' => 'puppi/info.erb', + 'run' => 'myownscript', + } + } + + describe 'Test puppi info step file creation' do + it 'should create a puppi::info step file' do + should contain_file('/etc/puppi/info/sample').with_ensure('present') + end + it 'should populate correctly the puppi::info step file' do + should contain_file('/etc/puppi/info/sample').with_content(/myownscript/) + end + end it { is_expected.to compile } end end diff --git a/spec/defines/initialize_spec.rb b/spec/defines/initialize_spec.rb index 74bb2f2..50ecdba 100644 --- a/spec/defines/initialize_spec.rb +++ b/spec/defines/initialize_spec.rb @@ -3,22 +3,20 @@ require 'spec_helper' describe 'puppi::initialize' do - let(:title) { 'puppi::initialize' } - let(:node) { 'rspec.example42.com' } - let(:pre_condition) { 'include puppi' } - let(:params) { - { 'enable' => 'true', - 'name' => 'get', - 'command' => 'echo', - 'priority' => '50', - 'project' => 'myapp', - } - } - on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } - + let(:title) { 'puppi::initialize' } + let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } + let(:params) { + { 'enable' => 'true', + 'name' => 'get', + 'command' => 'echo', + 'priority' => '50', + 'project' => 'myapp', + } + } it { is_expected.to compile } end end diff --git a/spec/defines/install_packages_spec.rb b/spec/defines/install_packages_spec.rb index e3805c5..b59b248 100644 --- a/spec/defines/install_packages_spec.rb +++ b/spec/defines/install_packages_spec.rb @@ -3,17 +3,15 @@ require 'spec_helper' describe 'puppi::install_packages' do - let(:title) { 'namevar' } - let(:node) { 'rspec.example42.com' } - let(:pre_condition) { 'include puppi' } - let(:params) do - {} - end - on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } - + let(:title) { 'namevar' } + let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } + let(:params) do + {} + end it { is_expected.to compile } end end diff --git a/spec/defines/log_spec.rb b/spec/defines/log_spec.rb index 9af6fbc..cbfb0f6 100644 --- a/spec/defines/log_spec.rb +++ b/spec/defines/log_spec.rb @@ -3,27 +3,26 @@ require 'spec_helper' describe 'puppi::log' do - let(:title) { 'mylog' } - let(:node) { 'rspec.example42.com' } - let(:pre_condition) { 'include puppi' } - let(:params) { - { 'log' => '/var/log/mylog.log', - 'description' => 'My Log', - } - } - - describe 'Test puppi log file creation' do - it 'should create a puppi::log file' do - should contain_file('/etc/puppi/logs/mylog').with_ensure('present') - end - it 'should populate correctly the puppi::log step file' do - should contain_file('/etc/puppi/logs/mylog').with_content(/mylog.log/) - end - end - on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } + let(:title) { 'mylog' } + let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } + let(:params) { + { 'log' => '/var/log/mylog.log', + 'description' => 'My Log', + } + } + + describe 'Test puppi log file creation' do + it 'should create a puppi::log file' do + should contain_file('/etc/puppi/logs/mylog').with_ensure('present') + end + it 'should populate correctly the puppi::log step file' do + should contain_file('/etc/puppi/logs/mylog').with_content(/mylog.log/) + end + end it { is_expected.to compile } end diff --git a/spec/defines/netinstall_spec.rb b/spec/defines/netinstall_spec.rb index 7f28a75..5c33444 100644 --- a/spec/defines/netinstall_spec.rb +++ b/spec/defines/netinstall_spec.rb @@ -3,17 +3,15 @@ require 'spec_helper' describe 'puppi::netinstall' do - let(:title) { 'namevar' } - let(:node) { 'rspec.example42.com' } - let(:pre_condition) { 'include puppi' } - let(:params) do - {} - end - on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } - + let(:title) { 'namevar' } + let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } + let(:params) do + {} + end it { is_expected.to compile } end end diff --git a/spec/defines/project/archive_spec.rb b/spec/defines/project/archive_spec.rb index 4a7bff5..f551a3e 100644 --- a/spec/defines/project/archive_spec.rb +++ b/spec/defines/project/archive_spec.rb @@ -4,9 +4,12 @@ describe 'puppi::project::archive' do let(:title) { 'namevar' } - let(:params) do - {} - end + let(:params) { + { + 'source' => 'test', + 'deploy_root' => '/tmp', + } + } on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do diff --git a/spec/defines/project/builder_spec.rb b/spec/defines/project/builder_spec.rb index e928a5b..497cc7f 100644 --- a/spec/defines/project/builder_spec.rb +++ b/spec/defines/project/builder_spec.rb @@ -4,9 +4,13 @@ describe 'puppi::project::builder' do let(:title) { 'namevar' } - let(:params) do - {} - end + let(:params) { + { + 'source' => 'test', + 'source_type' => 'git', + 'deploy_root' => '/tmp', + } + } on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do diff --git a/spec/defines/project/dir_spec.rb b/spec/defines/project/dir_spec.rb index c815989..650b2d6 100644 --- a/spec/defines/project/dir_spec.rb +++ b/spec/defines/project/dir_spec.rb @@ -4,9 +4,12 @@ describe 'puppi::project::dir' do let(:title) { 'namevar' } - let(:params) do - {} - end + let(:params) { + { + 'source' => 'test', + 'deploy_root' => '/tmp', + } + } on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do diff --git a/spec/defines/project/files_spec.rb b/spec/defines/project/files_spec.rb index 8dd2884..f0ae224 100644 --- a/spec/defines/project/files_spec.rb +++ b/spec/defines/project/files_spec.rb @@ -4,9 +4,13 @@ describe 'puppi::project::files' do let(:title) { 'namevar' } - let(:params) do - {} - end + let(:params) { + { + 'source' => 'test', + 'deploy_root' => '/tmp', + 'source_baseurl' => 'http://example.com', + } + } on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do diff --git a/spec/defines/project/git_spec.rb b/spec/defines/project/git_spec.rb index 4c3ded8..c38767c 100644 --- a/spec/defines/project/git_spec.rb +++ b/spec/defines/project/git_spec.rb @@ -4,9 +4,12 @@ describe 'puppi::project::git' do let(:title) { 'namevar' } - let(:params) do - {} - end + let(:params) { + { + 'source' => 'test', + 'deploy_root' => '/tmp', + } + } on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do diff --git a/spec/defines/project/hg_spec.rb b/spec/defines/project/hg_spec.rb index 5d2f19e..2bf0524 100644 --- a/spec/defines/project/hg_spec.rb +++ b/spec/defines/project/hg_spec.rb @@ -4,9 +4,12 @@ describe 'puppi::project::hg' do let(:title) { 'namevar' } - let(:params) do - {} - end + let(:params) { + { + 'source' => 'test', + 'deploy_root' => '/tmp', + } + } on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do diff --git a/spec/defines/project/maven_spec.rb b/spec/defines/project/maven_spec.rb index cf2c09e..ade4e15 100644 --- a/spec/defines/project/maven_spec.rb +++ b/spec/defines/project/maven_spec.rb @@ -4,9 +4,12 @@ describe 'puppi::project::maven' do let(:title) { 'namevar' } - let(:params) do - {} - end + let(:params) { + { + 'source' => 'test', + 'deploy_root' => '/tmp', + } + } on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do diff --git a/spec/defines/project/mysql_spec.rb b/spec/defines/project/mysql_spec.rb index 515a404..690e98f 100644 --- a/spec/defines/project/mysql_spec.rb +++ b/spec/defines/project/mysql_spec.rb @@ -4,9 +4,12 @@ describe 'puppi::project::mysql' do let(:title) { 'namevar' } - let(:params) do - {} - end + let(:params) { + { + 'source' => 'test', + 'mysql_database' => 'tmp', + } + } on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do diff --git a/spec/defines/project/svn_spec.rb b/spec/defines/project/svn_spec.rb index a01e1f7..0b28515 100644 --- a/spec/defines/project/svn_spec.rb +++ b/spec/defines/project/svn_spec.rb @@ -4,9 +4,12 @@ describe 'puppi::project::svn' do let(:title) { 'namevar' } - let(:params) do - {} - end + let(:params) { + { + 'source' => 'test', + 'deploy_root' => '/tmp', + } + } on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do diff --git a/spec/defines/project/tar_spec.rb b/spec/defines/project/tar_spec.rb index 642947e..242e524 100644 --- a/spec/defines/project/tar_spec.rb +++ b/spec/defines/project/tar_spec.rb @@ -4,9 +4,12 @@ describe 'puppi::project::tar' do let(:title) { 'namevar' } - let(:params) do - {} - end + let(:params) { + { + 'source' => 'test', + 'deploy_root' => '/tmp', + } + } on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do diff --git a/spec/defines/project/war_spec.rb b/spec/defines/project/war_spec.rb index 9341403..ecd2c24 100644 --- a/spec/defines/project/war_spec.rb +++ b/spec/defines/project/war_spec.rb @@ -4,9 +4,12 @@ describe 'puppi::project::war' do let(:title) { 'namevar' } - let(:params) do - {} - end + let(:params) { + { + 'source' => 'test', + 'deploy_root' => '/tmp', + } + } on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do diff --git a/spec/defines/project/y4maven_spec.rb b/spec/defines/project/y4maven_spec.rb index 8e4e9f0..19113a5 100644 --- a/spec/defines/project/y4maven_spec.rb +++ b/spec/defines/project/y4maven_spec.rb @@ -4,9 +4,12 @@ describe 'puppi::project::y4maven' do let(:title) { 'namevar' } - let(:params) do - {} - end + let(:params) { + { + 'source' => 'test', + 'deploy_root' => '/tmp', + } + } on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do diff --git a/spec/defines/project/yum_spec.rb b/spec/defines/project/yum_spec.rb index 147b9fc..b4e3a73 100644 --- a/spec/defines/project/yum_spec.rb +++ b/spec/defines/project/yum_spec.rb @@ -4,9 +4,11 @@ describe 'puppi::project::yum' do let(:title) { 'namevar' } - let(:params) do - {} - end + let(:params) { + { + 'rpm' => 'test', + } + } on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do diff --git a/spec/defines/project_spec.rb b/spec/defines/project_spec.rb index 892577b..f168e5a 100644 --- a/spec/defines/project_spec.rb +++ b/spec/defines/project_spec.rb @@ -3,30 +3,29 @@ require 'spec_helper' describe 'puppi::project' do - let(:title) { 'puppi::project' } - let(:node) { 'rspec.example42.com' } - let(:pre_condition) { 'include puppi' } - let(:params) { - { 'enable' => 'true', - 'name' => 'get', - 'command' => 'echo', - 'priority' => '50', - 'project' => 'myapp', - } - } - - describe 'Test puppi report step file creation' do - it 'should create a puppi::report step file' do - should contain_file('/etc/puppi/projects/myapp/report/50-get').with_ensure('present') - end - it 'should populate correctly the puppi::report step file' do - should contain_file('/etc/puppi/projects/myapp/report/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") - end - end - on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } + let(:title) { 'puppi::project' } + let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } + let(:params) { + { 'enable' => 'true', + 'name' => 'get', + 'command' => 'echo', + 'priority' => '50', + 'project' => 'myapp', + } + } + + describe 'Test puppi report step file creation' do + it 'should create a puppi::report step file' do + should contain_file('/etc/puppi/projects/myapp/report/50-get').with_ensure('present') + end + it 'should populate correctly the puppi::report step file' do + should contain_file('/etc/puppi/projects/myapp/report/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") + end + end it { is_expected.to compile } end diff --git a/spec/defines/report_spec.rb b/spec/defines/report_spec.rb index b4b8295..e0cf299 100644 --- a/spec/defines/report_spec.rb +++ b/spec/defines/report_spec.rb @@ -3,31 +3,30 @@ require 'spec_helper' describe 'puppi::report' do - let(:title) { 'puppi::report' } - let(:node) { 'rspec.example42.com' } - let(:pre_condition) { 'include puppi' } - let(:params) { - { 'enable' => 'true', - 'name' => 'get', - 'command' => 'echo', - 'priority' => '50', - 'project' => 'myapp', - } - } - - describe 'Test puppi report step file creation' do - it 'should create a puppi::report step file' do - should contain_file('/etc/puppi/projects/myapp/report/50-get').with_ensure('present') - end - it 'should populate correctly the puppi::report step file' do - should contain_file('/etc/puppi/projects/myapp/report/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") - end - end - on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } - + let(:title) { 'puppi::report' } + let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } + let(:params) { + { 'enable' => 'true', + 'name' => 'get', + 'command' => 'echo', + 'priority' => '50', + 'project' => 'myapp', + } + } + + describe 'Test puppi report step file creation' do + it 'should create a puppi::report step file' do + should contain_file('/etc/puppi/projects/myapp/report/50-get').with_ensure('present') + end + it 'should populate correctly the puppi::report step file' do + should contain_file('/etc/puppi/projects/myapp/report/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") + end + end + it { is_expected.to compile } end end diff --git a/spec/defines/rollback_spec.rb b/spec/defines/rollback_spec.rb index 59017ce..617a648 100644 --- a/spec/defines/rollback_spec.rb +++ b/spec/defines/rollback_spec.rb @@ -3,30 +3,29 @@ require 'spec_helper' describe 'puppi::rollback' do - let(:title) { 'puppi::rollback' } - let(:node) { 'rspec.example42.com' } - let(:pre_condition) { 'include puppi' } - let(:params) { - { 'enable' => 'true', - 'name' => 'get', - 'command' => 'echo', - 'priority' => '50', - 'project' => 'myapp', - } - } - - describe 'Test puppi rollback step file creation' do - it 'should create a puppi::rollback step file' do - should contain_file('/etc/puppi/projects/myapp/rollback/50-get').with_ensure('present') - end - it 'should populate correctly the puppi::rollback step file' do - should contain_file('/etc/puppi/projects/myapp/rollback/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") - end - end - on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } + let(:title) { 'puppi::rollback' } + let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } + let(:params) { + { 'enable' => 'true', + 'name' => 'get', + 'command' => 'echo', + 'priority' => '50', + 'project' => 'myapp', + } + } + + describe 'Test puppi rollback step file creation' do + it 'should create a puppi::rollback step file' do + should contain_file('/etc/puppi/projects/myapp/rollback/50-get').with_ensure('present') + end + it 'should populate correctly the puppi::rollback step file' do + should contain_file('/etc/puppi/projects/myapp/rollback/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") + end + end it { is_expected.to compile } end diff --git a/spec/defines/run_spec.rb b/spec/defines/run_spec.rb index 5ef9bff..67503b2 100644 --- a/spec/defines/run_spec.rb +++ b/spec/defines/run_spec.rb @@ -3,22 +3,21 @@ require 'spec_helper' describe 'puppi::run' do - let(:title) { 'myapp' } - let(:node) { 'rspec.example42.com' } - let(:pre_condition) { 'include puppi' } - let(:params) { - { - 'project' => 'myapp', - } - } - - describe 'Test puppi run exe creation' do - it { should contain_exec('Run_Puppi_myapp').with_command(/puppi deploy myapp/) } - end - on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } + let(:title) { 'myapp' } + let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } + let(:params) { + { + 'project' => 'myapp', + } + } + + describe 'Test puppi run exe creation' do + it { should contain_exec('Run_Puppi_myapp').with_command(/puppi deploy myapp/) } + end it { is_expected.to compile } end diff --git a/spec/defines/runscript_spec.rb b/spec/defines/runscript_spec.rb index fcf1ff2..40f3e9a 100644 --- a/spec/defines/runscript_spec.rb +++ b/spec/defines/runscript_spec.rb @@ -3,16 +3,15 @@ require 'spec_helper' describe 'puppi::runscript' do - let(:title) { 'namevar' } - let(:node) { 'rspec.example42.com' } - let(:pre_condition) { 'include puppi' } - let(:params) do - {} - end - on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } + let(:title) { 'namevar' } + let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } + let(:params) do + {} + end it { is_expected.to compile } end diff --git a/spec/defines/todo_spec.rb b/spec/defines/todo_spec.rb index b279aaf..bb80dbc 100644 --- a/spec/defines/todo_spec.rb +++ b/spec/defines/todo_spec.rb @@ -3,30 +3,29 @@ require 'spec_helper' describe 'puppi::todo' do - let(:title) { 'mytodo' } - let(:node) { 'rspec.example42.com' } - let(:pre_condition) { 'include puppi' } - let(:params) { - { 'notes' => 'Test Notes', - 'description' => 'Test Description', - 'check_command' => 'check_test', - 'run' => 'test', - } - } - - describe 'Test puppi todo file creation' do - it 'should create a puppi::todo file' do - should contain_file('/etc/puppi/todo/mytodo').with_ensure('present') - end - it 'should populate correctly the puppi::todo step file' do - should contain_file('/etc/puppi/todo/mytodo').with_content(/check_test/) - end - end - on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } - + let(:title) { 'mytodo' } + let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } + let(:params) { + { 'notes' => 'Test Notes', + 'description' => 'Test Description', + 'check_command' => 'check_test', + 'run' => 'test', + } + } + + describe 'Test puppi todo file creation' do + it 'should create a puppi::todo file' do + should contain_file('/etc/puppi/todo/mytodo').with_ensure('present') + end + it 'should populate correctly the puppi::todo step file' do + should contain_file('/etc/puppi/todo/mytodo').with_content(/check_test/) + end + end + it { is_expected.to compile } end end diff --git a/spec/defines/ze_spec.rb b/spec/defines/ze_spec.rb index f6ce152..cb6773c 100644 --- a/spec/defines/ze_spec.rb +++ b/spec/defines/ze_spec.rb @@ -3,26 +3,25 @@ require 'spec_helper' describe 'puppi::ze' do - let(:title) { 'sample' } - let(:node) { 'rspec.example42.com' } - let(:pre_condition) { 'include puppi' } - let(:params) { - { 'helper' => 'mytest', - 'variables' => { 'var1' => 'get', 'var2' => 'got' }, - 'name' => 'sample', - } - } - - describe 'Test puppi ze data file creation' do - it 'should create a puppi::ze step file' do - should contain_file('puppize_sample').with_ensure('present') - end - end - on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } - + let(:title) { 'sample' } + let(:node) { 'rspec.example42.com' } + let(:pre_condition) { 'include puppi' } + let(:params) { + { 'helper' => 'mytest', + 'variables' => { 'var1' => 'get', 'var2' => 'got' }, + 'name' => 'sample', + } + } + + describe 'Test puppi ze data file creation' do + it 'should create a puppi::ze step file' do + should contain_file('puppize_sample').with_ensure('present') + end + end + it { is_expected.to compile } end end From 47c49b27473a75c21445ef17834735bd211a21de Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Wed, 25 Sep 2024 10:47:14 +0200 Subject: [PATCH 11/22] More fixes --- manifests/info.pp | 9 +++++---- manifests/log.pp | 7 ++++--- manifests/todo.pp | 9 +++++---- spec/defines/project/archive_spec.rb | 2 +- spec/defines/project/builder_spec.rb | 2 +- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/manifests/info.pp b/manifests/info.pp index 07b00f3..bfdae91 100644 --- a/manifests/info.pp +++ b/manifests/info.pp @@ -25,12 +25,13 @@ require puppi require puppi::params - $array_run = is_array($run) ? { - false => $run ? { + if Array($run) { + $array_run = $run + } else { + $array_run = $run ? { '' => [], default => split($run, ','), - }, - default => $run, + } } file { "${puppi::params::infodir}/${name}": diff --git a/manifests/log.pp b/manifests/log.pp index b50feb6..5ed7daf 100644 --- a/manifests/log.pp +++ b/manifests/log.pp @@ -18,9 +18,10 @@ require puppi require puppi::params - $array_log = is_array($log) ? { - false => split($log, ','), - default => $log, + if Array($log) { + $array_log = $log + } else { + $array_log = split($log, ',') } file { "${puppi::params::logsdir}/${name}": diff --git a/manifests/todo.pp b/manifests/todo.pp index f6c7440..9822f23 100644 --- a/manifests/todo.pp +++ b/manifests/todo.pp @@ -36,12 +36,13 @@ require puppi require puppi::params - $array_run = is_array($run) ? { - false => $run ? { + if Array($run) { + $array_run = $run + } else { + $array_run = $run ? { '' => [], default => split($run, ','), - }, - default => $run, + } } file { "${puppi::params::tododir}/${name}": diff --git a/spec/defines/project/archive_spec.rb b/spec/defines/project/archive_spec.rb index f551a3e..7eec6f9 100644 --- a/spec/defines/project/archive_spec.rb +++ b/spec/defines/project/archive_spec.rb @@ -6,7 +6,7 @@ let(:title) { 'namevar' } let(:params) { { - 'source' => 'test', + 'source' => 'test.tar.gz', 'deploy_root' => '/tmp', } } diff --git a/spec/defines/project/builder_spec.rb b/spec/defines/project/builder_spec.rb index 497cc7f..c937b6d 100644 --- a/spec/defines/project/builder_spec.rb +++ b/spec/defines/project/builder_spec.rb @@ -7,7 +7,7 @@ let(:params) { { 'source' => 'test', - 'source_type' => 'git', + 'source_type' => 'zip', 'deploy_root' => '/tmp', } } From dff2762e399c0e1e321d14ced4d609808b762a7a Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Wed, 25 Sep 2024 11:10:42 +0200 Subject: [PATCH 12/22] Fix datatype --- manifests/info/module.pp | 14 +++++++------- templates/info/module.erb | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/manifests/info/module.pp b/manifests/info/module.pp index 89376b4..44107a6 100644 --- a/manifests/info/module.pp +++ b/manifests/info/module.pp @@ -26,20 +26,20 @@ # } # define puppi::info::module ( - String $packagename = '', - String $servicename = '', + Array $packagename = [], + Array $servicename = [], String $processname = '', - String $configfile = '', + Array $configfile = [], String $configdir = '', String $initconfigfile = '', String $pidfile = '', - String $datadir = '', - String $logfile = '', - String $logdir = '', + Array $datadir = [], + Array $logfile = [], + Array $logdir = [], String $protocol = '', Variant[String,Integer] $port = '', String $description = '', - String $run = '', + Array $run = [], String $verbose = 'no', String $templatefile = 'puppi/info/module.erb', ) { diff --git a/templates/info/module.erb b/templates/info/module.erb index aa53d25..71e73c6 100644 --- a/templates/info/module.erb +++ b/templates/info/module.erb @@ -6,7 +6,7 @@ # Sources common header for Puppi scripts . <%= scope.lookupvar('puppi::params::scriptsdir') %>/header || exit 10 -<% if @packagename != "" -%> +<% if @packagename != [] -%> # Show packages info echo_title "$HOSTNAME - <%= @name %>: Packages Installed: <% @packagename.each do |item| %><%= item %><% end %>" <% @packagename.each do |item| -%> @@ -19,7 +19,7 @@ show_command "<%= scope.lookupvar('puppi::params::info_package_list') %> <%= ite <% end -%> <% end -%> -<% if @configfile != "" -%> +<% if @configfile != [] -%> # Show config info echo_title "$HOSTNAME - <%= @name %>: Configuration Files managed: <% @configfile.each do |item| %><%= item %><% end %>" <% @configfile.each do |item| -%> @@ -31,7 +31,7 @@ show_command "head <%= item %>" <% end -%> <% end -%> -<% if @datadir != "" -%> +<% if @datadir != [] -%> # Show data dir echo_title "$HOSTNAME - <%= @name %>: Application data are in: <% @datadir.each do |item| %><%= item %><% end %>" <% @datadir.each do |item| -%> @@ -40,7 +40,7 @@ show_command "df <%= item %>" <% end -%> <% end -%> -<% if @logdir != "" -%> +<% if @logdir != [] -%> # Show log dir echo_title "$HOSTNAME - <%= @name %>: Logs are in: <% @logdir.each do |item| %><%= item %><% end %>" <% @logdir.each do |item| -%> @@ -49,7 +49,7 @@ show_command "df <%= item %>" <% end -%> <% end -%> -<% if @logfile != "" -%> +<% if @logfile != [] -%> # Show logs echo_title "$HOSTNAME - <%= @name %>: Last log entries: <% @logfile.each do |item| %><%= item %><% end %>" <% @logfile.each do |item| -%> @@ -61,14 +61,14 @@ show_command "tail -10 <%= item %>" <% end -%> <% end -%> -<% if @run != "" -%> +<% if @run != [] -%> echo_title "$HOSTNAME - <%= @name %>: Extra info" <% @run.each do |cmd| %>show_command "<%= cmd %>" <% end -%> <% end -%> -<% if @servicename != "" -%> +<% if @servicename != [] -%> # Show service info echo_title "$HOSTNAME - <%= @name %>: Services: <% @servicename.each do |item| %><%= item %><% end %>" <% @servicename.each do |item| -%> From cee2146543422932cee72e5fd633e730c8c8e8a2 Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Wed, 25 Sep 2024 12:28:55 +0200 Subject: [PATCH 13/22] Fix data type --- manifests/info/module.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/info/module.pp b/manifests/info/module.pp index 44107a6..04adb0d 100644 --- a/manifests/info/module.pp +++ b/manifests/info/module.pp @@ -30,7 +30,7 @@ Array $servicename = [], String $processname = '', Array $configfile = [], - String $configdir = '', + Variant[Array,String] $configdir = '', String $initconfigfile = '', String $pidfile = '', Array $datadir = [], From 86ac0b1f45e87538d18f4dd2c3cdfe827076986f Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Wed, 25 Sep 2024 13:22:57 +0200 Subject: [PATCH 14/22] Fixing tests --- manifests/info.pp | 2 +- manifests/install_packages.pp | 2 +- manifests/log.pp | 2 +- manifests/todo.pp | 2 +- spec/defines/configure_spec.rb | 9 ++++++--- spec/defines/netinstall_spec.rb | 9 ++++++--- spec/defines/project_spec.rb | 6 ++---- 7 files changed, 18 insertions(+), 14 deletions(-) diff --git a/manifests/info.pp b/manifests/info.pp index bfdae91..9ab4f70 100644 --- a/manifests/info.pp +++ b/manifests/info.pp @@ -25,7 +25,7 @@ require puppi require puppi::params - if Array($run) { + if $run.type == Array { $array_run = $run } else { $array_run = $run ? { diff --git a/manifests/install_packages.pp b/manifests/install_packages.pp index 3ce8a94..1b3bafc 100644 --- a/manifests/install_packages.pp +++ b/manifests/install_packages.pp @@ -47,7 +47,7 @@ define puppi::install_packages ( String $packages, String $template = 'puppi/install_packages.erb', - Srring $scripts_dir = '/root/puppi_install_packages', + String $scripts_dir = '/root/puppi_install_packages', Boolean $autorun = true, Boolean $refreshonly = true, Variant[String,Integer] $timeout = '600', diff --git a/manifests/log.pp b/manifests/log.pp index 5ed7daf..d32668c 100644 --- a/manifests/log.pp +++ b/manifests/log.pp @@ -18,7 +18,7 @@ require puppi require puppi::params - if Array($log) { + if $log.type == Array { $array_log = $log } else { $array_log = split($log, ',') diff --git a/manifests/todo.pp b/manifests/todo.pp index 9822f23..2fa109a 100644 --- a/manifests/todo.pp +++ b/manifests/todo.pp @@ -36,7 +36,7 @@ require puppi require puppi::params - if Array($run) { + if $run.type == Array { $array_run = $run } else { $array_run = $run ? { diff --git a/spec/defines/configure_spec.rb b/spec/defines/configure_spec.rb index 80959d2..eb18e86 100644 --- a/spec/defines/configure_spec.rb +++ b/spec/defines/configure_spec.rb @@ -10,9 +10,12 @@ let(:title) { 'namevar' } let(:node) { 'rspec.example42.com' } let(:pre_condition) { 'include puppi' } - let(:params) do - {} - end + let(:params) { + { + 'command' => 'test', + 'project' => 'zip', + } + } it { is_expected.to compile } end end diff --git a/spec/defines/netinstall_spec.rb b/spec/defines/netinstall_spec.rb index 5c33444..5e941b8 100644 --- a/spec/defines/netinstall_spec.rb +++ b/spec/defines/netinstall_spec.rb @@ -9,9 +9,12 @@ let(:title) { 'namevar' } let(:node) { 'rspec.example42.com' } let(:pre_condition) { 'include puppi' } - let(:params) do - {} - end + let(:params) { + { + 'url' => 'test', + 'destination_url' => '/tmp', + } + } it { is_expected.to compile } end end diff --git a/spec/defines/project_spec.rb b/spec/defines/project_spec.rb index f168e5a..933ca97 100644 --- a/spec/defines/project_spec.rb +++ b/spec/defines/project_spec.rb @@ -10,11 +10,9 @@ let(:node) { 'rspec.example42.com' } let(:pre_condition) { 'include puppi' } let(:params) { - { 'enable' => 'true', + { + 'enable' => 'true', 'name' => 'get', - 'command' => 'echo', - 'priority' => '50', - 'project' => 'myapp', } } From 1ac7ed1814a70c3067ce6718334b5653a04b1a4b Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Wed, 25 Sep 2024 14:24:45 +0200 Subject: [PATCH 15/22] Array typecast --- CHANGELOG.md | 11 ------ README.md | 85 +++++++++++++++++++---------------------------- manifests/info.pp | 9 +---- manifests/log.pp | 6 +--- manifests/todo.pp | 9 +---- metadata.json | 2 +- 6 files changed, 39 insertions(+), 83 deletions(-) delete mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 9e5c7de..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,11 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. - -## Release 3.0.0 - -**Features** - -**Bugfixes** - -**Known Issues** diff --git a/README.md b/README.md index 62ccfae..79d4caa 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,13 @@ -# Puppi: Puppet Knowledge to the CLI +# Puppi: Applications deployment as code -Puppi is maintained by Example42 GmbH +Puppi is maintained by Example42 Licence: Apache 2 Puppi is a unique tool that serves both as a Puppet module and a CLI command tool. It's data is entirely driven by Puppet code. Example use cases for Puppi may include: + - creating a standardize method to automate the deployment of web applications - or to provide a set of standard commands to query and check system resources based on "user defined actions". @@ -15,33 +16,29 @@ Its structure provides FULL flexibility on the type of "actions" that may be req The module provides: * Puppi v1 script - * A set of scripts that can be chained together to automate any kind of deployment. - * Puppet defines that make it easy to prepare a puppi set of commands for a project deployment. - * Puppet defines to populate the output of the different actions. This module requires functions provided by the [Puppet Labs Stdlib Module](https://github.com/puppetlabs/puppetlabs-stdlib). - ## HOW TO INSTALL -Download Puppi from GitHub and place it in your modules directory: +Install the module from the Forge: -```bash -git clone https://github.com/example42/puppi.git /etc/puppet/modules/puppi +```bash {"id":"01J8MJ40BQWMDAJC3F710YREN4"} +puppet module install example42/puppi ``` To use the Puppi just declare or include the puppi class -```ruby +```ruby {"id":"01J8MJ40BQWMDAJC3F7286XQQK"} include puppi ``` If you have resources conflicts, do not install automatically the Puppi dependencies (commands and packages) -```ruby +```ruby {"id":"01J8MJ40BQWMDAJC3F72Q9E3VZ"} class { 'puppi': install_dependencies => false, } @@ -53,18 +50,17 @@ Once Puppi is installed you can use it to: * Easily define in Puppet manifests Web Applications deploy procedures. For example: - ```ruby - puppi::project::war { "myapp": - source => "http://repo.example42.com/deploy/prod/myapp.war", - deploy_root => "/opt/tomcat/myapp/webapps", - } - ``` +```ruby {"id":"01J8MJ40BQWMDAJC3F748G9HWW"} +puppi::project::war { "myapp": + source => "http://repo.example42.com/deploy/prod/myapp.war", + deploy_root => "/opt/tomcat/myapp/webapps", +} +``` * Integrate with your modules for puppi check, info and log * Enable Example42 modules integration - ## HOW TO USE WITH EXAMPLE42 MODULES The Example42 modules version 1 provide (optional) Puppi integration. @@ -72,7 +68,7 @@ Once enabled for each module you have puppi check, info and log commands. To enable Puppi integration in OldGen (version 1) Example42 Modules, set in the scope these variables: -``` +```html {"id":"01J8MJ40BQWMDAJC3F74Q6B0KZ"} $puppi = yes # Enables puppi integration $monitor = yes # Enables automatic monitoring $monitor_tool = "puppi" # Sets puppi as monitoring tool @@ -80,7 +76,7 @@ $monitor_tool = "puppi" # Sets puppi as monitoring tool ## USAGE OF THE PUPPI COMMAND (OLD GEN) -```bash +```bash {"id":"01J8MJ40BQWMDAJC3F7615PETB"} puppi [ -options ] ``` @@ -119,19 +115,14 @@ In the deploy/rollback/init actions, puppi runs the commands in /etc/puppi/proje You can also provide some options: * -f : Force puppi commands execution also on CRITICAL errors - * -i : Interactively ask confirmation for every command - * -t : Test mode. Just show the commands that should be executed without doing anything - * -d : Debug mode. Show debugging info during execution - * -o "parameter=value parameter2=value2" : Set manual options to override defaults. The options must be in parameter=value syntax, separated by spaces and inside double quotes. - Some common puppi commands when you log for an application deployment: -```bash +```bash {"id":"01J8MJ40BQWMDAJC3F790N39R5"} puppi check puppi log & # (More readable if done on another window) puppi deploy myapp @@ -178,7 +169,6 @@ Create an info entry with the commands used to provide info on a topic Read details in the relevant READMEs - ## FILE PATHS (all of them are provided, and can be configured, in the puppi module): A link to the actual version of puppi enabled @@ -229,52 +219,47 @@ A runtime configuration file, which is used by all the the scripts invoked by pu /tmp/puppi/$project/config - ## HOW TO CUSTOMIZE + It should be clear that with puppi you have full flexibility in the definition of a deployment procedure, since the puppi command is basically a wrapper that executes arbitrary scripts with a given sequence, in pure KISS logic. The advantanges though, are various: -* You have a common syntax to manage deploys and rollbacks on an host +* You have a common syntax to manage deploys and rollbacks on an host * In your Puppet manifests, you can set in simple, coherent and still flexible and customizable - defines all the elements, you need for your application deployments. - Think about it: with just a Puppet define you build the whole deploy logic - + defines all the elements, you need for your application deployments. + Think about it: with just a Puppet define you build the whole deploy logic * Reporting for each deploy/rollback is built-in and extensible - * Automatic checks can be built in the deploy procedure - * You have a common, growing, set of general-use scripts for typical actions - * You have quick and useful command to see what's happening on the system (puppi check, log, info) There are different parts where you can customize the behaviour of puppi: * The set of general-use scripts in /etc/puppi/scripts/ ( this directory is filled with the content - of puppi/files/scripts/ ) can/should be enhanced. These can be arbitrary scripts in whatever - language. If you want to follow puppi's logic, though, consider that they should import the - common and runtime configuration files and have an exit code logic similar to the one of - Nagios plugins: 0 is OK, 1 is WARNING, 2 is CRITICAL. Note that by default a script that - exits with WARNING doesn't block the deploy procedure, on the other hand, if a script exits - with CRITICAL (exit 2) by default it blocks the procedure. - Take a second, also, to explore the runtime config file created by the puppi command that - contains variables that can be set and used by the scripts invoked by puppi. - + of puppi/files/scripts/ ) can/should be enhanced. These can be arbitrary scripts in whatever + language. If you want to follow puppi's logic, though, consider that they should import the + common and runtime configuration files and have an exit code logic similar to the one of + Nagios plugins: 0 is OK, 1 is WARNING, 2 is CRITICAL. Note that by default a script that + exits with WARNING doesn't block the deploy procedure, on the other hand, if a script exits + with CRITICAL (exit 2) by default it blocks the procedure. + Take a second, also, to explore the runtime config file created by the puppi command that + contains variables that can be set and used by the scripts invoked by puppi. * The custom project defines that describe deploy templates. These are placed in - puppi/manifests/project/ and can request all the arguments you want to feed your scripts with. - Generally is a good idea to design a standard enough template that can be used for all the - cases where the deployment procedure involves similar steps. Consider also that you can handle - exceptions with variables (see the $loadbalancer_ip usage in puppi/manifests/project/maven.pp) - + puppi/manifests/project/ and can request all the arguments you want to feed your scripts with. + Generally is a good idea to design a standard enough template that can be used for all the + cases where the deployment procedure involves similar steps. Consider also that you can handle + exceptions with variables (see the $loadbalancer_ip usage in puppi/manifests/project/maven.pp) ## (NO) DEPENDENCIES AND CONFLICTS + Puppi is self contained. It doesn't require other modules. (And is required by all Example42 modules). For correct functionality by default some extra packages are installed. If you have conflicts with your existing modules, set the argument: - install_dependencies => false +install_dependencies => false diff --git a/manifests/info.pp b/manifests/info.pp index 9ab4f70..5e0a51f 100644 --- a/manifests/info.pp +++ b/manifests/info.pp @@ -25,14 +25,7 @@ require puppi require puppi::params - if $run.type == Array { - $array_run = $run - } else { - $array_run = $run ? { - '' => [], - default => split($run, ','), - } - } + $array_run = Array($run) file { "${puppi::params::infodir}/${name}": ensure => file, diff --git a/manifests/log.pp b/manifests/log.pp index d32668c..9e89c42 100644 --- a/manifests/log.pp +++ b/manifests/log.pp @@ -18,11 +18,7 @@ require puppi require puppi::params - if $log.type == Array { - $array_log = $log - } else { - $array_log = split($log, ',') - } + $array_log = Array($log) file { "${puppi::params::logsdir}/${name}": ensure => 'file', diff --git a/manifests/todo.pp b/manifests/todo.pp index 2fa109a..dee0d75 100644 --- a/manifests/todo.pp +++ b/manifests/todo.pp @@ -36,14 +36,7 @@ require puppi require puppi::params - if $run.type == Array { - $array_run = $run - } else { - $array_run = $run ? { - '' => [], - default => split($run, ','), - } - } + $array_run = Array($run) file { "${puppi::params::tododir}/${name}": ensure => file, diff --git a/metadata.json b/metadata.json index 9ce3c4d..81178b1 100644 --- a/metadata.json +++ b/metadata.json @@ -73,7 +73,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 3.0.0 < 9.0.0" + "version_requirement": ">= 5.0.0 < 9.0.0" } ], "description": "This module provides the Puppi libraries required by Example42 modules and, if explicitly included, the puppi command, its working environment, the defines and procedures to deploy applications", From 0028fb7bf1ae6f2cb005524b92ba062282cffc86 Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Wed, 25 Sep 2024 15:24:14 +0200 Subject: [PATCH 16/22] .. --- manifests/info.pp | 6 +++++- manifests/log.pp | 6 +++++- manifests/todo.pp | 6 +++++- spec/classes/puppi_spec.rb2 | 4 ++-- spec/defines/check_spec.rb | 2 +- spec/defines/deploy_spec.rb | 2 +- spec/defines/helper_spec.rb | 2 +- spec/defines/info_spec.rb | 2 +- spec/defines/log_spec.rb | 2 +- spec/defines/project_spec.rb | 2 +- spec/defines/report_spec.rb | 2 +- spec/defines/rollback_spec.rb | 2 +- spec/defines/todo_spec.rb | 2 +- spec/defines/ze_spec.rb | 2 +- 14 files changed, 27 insertions(+), 15 deletions(-) diff --git a/manifests/info.pp b/manifests/info.pp index 5e0a51f..37640d3 100644 --- a/manifests/info.pp +++ b/manifests/info.pp @@ -25,7 +25,11 @@ require puppi require puppi::params - $array_run = Array($run) + if $run.type =~ Array { + $array_run = $run + } else { + $array_run = split($run, ',') + } file { "${puppi::params::infodir}/${name}": ensure => file, diff --git a/manifests/log.pp b/manifests/log.pp index 9e89c42..d6897ef 100644 --- a/manifests/log.pp +++ b/manifests/log.pp @@ -18,7 +18,11 @@ require puppi require puppi::params - $array_log = Array($log) + if $log.type =~ Array { + $array_log = $log + } else { + $array_log = split($log, ',') + } file { "${puppi::params::logsdir}/${name}": ensure => 'file', diff --git a/manifests/todo.pp b/manifests/todo.pp index dee0d75..69fd433 100644 --- a/manifests/todo.pp +++ b/manifests/todo.pp @@ -36,7 +36,11 @@ require puppi require puppi::params - $array_run = Array($run) + if $run.type =~ Array { + $array_run = $run + } else { + $array_run = split($run, ',') + } file { "${puppi::params::tododir}/${name}": ensure => file, diff --git a/spec/classes/puppi_spec.rb2 b/spec/classes/puppi_spec.rb2 index 903f593..824f21c 100644 --- a/spec/classes/puppi_spec.rb2 +++ b/spec/classes/puppi_spec.rb2 @@ -8,8 +8,8 @@ describe 'puppi' do describe 'Test standard installation' do it { should contain_file('puppi').with_ensure('present') } - it { should contain_file('puppi.conf').with_ensure('present') } - it { should contain_file('puppi.scripts').with_ensure('present') } + it { should contain_file('puppi.conf').with_ensure('file') } + it { should contain_file('puppi.scripts').with_ensure('file') } it { should contain_file('puppi_basedir').with_ensure('directory') } it { should contain_file('puppi_datadir').with_ensure('directory') } end diff --git a/spec/defines/check_spec.rb b/spec/defines/check_spec.rb index fc9c5d0..2fcbf41 100644 --- a/spec/defines/check_spec.rb +++ b/spec/defines/check_spec.rb @@ -21,7 +21,7 @@ it { is_expected.to compile } describe 'Test puppi check step file creation' do it 'should create a puppi::check step file' do - should contain_file('Puppi_check_myapp_50_get').with_ensure('present') + should contain_file('Puppi_check_myapp_50_get').with_ensure('file') end it 'should populate correctly the puppi::check step file' do should contain_file('Puppi_check_myapp_50_get').with_content(/\/usr\/lib64\/nagios\/plugins\/echo/) diff --git a/spec/defines/deploy_spec.rb b/spec/defines/deploy_spec.rb index 78e0117..d55866e 100644 --- a/spec/defines/deploy_spec.rb +++ b/spec/defines/deploy_spec.rb @@ -20,7 +20,7 @@ describe 'Test puppi deploy step file creation' do it 'should create a puppi::deploy step file' do - should contain_file('/etc/puppi/projects/myapp/deploy/50-get').with_ensure('present') + should contain_file('/etc/puppi/projects/myapp/deploy/50-get').with_ensure('file') end it 'should populate correctly the puppi::deploy step file' do should contain_file('/etc/puppi/projects/myapp/deploy/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") diff --git a/spec/defines/helper_spec.rb b/spec/defines/helper_spec.rb index 2573c49..162e896 100644 --- a/spec/defines/helper_spec.rb +++ b/spec/defines/helper_spec.rb @@ -15,7 +15,7 @@ describe 'Test puppi helper file creation' do it 'should create a puppi helper file' do - should contain_file('puppi_helper_spec').with_ensure('present') + should contain_file('puppi_helper_spec').with_ensure('file') end it 'should populate correctly the helper file' do should contain_file('puppi_helper_spec').with_content(/info/) diff --git a/spec/defines/info_spec.rb b/spec/defines/info_spec.rb index 87587ae..85e0cb9 100644 --- a/spec/defines/info_spec.rb +++ b/spec/defines/info_spec.rb @@ -19,7 +19,7 @@ describe 'Test puppi info step file creation' do it 'should create a puppi::info step file' do - should contain_file('/etc/puppi/info/sample').with_ensure('present') + should contain_file('/etc/puppi/info/sample').with_ensure('file') end it 'should populate correctly the puppi::info step file' do should contain_file('/etc/puppi/info/sample').with_content(/myownscript/) diff --git a/spec/defines/log_spec.rb b/spec/defines/log_spec.rb index cbfb0f6..356ae73 100644 --- a/spec/defines/log_spec.rb +++ b/spec/defines/log_spec.rb @@ -17,7 +17,7 @@ describe 'Test puppi log file creation' do it 'should create a puppi::log file' do - should contain_file('/etc/puppi/logs/mylog').with_ensure('present') + should contain_file('/etc/puppi/logs/mylog').with_ensure('file') end it 'should populate correctly the puppi::log step file' do should contain_file('/etc/puppi/logs/mylog').with_content(/mylog.log/) diff --git a/spec/defines/project_spec.rb b/spec/defines/project_spec.rb index 933ca97..6e3b9c1 100644 --- a/spec/defines/project_spec.rb +++ b/spec/defines/project_spec.rb @@ -18,7 +18,7 @@ describe 'Test puppi report step file creation' do it 'should create a puppi::report step file' do - should contain_file('/etc/puppi/projects/myapp/report/50-get').with_ensure('present') + should contain_file('/etc/puppi/projects/myapp/report/50-get').with_ensure('file') end it 'should populate correctly the puppi::report step file' do should contain_file('/etc/puppi/projects/myapp/report/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") diff --git a/spec/defines/report_spec.rb b/spec/defines/report_spec.rb index e0cf299..2201e27 100644 --- a/spec/defines/report_spec.rb +++ b/spec/defines/report_spec.rb @@ -20,7 +20,7 @@ describe 'Test puppi report step file creation' do it 'should create a puppi::report step file' do - should contain_file('/etc/puppi/projects/myapp/report/50-get').with_ensure('present') + should contain_file('/etc/puppi/projects/myapp/report/50-get').with_ensure('file') end it 'should populate correctly the puppi::report step file' do should contain_file('/etc/puppi/projects/myapp/report/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") diff --git a/spec/defines/rollback_spec.rb b/spec/defines/rollback_spec.rb index 617a648..af7283b 100644 --- a/spec/defines/rollback_spec.rb +++ b/spec/defines/rollback_spec.rb @@ -20,7 +20,7 @@ describe 'Test puppi rollback step file creation' do it 'should create a puppi::rollback step file' do - should contain_file('/etc/puppi/projects/myapp/rollback/50-get').with_ensure('present') + should contain_file('/etc/puppi/projects/myapp/rollback/50-get').with_ensure('file') end it 'should populate correctly the puppi::rollback step file' do should contain_file('/etc/puppi/projects/myapp/rollback/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") diff --git a/spec/defines/todo_spec.rb b/spec/defines/todo_spec.rb index bb80dbc..aaa3970 100644 --- a/spec/defines/todo_spec.rb +++ b/spec/defines/todo_spec.rb @@ -19,7 +19,7 @@ describe 'Test puppi todo file creation' do it 'should create a puppi::todo file' do - should contain_file('/etc/puppi/todo/mytodo').with_ensure('present') + should contain_file('/etc/puppi/todo/mytodo').with_ensure('file') end it 'should populate correctly the puppi::todo step file' do should contain_file('/etc/puppi/todo/mytodo').with_content(/check_test/) diff --git a/spec/defines/ze_spec.rb b/spec/defines/ze_spec.rb index cb6773c..e327d97 100644 --- a/spec/defines/ze_spec.rb +++ b/spec/defines/ze_spec.rb @@ -18,7 +18,7 @@ describe 'Test puppi ze data file creation' do it 'should create a puppi::ze step file' do - should contain_file('puppize_sample').with_ensure('present') + should contain_file('puppize_sample').with_ensure('file') end end From 7ecf47dd9c9bcb75061e21c0a94dc0f05a558e8b Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Wed, 25 Sep 2024 15:39:50 +0200 Subject: [PATCH 17/22] tt --- manifests/info.pp | 3 +-- manifests/log.pp | 2 +- manifests/todo.pp | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/manifests/info.pp b/manifests/info.pp index 37640d3..20187c6 100644 --- a/manifests/info.pp +++ b/manifests/info.pp @@ -28,9 +28,8 @@ if $run.type =~ Array { $array_run = $run } else { - $array_run = split($run, ',') + $array_run = [$run] } - file { "${puppi::params::infodir}/${name}": ensure => file, mode => '0750', diff --git a/manifests/log.pp b/manifests/log.pp index d6897ef..11ba8ec 100644 --- a/manifests/log.pp +++ b/manifests/log.pp @@ -21,7 +21,7 @@ if $log.type =~ Array { $array_log = $log } else { - $array_log = split($log, ',') + $array_rlog = [$log] } file { "${puppi::params::logsdir}/${name}": diff --git a/manifests/todo.pp b/manifests/todo.pp index 69fd433..426cb8d 100644 --- a/manifests/todo.pp +++ b/manifests/todo.pp @@ -39,7 +39,7 @@ if $run.type =~ Array { $array_run = $run } else { - $array_run = split($run, ',') + $array_run = [$run] } file { "${puppi::params::tododir}/${name}": From 3aec8f77b3e2beac93774dafb56427ccb60dbedf Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Wed, 25 Sep 2024 16:37:05 +0200 Subject: [PATCH 18/22] fixing --- templates/log.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/log.erb b/templates/log.erb index 5ca47bb..a8a1295 100644 --- a/templates/log.erb +++ b/templates/log.erb @@ -1,2 +1,4 @@ +<% if @array_log != '' -%> <% @array_log.each do |path| %><%= path %> <% end %> +<% end -%> \ No newline at end of file From 38cee5911647c302ced8b24fca49870f98b680c9 Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Wed, 25 Sep 2024 17:44:06 +0200 Subject: [PATCH 19/22] Another test --- manifests/log.pp | 2 +- templates/log.erb | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/manifests/log.pp b/manifests/log.pp index 11ba8ec..5861745 100644 --- a/manifests/log.pp +++ b/manifests/log.pp @@ -21,7 +21,7 @@ if $log.type =~ Array { $array_log = $log } else { - $array_rlog = [$log] + $array_log = [$log] } file { "${puppi::params::logsdir}/${name}": diff --git a/templates/log.erb b/templates/log.erb index a8a1295..ea3de07 100644 --- a/templates/log.erb +++ b/templates/log.erb @@ -1,4 +1,2 @@ -<% if @array_log != '' -%> <% @array_log.each do |path| %><%= path %> -<% end %> -<% end -%> \ No newline at end of file +<% end %> \ No newline at end of file From 4283bacd601cbc5262ee0b93291be3fcf44a03be Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Wed, 25 Sep 2024 18:14:38 +0200 Subject: [PATCH 20/22] More spec fixing --- spec/defines/check_spec.rb | 2 +- spec/defines/deploy_spec.rb | 2 +- spec/defines/helper_spec.rb | 2 +- spec/defines/netinstall_spec.rb | 2 +- spec/defines/project_spec.rb | 2 +- spec/defines/rollback_spec.rb | 2 +- spec/defines/ze_spec.rb | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/defines/check_spec.rb b/spec/defines/check_spec.rb index 2fcbf41..fc9c5d0 100644 --- a/spec/defines/check_spec.rb +++ b/spec/defines/check_spec.rb @@ -21,7 +21,7 @@ it { is_expected.to compile } describe 'Test puppi check step file creation' do it 'should create a puppi::check step file' do - should contain_file('Puppi_check_myapp_50_get').with_ensure('file') + should contain_file('Puppi_check_myapp_50_get').with_ensure('present') end it 'should populate correctly the puppi::check step file' do should contain_file('Puppi_check_myapp_50_get').with_content(/\/usr\/lib64\/nagios\/plugins\/echo/) diff --git a/spec/defines/deploy_spec.rb b/spec/defines/deploy_spec.rb index d55866e..78e0117 100644 --- a/spec/defines/deploy_spec.rb +++ b/spec/defines/deploy_spec.rb @@ -20,7 +20,7 @@ describe 'Test puppi deploy step file creation' do it 'should create a puppi::deploy step file' do - should contain_file('/etc/puppi/projects/myapp/deploy/50-get').with_ensure('file') + should contain_file('/etc/puppi/projects/myapp/deploy/50-get').with_ensure('present') end it 'should populate correctly the puppi::deploy step file' do should contain_file('/etc/puppi/projects/myapp/deploy/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") diff --git a/spec/defines/helper_spec.rb b/spec/defines/helper_spec.rb index 162e896..2573c49 100644 --- a/spec/defines/helper_spec.rb +++ b/spec/defines/helper_spec.rb @@ -15,7 +15,7 @@ describe 'Test puppi helper file creation' do it 'should create a puppi helper file' do - should contain_file('puppi_helper_spec').with_ensure('file') + should contain_file('puppi_helper_spec').with_ensure('present') end it 'should populate correctly the helper file' do should contain_file('puppi_helper_spec').with_content(/info/) diff --git a/spec/defines/netinstall_spec.rb b/spec/defines/netinstall_spec.rb index 5e941b8..1619765 100644 --- a/spec/defines/netinstall_spec.rb +++ b/spec/defines/netinstall_spec.rb @@ -12,7 +12,7 @@ let(:params) { { 'url' => 'test', - 'destination_url' => '/tmp', + 'destination_dir' => '/tmp', } } it { is_expected.to compile } diff --git a/spec/defines/project_spec.rb b/spec/defines/project_spec.rb index 6e3b9c1..933ca97 100644 --- a/spec/defines/project_spec.rb +++ b/spec/defines/project_spec.rb @@ -18,7 +18,7 @@ describe 'Test puppi report step file creation' do it 'should create a puppi::report step file' do - should contain_file('/etc/puppi/projects/myapp/report/50-get').with_ensure('file') + should contain_file('/etc/puppi/projects/myapp/report/50-get').with_ensure('present') end it 'should populate correctly the puppi::report step file' do should contain_file('/etc/puppi/projects/myapp/report/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") diff --git a/spec/defines/rollback_spec.rb b/spec/defines/rollback_spec.rb index af7283b..617a648 100644 --- a/spec/defines/rollback_spec.rb +++ b/spec/defines/rollback_spec.rb @@ -20,7 +20,7 @@ describe 'Test puppi rollback step file creation' do it 'should create a puppi::rollback step file' do - should contain_file('/etc/puppi/projects/myapp/rollback/50-get').with_ensure('file') + should contain_file('/etc/puppi/projects/myapp/rollback/50-get').with_ensure('present') end it 'should populate correctly the puppi::rollback step file' do should contain_file('/etc/puppi/projects/myapp/rollback/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") diff --git a/spec/defines/ze_spec.rb b/spec/defines/ze_spec.rb index e327d97..cb6773c 100644 --- a/spec/defines/ze_spec.rb +++ b/spec/defines/ze_spec.rb @@ -18,7 +18,7 @@ describe 'Test puppi ze data file creation' do it 'should create a puppi::ze step file' do - should contain_file('puppize_sample').with_ensure('file') + should contain_file('puppize_sample').with_ensure('present') end end From b084fc9852d25918b3ce788627c7b363a94ca447 Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Wed, 25 Sep 2024 18:21:56 +0200 Subject: [PATCH 21/22] Final fixes --- README.md | 14 +++++++------- spec/defines/install_packages_spec.rb | 8 +++++--- spec/defines/project_spec.rb | 9 +++------ spec/defines/report_spec.rb | 2 +- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 79d4caa..51348ab 100644 --- a/README.md +++ b/README.md @@ -26,19 +26,19 @@ This module requires functions provided by the [Puppet Labs Stdlib Module](https Install the module from the Forge: -```bash {"id":"01J8MJ40BQWMDAJC3F710YREN4"} +```bash puppet module install example42/puppi ``` To use the Puppi just declare or include the puppi class -```ruby {"id":"01J8MJ40BQWMDAJC3F7286XQQK"} +```ruby include puppi ``` If you have resources conflicts, do not install automatically the Puppi dependencies (commands and packages) -```ruby {"id":"01J8MJ40BQWMDAJC3F72Q9E3VZ"} +```ruby class { 'puppi': install_dependencies => false, } @@ -50,7 +50,7 @@ Once Puppi is installed you can use it to: * Easily define in Puppet manifests Web Applications deploy procedures. For example: -```ruby {"id":"01J8MJ40BQWMDAJC3F748G9HWW"} +```ruby puppi::project::war { "myapp": source => "http://repo.example42.com/deploy/prod/myapp.war", deploy_root => "/opt/tomcat/myapp/webapps", @@ -68,7 +68,7 @@ Once enabled for each module you have puppi check, info and log commands. To enable Puppi integration in OldGen (version 1) Example42 Modules, set in the scope these variables: -```html {"id":"01J8MJ40BQWMDAJC3F74Q6B0KZ"} +```html $puppi = yes # Enables puppi integration $monitor = yes # Enables automatic monitoring $monitor_tool = "puppi" # Sets puppi as monitoring tool @@ -76,7 +76,7 @@ $monitor_tool = "puppi" # Sets puppi as monitoring tool ## USAGE OF THE PUPPI COMMAND (OLD GEN) -```bash {"id":"01J8MJ40BQWMDAJC3F7615PETB"} +```bash puppi [ -options ] ``` @@ -122,7 +122,7 @@ You can also provide some options: Some common puppi commands when you log for an application deployment: -```bash {"id":"01J8MJ40BQWMDAJC3F790N39R5"} +```bash puppi check puppi log & # (More readable if done on another window) puppi deploy myapp diff --git a/spec/defines/install_packages_spec.rb b/spec/defines/install_packages_spec.rb index b59b248..80ea66d 100644 --- a/spec/defines/install_packages_spec.rb +++ b/spec/defines/install_packages_spec.rb @@ -9,9 +9,11 @@ let(:title) { 'namevar' } let(:node) { 'rspec.example42.com' } let(:pre_condition) { 'include puppi' } - let(:params) do - {} - end + let(:params) { + { + 'packages' => 'top', + } + } it { is_expected.to compile } end end diff --git a/spec/defines/project_spec.rb b/spec/defines/project_spec.rb index 933ca97..39eca77 100644 --- a/spec/defines/project_spec.rb +++ b/spec/defines/project_spec.rb @@ -16,12 +16,9 @@ } } - describe 'Test puppi report step file creation' do - it 'should create a puppi::report step file' do - should contain_file('/etc/puppi/projects/myapp/report/50-get').with_ensure('present') - end - it 'should populate correctly the puppi::report step file' do - should contain_file('/etc/puppi/projects/myapp/report/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") + describe 'Test puppi project configuration file' do + it 'should create a puppi::project configuration file' do + should contain_file('/etc/puppi/projects/myapp/config').with_ensure('present') end end diff --git a/spec/defines/report_spec.rb b/spec/defines/report_spec.rb index 2201e27..e0cf299 100644 --- a/spec/defines/report_spec.rb +++ b/spec/defines/report_spec.rb @@ -20,7 +20,7 @@ describe 'Test puppi report step file creation' do it 'should create a puppi::report step file' do - should contain_file('/etc/puppi/projects/myapp/report/50-get').with_ensure('file') + should contain_file('/etc/puppi/projects/myapp/report/50-get').with_ensure('present') end it 'should populate correctly the puppi::report step file' do should contain_file('/etc/puppi/projects/myapp/report/50-get').with_content("su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n") From 932e7f2235544bd4773165472dd523d2b12b44bd Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Wed, 25 Sep 2024 18:26:12 +0200 Subject: [PATCH 22/22] Last? --- spec/defines/project_spec.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spec/defines/project_spec.rb b/spec/defines/project_spec.rb index 39eca77..d3afe5e 100644 --- a/spec/defines/project_spec.rb +++ b/spec/defines/project_spec.rb @@ -6,19 +6,18 @@ on_supported_os.select { |k, _v| k == 'redhat-8-x86_64' }.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } - let(:title) { 'puppi::project' } + let(:title) { 'get' } let(:node) { 'rspec.example42.com' } let(:pre_condition) { 'include puppi' } let(:params) { { 'enable' => 'true', - 'name' => 'get', } } describe 'Test puppi project configuration file' do it 'should create a puppi::project configuration file' do - should contain_file('/etc/puppi/projects/myapp/config').with_ensure('present') + should contain_file('/etc/puppi/projects/get/config').with_ensure('present') end end