From ae818c0ffc7c728765edfa216a6cf9c90040c911 Mon Sep 17 00:00:00 2001 From: zicklam Date: Fri, 6 Nov 2020 08:51:10 +0100 Subject: [PATCH 01/11] Update varnish.service.erb Starting varnish daemon after network is successfully up --- templates/varnish.service.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/varnish.service.erb b/templates/varnish.service.erb index 3b979e3..8476fa2 100644 --- a/templates/varnish.service.erb +++ b/templates/varnish.service.erb @@ -1,5 +1,6 @@ [Unit] Description=Varnish HTTP accelerator +After=network.target [Service] Type=forking From 3de60fc3f08d5b35e8ac5971909cb7603dbb1556 Mon Sep 17 00:00:00 2001 From: Steffy Fort Date: Mon, 17 Jan 2022 21:12:01 +0100 Subject: [PATCH 02/11] update pdk --- .devcontainer/Dockerfile | 6 + .devcontainer/README.md | 34 +++ .devcontainer/devcontainer.json | 17 ++ .gitignore | 4 + .pdkignore | 10 + .rubocop.yml | 419 +++++++++++++++++++++++++++++++- .sync.yml | 7 +- .travis.yml | 33 ++- .vscode/extensions.json | 6 + .yardopts | 1 + Gemfile | 31 +-- Rakefile | 33 ++- metadata.json | 6 +- spec/default_facts.yml | 1 + spec/spec_helper.rb | 28 ++- 15 files changed, 575 insertions(+), 61 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/README.md create mode 100644 .devcontainer/devcontainer.json create mode 100644 .vscode/extensions.json create mode 100644 .yardopts diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..12ed4ff --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,6 @@ +FROM puppet/pdk:latest + +# [Optional] Uncomment this section to install additional packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 0000000..cc4675e --- /dev/null +++ b/.devcontainer/README.md @@ -0,0 +1,34 @@ +# devcontainer + + +For format details, see https://aka.ms/devcontainer.json. + +For config options, see the README at: +https://github.com/microsoft/vscode-dev-containers/tree/v0.140.1/containers/puppet + +``` json +{ + "name": "Puppet Development Kit (Community)", + "dockerFile": "Dockerfile", + + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "puppet.puppet-vscode", + "rebornix.Ruby" + ] + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "pdk --version", +} +``` + + + diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..fe7a8b1 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,17 @@ +{ + "name": "Puppet Development Kit (Community)", + "dockerFile": "Dockerfile", + + "settings": { + "terminal.integrated.profiles.linux": { + "bash": { + "path": "bash", + } + } + }, + + "extensions": [ + "puppet.puppet-vscode", + "rebornix.Ruby" + ] +} diff --git a/.gitignore b/.gitignore index 6344515..3b01a93 100644 --- a/.gitignore +++ b/.gitignore @@ -22,5 +22,9 @@ /convert_report.txt /update_report.txt .DS_Store +.project +.envrc +/inventory.yaml +/spec/fixtures/litmus_inventory.yaml *.log convert_report.txt diff --git a/.pdkignore b/.pdkignore index b713b3b..c538bea 100644 --- a/.pdkignore +++ b/.pdkignore @@ -22,16 +22,26 @@ /convert_report.txt /update_report.txt .DS_Store +.project +.envrc +/inventory.yaml +/spec/fixtures/litmus_inventory.yaml /appveyor.yml +/.editorconfig /.fixtures.yml /Gemfile /.gitattributes /.gitignore /.gitlab-ci.yml /.pdkignore +/.puppet-lint.rc /Rakefile +/rakelib/ /.rspec /.rubocop.yml /.travis.yml /.yardopts /spec/ +/.vscode/ +/.sync.yml +/.devcontainer/ diff --git a/.rubocop.yml b/.rubocop.yml index f5a6c2a..8f782e7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,10 +1,12 @@ --- -require: rubocop-rspec +require: +- rubocop-performance +- rubocop-rspec AllCops: DisplayCopNames: true - TargetRubyVersion: '2.1' + TargetRubyVersion: '2.4' Include: - - "./**/*.rb" + - "**/*.rb" Exclude: - bin/* - ".vendor/**/*" @@ -16,13 +18,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 +29,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 +64,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 +79,170 @@ 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/InsecureProtocolSource: + 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 +255,265 @@ 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/CurrentPathExpectation: + Enabled: false +RSpec/Capybara/FeatureMethods: + Enabled: false +RSpec/Capybara/VisibilityMatcher: + 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/MissingExampleGroupArgument: Enabled: false RSpec/MultipleExpectations: Enabled: false +RSpec/MultipleMemoizedHelpers: + Enabled: false +RSpec/MultipleSubjects: + Enabled: false RSpec/NestedGroups: Enabled: false +RSpec/PredicateMatcher: + Enabled: false +RSpec/ReceiveCounts: + Enabled: false +RSpec/ReceiveNever: + Enabled: false +RSpec/RepeatedExampleGroupBody: + Enabled: false +RSpec/RepeatedExampleGroupDescription: + Enabled: false +RSpec/RepeatedIncludeExample: + Enabled: false +RSpec/ReturnFromStub: + Enabled: false +RSpec/SharedExamples: + Enabled: false +RSpec/StubbedMock: + Enabled: false +RSpec/UnspecifiedException: + Enabled: false +RSpec/VariableDefinition: + Enabled: false +RSpec/VoidExpect: + Enabled: false +RSpec/Yield: + Enabled: false +Security/Open: + Enabled: false +Style/AccessModifierDeclarations: + Enabled: false +Style/AccessorGrouping: + Enabled: false Style/AsciiComments: 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 +Lint/DuplicateBranch: + Enabled: false +Lint/DuplicateRegexpCharacterClassElement: + Enabled: false +Lint/EmptyBlock: + Enabled: false +Lint/EmptyClass: + Enabled: false +Lint/NoReturnInBeginEndBlocks: + Enabled: false +Lint/ToEnumArguments: + Enabled: false +Lint/UnexpectedBlockArity: + Enabled: false +Lint/UnmodifiedReduceAccumulator: + Enabled: false +Performance/CollectionLiteralInLoop: + Enabled: false +Style/ArgumentsForwarding: + Enabled: false +Style/CollectionCompact: + Enabled: false +Style/DocumentDynamicEvalDefinition: + Enabled: false +Style/NegatedIfElseCondition: + Enabled: false +Style/NilLambda: + Enabled: false +Style/RedundantArgument: + Enabled: false +Style/SwapValues: + Enabled: false diff --git a/.sync.yml b/.sync.yml index 5040ef4..d2b20c5 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,14 +1,11 @@ --- .gitignore: paths: - - '*.log' - - 'convert_report.txt' + - '*.log' + - 'convert_report.txt' .gitlab-ci.yml: delete: true appveyor.yml: delete: true - -.yardopts: - delete: true diff --git a/.travis.yml b/.travis.yml index 521510d..4e587cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,31 +1,42 @@ --- -dist: trusty +os: linux +dist: xenial language: ruby cache: bundler before_install: - bundle -v - rm -f Gemfile.lock - - gem update --system $RUBYGEMS_VERSION + - "# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner" + - "# See https://github.com/puppetlabs/pdk-templates/commit/705154d5c437796b821691b707156e1b056d244f for an example of how this was used" + - "# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set" + - '[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION' - gem --version - bundle -v script: - 'bundle exec rake $CHECK' bundler_args: --without system_tests rvm: - - 2.5.1 -env: - global: - - BEAKER_PUPPET_COLLECTION=puppet6 PUPPET_GEM_VERSION="~> 6.0" -matrix: + - 2.5.7 +stages: + - static + - spec + - acceptance + - + if: tag =~ ^v\d + name: deploy +jobs: fast_finish: true include: - - env: CHECK="syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop" + env: CHECK="validate lint check rubocop" + stage: static - - env: CHECK=parallel_spec + env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec + rvm: 2.5.7 + stage: spec - - env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec - rvm: 2.4.4 + env: DEPLOY_TO_FORGE=yes + stage: deploy branches: only: - master diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..2f1e4f7 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "puppet.puppet-vscode", + "rebornix.Ruby" + ] +} diff --git a/.yardopts b/.yardopts new file mode 100644 index 0000000..29c933b --- /dev/null +++ b/.yardopts @@ -0,0 +1 @@ +--markup markdown diff --git a/Gemfile b/Gemfile index cf2c387..a167b88 100644 --- a/Gemfile +++ b/Gemfile @@ -17,16 +17,17 @@ ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments minor_version = ruby_version_segments[0..1].join('.') group :development do - gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') - gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') - gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') - gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') - gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "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.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 2.8.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "puppet-module-posix-default-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby] + gem "puppet-module-posix-dev-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby] + gem "puppet-module-win-default-r#{minor_version}", '~> 1.0', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "puppet-module-win-dev-r#{minor_version}", '~> 1.0', require: false, platforms: [:mswin, :mingw, :x64_mingw] +end +group :system_tests do + gem "puppet-module-posix-system-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby] + gem "puppet-module-win-system-r#{minor_version}", '~> 1.0', require: false, platforms: [:mswin, :mingw, :x64_mingw] end puppet_version = ENV['PUPPET_GEM_VERSION'] @@ -43,16 +44,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..0f8754e 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,7 @@ +# frozen_string_literal: true + +require 'bundler' +require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? 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? @@ -14,15 +18,24 @@ 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? + + returnVal = nil + returnVal ||= begin + metadata_source = JSON.load(File.read('metadata.json'))['source'] + metadata_source_match = metadata_source && metadata_source.match(%r{.*\/([^\/]*?)(?:\.git)?\Z}) + + metadata_source_match && metadata_source_match[1] + end + + raise "unable to find the changelog_project in .sync.yml or calculate it from the source 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'] + returnVal = "v%s" % 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 @@ -30,6 +43,7 @@ end 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? @@ -40,7 +54,7 @@ if Bundler.rubygems.find_name('github_changelog_generator').any? config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)." config.add_pr_wo_labels = true config.issues = false - config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM" + config.merge_prefix = "### UNCATEGORIZED PRS; LABEL THEM ON GITHUB" config.configure_sections = { "Changed" => { "prefix" => "### Changed", @@ -48,11 +62,11 @@ if Bundler.rubygems.find_name('github_changelog_generator').any? }, "Added" => { "prefix" => "### Added", - "labels" => ["feature", "enhancement"], + "labels" => ["enhancement", "feature"], }, "Fixed" => { "prefix" => "### Fixed", - "labels" => ["bugfix"], + "labels" => ["bug", "documentation", "bugfix"], }, } end @@ -60,16 +74,15 @@ else desc 'Generate a Changelog from GitHub' task :changelog do raise <= Gem::Version.new('2.2.2')" + version: '~> 1.15' + condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0')" EOM end end diff --git a/metadata.json b/metadata.json index 7ac4b9d..c20a75d 100644 --- a/metadata.json +++ b/metadata.json @@ -83,7 +83,7 @@ "cache", "http" ], - "pdk-version": "1.9.0", - "template-url": "file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git", - "template-ref": "1.9.0-0-g7281db5" + "pdk-version": "2.3.0", + "template-url": "pdk-default#2.3.0", + "template-ref": "tags/2.3.0-0-g8aaceff" } diff --git a/spec/default_facts.yml b/spec/default_facts.yml index ea1e480..f777abf 100644 --- a/spec/default_facts.yml +++ b/spec/default_facts.yml @@ -3,5 +3,6 @@ # Facts specified here will override the values provided by rspec-puppet-facts. --- ipaddress: "172.16.254.254" +ipaddress6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" is_pe: false macaddress: "AA:AA:AA:AA:AA:AA" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0d5efc0..9b1fa6f 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,24 +25,44 @@ next unless File.exist?(f) && File.readable?(f) && File.size?(f) begin - default_facts.merge!(YAML.safe_load(File.read(f))) + default_facts.merge!(YAML.safe_load(File.read(f), [], [], true)) rescue => 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 +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 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 fc6111139e2d8748b14ba02540bfabd7100f21b5 Mon Sep 17 00:00:00 2001 From: Steffy Fort Date: Mon, 17 Jan 2022 23:40:15 +0100 Subject: [PATCH 03/11] review all spec --- spec/classes/varnish_spec.rb | 408 ++++++++++++++++++++++++++--------- spec/default_facts.yml | 1 + 2 files changed, 303 insertions(+), 106 deletions(-) diff --git a/spec/classes/varnish_spec.rb b/spec/classes/varnish_spec.rb index b4a86a1..2f838a5 100644 --- a/spec/classes/varnish_spec.rb +++ b/spec/classes/varnish_spec.rb @@ -1,137 +1,333 @@ require 'spec_helper' describe 'varnish', type: :class do - ['3.0', '4.0', '4.1', '5.0', '5.1', '5.2', '6.0', '6.0lts', '6.1'].each do |version| - on_supported_os.each do |os, facts| - context "Varnish #{version} on #{os}" do - let(:facts) do - facts.merge(path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/snap/bin:/opt/puppetlabs/bin') + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) { facts } + it { is_expected.to compile.with_all_deps } + + # Temporary variable before remove init support + systemd = ( + facts[:os]['family'] == 'RedHat' && + facts[:os]['release']['major'].to_i >= 7 + ) || ( + facts[:os]['release']['name'] == 'Ubuntu' && + facts[:os]['release']['major'].to_f >- 16.04 + ) || ( + facts[:os]['release']['name'] == 'Debian' && + facts[:os]['release']['major'].to_i >= 8 + ) + + context 'with default params' do + it { is_expected.to contain_class('varnish::params') } + it { is_expected.to contain_class('varnish::repo') } + it { is_expected.to contain_class('varnish::install') } + it { is_expected.to contain_class('varnish::secret') } + it { is_expected.to contain_class('varnish::config') } + it { is_expected.to contain_class('varnish::service') } + + if facts[:os]['family'] == 'RedHat' + it { is_expected.to contain_class('epel') } + + it do + is_expected.to contain_yumrepo('varnish-cache').with( + descr: 'varnishcache_varnish41', + baseurl: format( + 'https://packagecloud.io/varnishcache/varnish41/el/%s/$basearch', + facts[:os]['release']['major'], + ), + gpgkey: 'https://packagecloud.io/varnishcache/varnish41/gpgkey', + metadata_expire: '300', + repo_gpgcheck: '1', + gpgcheck: '0', + sslverify: '1', + sslcacert: '/etc/pki/tls/certs/ca-bundle.crt' + ) + end + + it do + is_expected.to contain_yumrepo('varnish-cache-source').with( + descr: 'varnishcache_varnish41-source', + baseurl: format( + 'https://packagecloud.io/varnishcache/varnish41/el/%s/SRPMS', + facts[:os]['release']['major'], + ), + gpgkey: 'https://packagecloud.io/varnishcache/varnish41/gpgkey', + metadata_expire: '300', + repo_gpgcheck: '1', + gpgcheck: '0', + sslverify: '1', + sslcacert: '/etc/pki/tls/certs/ca-bundle.crt' + ) + end + else + it { is_expected.to contain_package('apt-transport-https') } + + it do + is_expected.to contain_apt__source('varnish-cache').with( + comment: 'Apt source for Varnish 4.1', + location: format( + 'https://packagecloud.io/varnishcache/varnish41/%s/', + facts[:os]['name'].downcase + ), + repos: 'main', + require: 'Package[apt-transport-https]', + key: { + 'source' => 'https://packagecloud.io/varnishcache/varnish41/gpgkey', + 'id' => '9C96F9CA0DC3F4EA78FF332834BF6E8ECBF5C49E', + }, + include: { + 'deb' => true, + 'src' => true, + } + ) + end end - let(:params) do - { - varnish_version: version, - } + it { is_expected.to contain_package('varnish') } + + it do + is_expected.to contain_file('/etc/varnish/secret').with( + owner: 'root', + group: 'varnish', + mode: '0640' + ) + end + + it do + is_expected.to contain_exec('Generate Varnish secret file').with( + unless: "/bin/egrep '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$' '/etc/varnish/secret' >/dev/null", + command: "/bin/cp /proc/sys/kernel/random/uuid '/etc/varnish/secret'" + ) + end + + it do + sysconfig = if facts[:os]['family'] == 'RedHat' + '/etc/sysconfig/varnish' + else + '/etc/default/varnish' + end + is_expected.to contain_file(sysconfig).with( + owner: 'root', + group: 'root', + mode: '0644' + ) end - should_fail = 0 - case version - when '3.0' - if facts[:operatingsystem] == 'Ubuntu' && Gem::Version.new(facts[:operatingsystemmajrelease]) >= Gem::Version.new('16.04') - it { is_expected.to raise_error(Puppet::Error, %r{Varnish 3 from Packagecloud is not supported after Ubuntu 14.04 \(Trusty\)}) } - should_fail = 1 + varnish_reload = if facts[:os]['family'] == 'RedHat' + '/usr/sbin/varnish_reload_vcl' + else + '/usr/share/varnish/reload-vcl -q' + end + + if systemd + it do + is_expected.to contain_file('/etc/systemd/system/varnish.service'). + with( + ensure: 'file', + owner: 'root', + group: 'root', + mode: '0644', + notify: 'Exec[varnish_systemctl_daemon_reload]', + content: < 'https://packagecloud.io/varnishcache/varnish60lts/gpgkey', + 'id' => '48D81A24CB0456F5D59431D94CFCFD6BA750EDCD' + } + ) + end + end + end + end end end end diff --git a/spec/default_facts.yml b/spec/default_facts.yml index f777abf..98bc25a 100644 --- a/spec/default_facts.yml +++ b/spec/default_facts.yml @@ -6,3 +6,4 @@ ipaddress: "172.16.254.254" ipaddress6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" is_pe: false macaddress: "AA:AA:AA:AA:AA:AA" +path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin' From c8dfba80a119f4225a13af0015e12853cae147ba Mon Sep 17 00:00:00 2001 From: fe80 Date: Thu, 20 Jan 2022 16:48:30 +0100 Subject: [PATCH 04/11] update with modulesync 5.1.0 --- .editorconfig | 15 + .fixtures.yml | 3 +- .github/CONTRIBUTING.md | 242 ++++++++++++-- .github/PULL_REQUEST_TEMPLATE.md | 12 + .github/workflows/ci.yml | 66 ++++ .github/workflows/release.yml | 34 ++ .gitignore | 49 ++- .msync.yml | 5 + .overcommit.yml | 65 ++++ .pdkignore | 47 --- .pmtignore | 37 +++ .puppet-lint.rc | 4 +- .rspec | 5 +- .rspec_parallel | 3 + .rubocop.yml | 523 +------------------------------ .travis.yml | 54 ---- .yardopts | 1 - Dockerfile | 24 ++ Gemfile | 74 ++--- Rakefile | 133 ++++---- spec/classes/coverage_spec.rb | 3 - spec/default_facts.yml | 9 - spec/spec_helper.rb | 76 +---- 23 files changed, 595 insertions(+), 889 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml create mode 100644 .msync.yml create mode 100644 .overcommit.yml delete mode 100644 .pdkignore create mode 100644 .pmtignore delete mode 100644 .travis.yml delete mode 100644 .yardopts create mode 100644 Dockerfile delete mode 100644 spec/classes/coverage_spec.rb delete mode 100644 spec/default_facts.yml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ecb10a8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# editorconfig.org + +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +tab_width = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/.fixtures.yml b/.fixtures.yml index 57d338a..3b8dd93 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,3 +1,4 @@ +--- fixtures: repositories: stdlib: @@ -18,5 +19,3 @@ fixtures: selinux_core: repo: "https://github.com/puppetlabs/puppetlabs-selinux_core.git" ref: "1.0.1" - symlinks: - varnish: "#{source_dir}" diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 8dda79b..048d2b5 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,31 +1,116 @@ +# Contribution guidelines + +## Table of contents + +* [Contributing](#contributing) +* [Writing proper commits - short version](#writing-proper-commits-short-version) +* [Writing proper commits - long version](#writing-proper-commits-long-version) +* [Dependencies](#dependencies) + * [Note for OS X users](#note-for-os-x-users) +* [The test matrix](#the-test-matrix) +* [Syntax and style](#syntax-and-style) +* [Running the unit tests](#running-the-unit-tests) +* [Unit tests in docker](#unit-tests-in-docker) +* [Integration tests](#integration-tests) + This module has grown over time based on a range of contributions from people using it. If you follow these contributing guidelines your patch -will likely make it into a release a little quicker. +will likely make it into a release a little more quickly. ## Contributing -Please note that this project has adopted the [Voxpupuli Contributor Code of Conduct](https://voxpupuli.org/coc/). +Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. -. - -1. Fork the repo. - -1. Create a separate branch for your change. - -1. Run the tests. Only pull requests with passing tests, and documentation will - be merged. - -1. Add a test for your change. Only refactoring and documentation - changes require no new tests. If you are adding functionality - or fixing a bug, please add a test. - -1. Squash your commits down into logical components. Make sure to rebase - against the current master. - -1. Push the branch to your fork and submit a pull request. - -Please be prepared to repeat some of these steps as our contributors review -your code. +[Contributor Code of Conduct](https://voxpupuli.org/coc/). + +* Fork the repo. +* Create a separate branch for your change. +* We only take pull requests with passing tests, and documentation. [GitHub Actions](https://docs.github.com/en/actions) run the tests for us. You can also execute them locally. This is explained [in a later section](#the-test-matrix). +* Checkout [our docs](https://voxpupuli.org/docs/reviewing_pr/) we use to review a module and the [official styleguide](https://puppet.com/docs/puppet/6.0/style_guide.html). They provide some guidance for new code that might help you before you submit a pull request. +* Add a test for your change. Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, please add a test. +* Squash your commits down into logical components. Make sure to rebase against our current master. +* Push the branch to your fork and submit a pull request. + +Please be prepared to repeat some of these steps as our contributors review your code. + +Also consider sending in your profile code that calls this component module as an acceptance test or provide it via an issue. This helps reviewers a lot to test your use case and prevents future regressions! + +## Writing proper commits - short version + +* Make commits of logical units. +* Check for unnecessary whitespace with "git diff --check" before committing. +* Commit using Unix line endings (check the settings around "crlf" in git-config(1)). +* Do not check in commented out code or unneeded files. +* The first line of the commit message should be a short description (50 characters is the soft limit, excluding ticket number(s)), and should skip the full stop. +* Associate the issue in the message. The first line should include the issue number in the form "(#XXXX) Rest of message". +* The body should provide a meaningful commit message, which: + *uses the imperative, present tense: `change`, not `changed` or `changes`. + * includes motivation for the change, and contrasts its implementation with the previous behavior. + * Make sure that you have tests for the bug you are fixing, or feature you are adding. + * Make sure the test suites passes after your commit: + * When introducing a new feature, make sure it is properly documented in the README.md + +## Writing proper commits - long version + + 1. Make separate commits for logically separate changes. + + Please break your commits down into logically consistent units + which include new or changed tests relevant to the rest of the + change. The goal of doing this is to make the diff easier to + read for whoever is reviewing your code. In general, the easier + your diff is to read, the more likely someone will be happy to + review it and get it into the code base. + + If you are going to refactor a piece of code, please do so as a + separate commit from your feature or bug fix changes. + + We also really appreciate changes that include tests to make + sure the bug is not re-introduced, and that the feature is not + accidentally broken. + + Describe the technical detail of the change(s). If your + description starts to get too long, that is a good sign that you + probably need to split up your commit into more finely grained + pieces. + + Commits which plainly describe the things which help + reviewers check the patch and future developers understand the + code are much more likely to be merged in with a minimum of + bike-shedding or requested changes. Ideally, the commit message + would include information, and be in a form suitable for + inclusion in the release notes for the version of Puppet that + includes them. + + Please also check that you are not introducing any trailing + whitespace or other "whitespace errors". You can do this by + running "git diff --check" on your changes before you commit. + + 2. Sending your patches + + To submit your changes via a GitHub pull request, we _highly_ + recommend that you have them on a topic branch, instead of + directly on `master`. + It makes things much easier to keep track of, especially if + you decide to work on another thing before your first change + is merged in. + + GitHub has some pretty good + [general documentation](http://help.github.com/) on using + their site. They also have documentation on + [creating pull requests](http://help.github.com/send-pull-requests/). + + In general, after pushing your topic branch up to your + repository on GitHub, you can switch to the branch in the + GitHub UI and click "Pull Request" towards the top of the page + in order to open a pull request. + + + 3. Update the related GitHub issue. + + If there is a GitHub issue associated with the change you + submitted, then you should update the ticket to include the + location of your branch, along with any other commentary you + may wish to make. ## Dependencies @@ -38,41 +123,130 @@ By default the tests use a baseline version of Puppet. If you have Ruby 2.x or want a specific version of Puppet, you must set an environment variable such as: - export PUPPET_VERSION="~> 4.2.0" +```sh +export PUPPET_VERSION="~> 5.5.6" +``` + +You can install all needed gems for spec tests into the modules directory by +running: + +```sh +bundle install --path .vendor/ --without development system_tests release --jobs "$(nproc)" +``` + +If you also want to run acceptance tests: + +```sh +bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)" +``` + +Our all in one solution if you don't know if you need to install or update gems: + +```sh +bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)"; bundle update; bundle clean +``` + +As an alternative to the `--jobs "$(nproc)` parameter, you can set an +environment variable: -Install the dependencies like so... +```sh +BUNDLE_JOBS="$(nproc)" +``` - bundle install +### Note for OS X users -## Syntax and style +`nproc` isn't a valid command under OS x. As an alternative, you can do: + +```sh +--jobs "$(sysctl -n hw.ncpu)" +``` + +## The test matrix + +### Syntax and style The test suite will run [Puppet Lint](http://puppet-lint.com/) and [Puppet Syntax](https://github.com/gds-operations/puppet-syntax) to check various syntax and style things. You can run these locally with: - bundle exec rake lint - bundle exec rake validate +```sh +bundle exec rake lint +bundle exec rake validate +``` It will also run some [Rubocop](http://batsov.com/rubocop/) tests against it. You can run those locally ahead of time with: - bundle exec rake rubocop +```sh +bundle exec rake rubocop +``` -## Running the unit tests +### Running the unit tests The unit test suite covers most of the code, as mentioned above please add tests if you're adding new functionality. If you've not used [rspec-puppet](http://rspec-puppet.com/) before then feel free to ask about how best to test your new feature. +To run the linter, the syntax checker and the unit tests: + +```sh +bundle exec rake test +``` + To run your all the unit tests - bundle exec rake spec SPEC_OPTS='--format documentation' +```sh +bundle exec rake spec +``` To run a specific spec test set the `SPEC` variable: - bundle exec rake spec SPEC=spec/foo_spec.rb +```sh +bundle exec rake spec SPEC=spec/foo_spec.rb +``` -To run the linter, the syntax checker and the unit tests: +#### Unit tests in docker + +Some people don't want to run the dependencies locally or don't want to install +ruby. We ship a Dockerfile that enables you to run all unit tests and linting. +You only need to run: + +```sh +docker build . +``` + +Please ensure that a docker daemon is running and that your user has the +permission to talk to it. You can specify a remote docker host by setting the +`DOCKER_HOST` environment variable. it will copy the content of the module into +the docker image. So it will not work if a Gemfile.lock exists. + +### Integration tests + +The unit tests just check the code runs, not that it does exactly what +we want on a real machine. For that we're using +[beaker](https://github.com/puppetlabs/beaker). + +This fires up a new virtual machine (using vagrant) and runs a series of +simple tests against it after applying the module. You can run this +with: + +```sh +BEAKER_setfile=debian10-x64 bundle exec rake beaker +``` + +You can replace the string `debian10` with any common operating system. +The following strings are known to work: + +* ubuntu1604 +* ubuntu1804 +* ubuntu2004 +* debian9 +* debian10 +* centos7 +* centos8 + +For more information and tips & tricks, see [voxpupuli-acceptance's documentation](https://github.com/voxpupuli/voxpupuli-acceptance#running-tests). - bundle exec rake test +The source of this file is in our [modulesync_config](https://github.com/voxpupuli/modulesync_config/blob/master/moduleroot/.github/CONTRIBUTING.md.erb) +repository. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 66f8044..342807b 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -6,3 +6,15 @@ Thank you for contributing to this project! - Our vulnerabilities reporting process is at https://voxpupuli.org/security/ --> +#### Pull Request (PR) description + + +#### This Pull Request (PR) fixes the following issues + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c5dad05 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,66 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: CI + +on: pull_request + +concurrency: + group: ${{ github.head_ref }} + cancel-in-progress: true + +jobs: + setup_matrix: + name: 'Setup Test Matrix' + runs-on: ubuntu-latest + timeout-minutes: 40 + outputs: + puppet_unit_test_matrix: ${{ steps.get-outputs.outputs.puppet_unit_test_matrix }} + github_action_test_matrix: ${{ steps.get-outputs.outputs.github_action_test_matrix }} + env: + BUNDLE_WITHOUT: development:system_tests:release + steps: + - uses: actions/checkout@v2 + - name: Setup ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.0' + bundler-cache: true + - name: Run static validations + run: bundle exec rake validate lint check + - name: Run rake rubocop + run: bundle exec rake rubocop + - name: Setup Test Matrix + id: get-outputs + run: bundle exec metadata2gha --use-fqdn --pidfile-workaround false + + unit: + needs: setup_matrix + runs-on: ubuntu-latest + timeout-minutes: 40 + strategy: + fail-fast: false + matrix: + include: ${{fromJson(needs.setup_matrix.outputs.puppet_unit_test_matrix)}} + env: + BUNDLE_WITHOUT: development:system_tests:release + PUPPET_VERSION: "~> ${{ matrix.puppet }}.0" + name: Puppet ${{ matrix.puppet }} (Ruby ${{ matrix.ruby }}) + steps: + - uses: actions/checkout@v2 + - name: Setup ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - name: Run tests + run: bundle exec rake parallel_spec + + tests: + needs: + - unit + runs-on: ubuntu-latest + name: Test suite + steps: + - run: echo Test suite completed diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a78d2d6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +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 == 'fe80' + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '2.7' + bundler-cache: true + - name: Build and Deploy + env: + # Configure secrets here: + # https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets + BLACKSMITH_FORGE_USERNAME: '${{ secrets.PUPPET_FORGE_USERNAME }}' + BLACKSMITH_FORGE_API_KEY: '${{ secrets.PUPPET_FORGE_API_KEY }}' + run: bundle exec rake module:push diff --git a/.gitignore b/.gitignore index 3b01a93..59a6173 100644 --- a/.gitignore +++ b/.gitignore @@ -1,30 +1,25 @@ -.git/ -.*.sw[op] -.metadata -.yardoc -.yardwarns +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +pkg/ +Gemfile.lock +Gemfile.local +vendor/ +.vendor/ +spec/fixtures/manifests/ +spec/fixtures/modules/ +.vagrant/ +.bundle/ +.ruby-version +coverage/ +log/ +.idea/ +.dependencies/ +.librarian/ +Puppetfile.lock *.iml -/.bundle/ -/.idea/ -/.vagrant/ -/coverage/ -/bin/ -/doc/ -/Gemfile.local -/Gemfile.lock -/junit/ -/log/ -/pkg/ -/spec/fixtures/manifests/ -/spec/fixtures/modules/ -/tmp/ -/vendor/ -/convert_report.txt -/update_report.txt -.DS_Store -.project -.envrc -/inventory.yaml -/spec/fixtures/litmus_inventory.yaml +.*.sw? +.yardoc/ +Guardfile *.log convert_report.txt diff --git a/.msync.yml b/.msync.yml new file mode 100644 index 0000000..a83abd9 --- /dev/null +++ b/.msync.yml @@ -0,0 +1,5 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +modulesync_config_version: '5.1.0' diff --git a/.overcommit.yml b/.overcommit.yml new file mode 100644 index 0000000..d367ada --- /dev/null +++ b/.overcommit.yml @@ -0,0 +1,65 @@ +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ +# +# Hooks are only enabled if you take action. +# +# To enable the hooks run: +# +# ``` +# bundle exec overcommit --install +# # ensure .overcommit.yml does not harm to you and then +# bundle exec overcommit --sign +# ``` +# +# (it will manage the .git/hooks directory): +# +# Examples howto skip a test for a commit or push: +# +# ``` +# SKIP=RuboCop git commit +# SKIP=PuppetLint git commit +# SKIP=RakeTask git push +# ``` +# +# Don't invoke overcommit at all: +# +# ``` +# OVERCOMMIT_DISABLE=1 git commit +# ``` +# +# Read more about overcommit: https://github.com/brigade/overcommit +# +# To manage this config yourself in your module add +# +# ``` +# .overcommit.yml: +# unmanaged: true +# ``` +# +# to your modules .sync.yml config +--- +PreCommit: + RuboCop: + enabled: true + description: 'Runs rubocop on modified files only' + command: ['bundle', 'exec', 'rubocop'] + PuppetLint: + enabled: true + description: 'Runs puppet-lint on modified files only' + command: ['bundle', 'exec', 'puppet-lint'] + YamlSyntax: + enabled: true + JsonSyntax: + enabled: true + TrailingWhitespace: + enabled: true + +PrePush: + RakeTarget: + enabled: true + description: 'Run rake targets' + targets: + - 'validate' + - 'test' + - 'rubocop' + command: ['bundle', 'exec', 'rake'] diff --git a/.pdkignore b/.pdkignore deleted file mode 100644 index c538bea..0000000 --- a/.pdkignore +++ /dev/null @@ -1,47 +0,0 @@ -.git/ -.*.sw[op] -.metadata -.yardoc -.yardwarns -*.iml -/.bundle/ -/.idea/ -/.vagrant/ -/coverage/ -/bin/ -/doc/ -/Gemfile.local -/Gemfile.lock -/junit/ -/log/ -/pkg/ -/spec/fixtures/manifests/ -/spec/fixtures/modules/ -/tmp/ -/vendor/ -/convert_report.txt -/update_report.txt -.DS_Store -.project -.envrc -/inventory.yaml -/spec/fixtures/litmus_inventory.yaml -/appveyor.yml -/.editorconfig -/.fixtures.yml -/Gemfile -/.gitattributes -/.gitignore -/.gitlab-ci.yml -/.pdkignore -/.puppet-lint.rc -/Rakefile -/rakelib/ -/.rspec -/.rubocop.yml -/.travis.yml -/.yardopts -/spec/ -/.vscode/ -/.sync.yml -/.devcontainer/ diff --git a/.pmtignore b/.pmtignore new file mode 100644 index 0000000..65f5051 --- /dev/null +++ b/.pmtignore @@ -0,0 +1,37 @@ +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +docs/ +pkg/ +Gemfile +Gemfile.lock +Gemfile.local +vendor/ +.vendor/ +spec/ +Rakefile +.vagrant/ +.bundle/ +.ruby-version +coverage/ +log/ +.idea/ +.dependencies/ +.github/ +.librarian/ +Puppetfile.lock +*.iml +.editorconfig +.fixtures.yml +.gitignore +.msync.yml +.overcommit.yml +.pmtignore +.rspec +.rspec_parallel +.rubocop.yml +.sync.yml +.*.sw? +.yardoc/ +.yardopts +Dockerfile diff --git a/.puppet-lint.rc b/.puppet-lint.rc index cc96ece..dd8272c 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1 +1,3 @@ ---relative +--fail-on-warnings +--no-parameter_documentation-check +--no-parameter_types-check diff --git a/.rspec b/.rspec index 16f9cdb..f634583 100644 --- a/.rspec +++ b/.rspec @@ -1,2 +1,5 @@ ---color +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + --format documentation +--color diff --git a/.rspec_parallel b/.rspec_parallel index e4d136b..a9a84f8 100644 --- a/.rspec_parallel +++ b/.rspec_parallel @@ -1 +1,4 @@ +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + --format progress diff --git a/.rubocop.yml b/.rubocop.yml index 8f782e7..53ac189 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,519 +1,6 @@ --- -require: -- rubocop-performance -- rubocop-rspec -AllCops: - DisplayCopNames: true - TargetRubyVersion: '2.4' - Include: - - "**/*.rb" - Exclude: - - bin/* - - ".vendor/**/*" - - "**/Gemfile" - - "**/Rakefile" - - pkg/**/* - - spec/fixtures/**/* - - vendor/**/* - - "**/Puppetfile" - - "**/Vagrantfile" - - "**/Guardfile" -Layout/LineLength: - Description: People have wide screens, use them. - Max: 200 -RSpec/BeforeAfterAll: - Description: Beware of using after(:all) as it may cause state to leak between tests. - A necessary evil in acceptance testing. - Exclude: - - spec/acceptance/**/*.rb -RSpec/HookArgument: - Description: Prefer explicit :each argument, matching existing module's style - EnforcedStyle: each -RSpec/DescribeSymbol: - Exclude: - - spec/unit/facter/**/*.rb -Style/BlockDelimiters: - Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to - be consistent then. - EnforcedStyle: braces_for_chaining -Style/ClassAndModuleChildren: - Description: Compact style reduces the required amount of indentation. - EnforcedStyle: compact -Style/EmptyElse: - Description: Enforce against empty else clauses, but allow `nil` for clarity. - EnforcedStyle: empty -Style/FormatString: - Description: Following the main puppet project's style, prefer the % format format. - EnforcedStyle: percent -Style/FormatStringToken: - Description: Following the main puppet project's style, prefer the simpler template - tokens over annotated ones. - EnforcedStyle: template -Style/Lambda: - Description: Prefer the keyword for easier discoverability. - EnforcedStyle: literal -Style/RegexpLiteral: - Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168 - EnforcedStyle: percent_r -Style/TernaryParentheses: - Description: Checks for use of parentheses around ternary conditions. Enforce parentheses - on complex expressions for better readability, but seriously consider breaking - it up. - EnforcedStyle: require_parentheses_when_complex -Style/TrailingCommaInArguments: - Description: Prefer always trailing comma on multiline argument lists. This makes - diffs, and re-ordering nicer. - EnforcedStyleForMultiline: comma -Style/TrailingCommaInArrayLiteral: - Description: Prefer always trailing comma on multiline literals. This makes diffs, - and re-ordering nicer. - EnforcedStyleForMultiline: comma -Style/SymbolArray: - Description: Using percent style obscures symbolic intent of array's contents. - EnforcedStyle: brackets -RSpec/MessageSpies: - EnforcedStyle: receive -Style/Documentation: - Exclude: - - lib/puppet/parser/functions/**/* - - spec/**/* -Style/WordArray: - EnforcedStyle: brackets -Performance/AncestorsInclude: - Enabled: true -Performance/BigDecimalWithNumericArgument: - Enabled: true -Performance/BlockGivenWithExplicitBlock: - Enabled: true -Performance/CaseWhenSplat: - Enabled: true -Performance/ConstantRegexp: - Enabled: true -Performance/MethodObjectAsBlock: - Enabled: true -Performance/RedundantSortBlock: - Enabled: true -Performance/RedundantStringChars: - Enabled: true -Performance/ReverseFirst: - Enabled: true -Performance/SortReverse: - Enabled: true -Performance/Squeeze: - Enabled: true -Performance/StringInclude: - Enabled: true -Performance/Sum: - Enabled: true -Style/CollectionMethods: - Enabled: true -Style/MethodCalledOnDoEndBlock: - Enabled: true -Style/StringMethods: - Enabled: true -Bundler/InsecureProtocolSource: - Enabled: false -Gemspec/DuplicatedAssignment: - Enabled: false -Gemspec/OrderedDependencies: - Enabled: false -Gemspec/RequiredRubyVersion: - Enabled: false -Gemspec/RubyVersionGlobalsUsage: - Enabled: false -Layout/ArgumentAlignment: - Enabled: false -Layout/BeginEndAlignment: - Enabled: false -Layout/ClosingHeredocIndentation: - Enabled: false -Layout/EmptyComment: - Enabled: false -Layout/EmptyLineAfterGuardClause: - Enabled: false -Layout/EmptyLinesAroundArguments: - Enabled: false -Layout/EmptyLinesAroundAttributeAccessor: - Enabled: false -Layout/EndOfLine: - Enabled: false -Layout/FirstArgumentIndentation: - Enabled: false -Layout/HashAlignment: - Enabled: false -Layout/HeredocIndentation: - Enabled: false -Layout/LeadingEmptyLines: - Enabled: false -Layout/SpaceAroundMethodCallOperator: - Enabled: false -Layout/SpaceInsideArrayLiteralBrackets: - Enabled: false -Layout/SpaceInsideReferenceBrackets: - Enabled: false -Lint/BigDecimalNew: - Enabled: false -Lint/BooleanSymbol: - Enabled: false -Lint/ConstantDefinitionInBlock: - Enabled: false -Lint/DeprecatedOpenSSLConstant: - Enabled: false -Lint/DisjunctiveAssignmentInConstructor: - Enabled: false -Lint/DuplicateElsifCondition: - Enabled: false -Lint/DuplicateRequire: - Enabled: false -Lint/DuplicateRescueException: - Enabled: false -Lint/EmptyConditionalBody: - Enabled: false -Lint/EmptyFile: - Enabled: false -Lint/ErbNewArguments: - Enabled: false -Lint/FloatComparison: - Enabled: false -Lint/HashCompareByIdentity: - Enabled: false -Lint/IdentityComparison: - Enabled: false -Lint/InterpolationCheck: - Enabled: false -Lint/MissingCopEnableDirective: - Enabled: false -Lint/MixedRegexpCaptureTypes: - Enabled: false -Lint/NestedPercentLiteral: - Enabled: false -Lint/NonDeterministicRequireOrder: - Enabled: false -Lint/OrderedMagicComments: - Enabled: false -Lint/OutOfRangeRegexpRef: - Enabled: false -Lint/RaiseException: - Enabled: false -Lint/RedundantCopEnableDirective: - Enabled: false -Lint/RedundantRequireStatement: - Enabled: false -Lint/RedundantSafeNavigation: - Enabled: false -Lint/RedundantWithIndex: - Enabled: false -Lint/RedundantWithObject: - Enabled: false -Lint/RegexpAsCondition: - Enabled: false -Lint/ReturnInVoidContext: - Enabled: false -Lint/SafeNavigationConsistency: - Enabled: false -Lint/SafeNavigationWithEmpty: - Enabled: false -Lint/SelfAssignment: - Enabled: false -Lint/SendWithMixinArgument: - Enabled: false -Lint/ShadowedArgument: - Enabled: false -Lint/StructNewOverride: - Enabled: false -Lint/ToJSON: - Enabled: false -Lint/TopLevelReturnWithArgument: - Enabled: false -Lint/TrailingCommaInAttributeDeclaration: - Enabled: false -Lint/UnreachableLoop: - Enabled: false -Lint/UriEscapeUnescape: - Enabled: false -Lint/UriRegexp: - Enabled: false -Lint/UselessMethodDefinition: - Enabled: false -Lint/UselessTimes: - Enabled: false -Metrics/AbcSize: - Enabled: false -Metrics/BlockLength: - Enabled: false -Metrics/BlockNesting: - Enabled: false -Metrics/ClassLength: - Enabled: false -Metrics/CyclomaticComplexity: - Enabled: false -Metrics/MethodLength: - Enabled: false -Metrics/ModuleLength: - Enabled: false -Metrics/ParameterLists: - Enabled: false -Metrics/PerceivedComplexity: - Enabled: false -Migration/DepartmentName: - Enabled: false -Naming/AccessorMethodName: - Enabled: false -Naming/BlockParameterName: - Enabled: false -Naming/HeredocDelimiterCase: - Enabled: false -Naming/HeredocDelimiterNaming: - Enabled: false -Naming/MemoizedInstanceVariableName: - Enabled: false -Naming/MethodParameterName: - Enabled: false -Naming/RescuedExceptionsVariableName: - Enabled: false -Naming/VariableNumber: - Enabled: false -Performance/BindCall: - Enabled: false -Performance/DeletePrefix: - Enabled: false -Performance/DeleteSuffix: - Enabled: false -Performance/InefficientHashSearch: - Enabled: false -Performance/UnfreezeString: - Enabled: false -Performance/UriDefaultParser: - Enabled: false -RSpec/Be: - Enabled: false -RSpec/Capybara/CurrentPathExpectation: - Enabled: false -RSpec/Capybara/FeatureMethods: - Enabled: false -RSpec/Capybara/VisibilityMatcher: - Enabled: false -RSpec/ContextMethod: - Enabled: false -RSpec/ContextWording: - Enabled: false -RSpec/DescribeClass: - Enabled: false -RSpec/EmptyHook: - Enabled: false -RSpec/EmptyLineAfterExample: - Enabled: false -RSpec/EmptyLineAfterExampleGroup: - Enabled: false -RSpec/EmptyLineAfterHook: - Enabled: false -RSpec/ExampleLength: - Enabled: false -RSpec/ExampleWithoutDescription: - Enabled: false -RSpec/ExpectChange: - Enabled: false -RSpec/ExpectInHook: - Enabled: false -RSpec/FactoryBot/AttributeDefinedStatically: - Enabled: false -RSpec/FactoryBot/CreateList: - Enabled: false -RSpec/FactoryBot/FactoryClassName: - Enabled: false -RSpec/HooksBeforeExamples: - Enabled: false -RSpec/ImplicitBlockExpectation: - Enabled: false -RSpec/ImplicitSubject: - Enabled: false -RSpec/LeakyConstantDeclaration: - Enabled: false -RSpec/LetBeforeExamples: - Enabled: false -RSpec/MissingExampleGroupArgument: - Enabled: false -RSpec/MultipleExpectations: - Enabled: false -RSpec/MultipleMemoizedHelpers: - Enabled: false -RSpec/MultipleSubjects: - Enabled: false -RSpec/NestedGroups: - Enabled: false -RSpec/PredicateMatcher: - Enabled: false -RSpec/ReceiveCounts: - Enabled: false -RSpec/ReceiveNever: - Enabled: false -RSpec/RepeatedExampleGroupBody: - Enabled: false -RSpec/RepeatedExampleGroupDescription: - Enabled: false -RSpec/RepeatedIncludeExample: - Enabled: false -RSpec/ReturnFromStub: - Enabled: false -RSpec/SharedExamples: - Enabled: false -RSpec/StubbedMock: - Enabled: false -RSpec/UnspecifiedException: - Enabled: false -RSpec/VariableDefinition: - Enabled: false -RSpec/VoidExpect: - Enabled: false -RSpec/Yield: - Enabled: false -Security/Open: - Enabled: false -Style/AccessModifierDeclarations: - Enabled: false -Style/AccessorGrouping: - Enabled: false -Style/AsciiComments: - 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 -Lint/DuplicateBranch: - Enabled: false -Lint/DuplicateRegexpCharacterClassElement: - Enabled: false -Lint/EmptyBlock: - Enabled: false -Lint/EmptyClass: - Enabled: false -Lint/NoReturnInBeginEndBlocks: - Enabled: false -Lint/ToEnumArguments: - Enabled: false -Lint/UnexpectedBlockArity: - Enabled: false -Lint/UnmodifiedReduceAccumulator: - Enabled: false -Performance/CollectionLiteralInLoop: - Enabled: false -Style/ArgumentsForwarding: - Enabled: false -Style/CollectionCompact: - Enabled: false -Style/DocumentDynamicEvalDefinition: - Enabled: false -Style/NegatedIfElseCondition: - Enabled: false -Style/NilLambda: - Enabled: false -Style/RedundantArgument: - Enabled: false -Style/SwapValues: - Enabled: false +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +inherit_gem: + voxpupuli-test: rubocop.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4e587cb..0000000 --- a/.travis.yml +++ /dev/null @@ -1,54 +0,0 @@ ---- -os: linux -dist: xenial -language: ruby -cache: bundler -before_install: - - bundle -v - - rm -f Gemfile.lock - - "# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner" - - "# See https://github.com/puppetlabs/pdk-templates/commit/705154d5c437796b821691b707156e1b056d244f for an example of how this was used" - - "# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set" - - '[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION' - - gem --version - - bundle -v -script: - - 'bundle exec rake $CHECK' -bundler_args: --without system_tests -rvm: - - 2.5.7 -stages: - - static - - spec - - acceptance - - - if: tag =~ ^v\d - name: deploy -jobs: - fast_finish: true - include: - - - env: CHECK="validate lint check rubocop" - stage: static - - - env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec - rvm: 2.5.7 - stage: spec - - - env: DEPLOY_TO_FORGE=yes - stage: deploy -branches: - only: - - master - - /^v\d/ -notifications: - email: false -deploy: - provider: puppetforge - user: puppet - password: - secure: "" - on: - tags: true - all_branches: true - condition: "$DEPLOY_TO_FORGE = yes" diff --git a/.yardopts b/.yardopts deleted file mode 100644 index 29c933b..0000000 --- a/.yardopts +++ /dev/null @@ -1 +0,0 @@ ---markup markdown diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e3cf307 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +# MANAGED BY MODULESYNC +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +FROM ruby:2.7 + +WORKDIR /opt/puppet + +# https://github.com/puppetlabs/puppet/blob/06ad255754a38f22fb3a22c7c4f1e2ce453d01cb/lib/puppet/provider/service/runit.rb#L39 +RUN mkdir -p /etc/sv + +ARG PUPPET_VERSION="~> 6.0" +ARG PARALLEL_TEST_PROCESSORS=4 + +# Cache gems +COPY Gemfile . +RUN bundle install --without system_tests development release --path=${BUNDLE_PATH:-vendor/bundle} + +COPY . . + +RUN bundle install +RUN bundle exec rake release_checks + +# Container should not saved +RUN exit 1 diff --git a/Gemfile b/Gemfile index a167b88..b6dcf45 100644 --- a/Gemfile +++ b/Gemfile @@ -1,62 +1,34 @@ -source ENV['GEM_SOURCE'] || 'https://rubygems.org' - -def location_for(place_or_version, fake_version = nil) - git_url_regex = %r{\A(?(https?|git)[:@][^#]*)(#(?.*))?} - file_url_regex = %r{\Afile:\/\/(?.*)} - - if place_or_version && (git_url = place_or_version.match(git_url_regex)) - [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact - elsif place_or_version && (file_url = place_or_version.match(file_url_regex)) - ['>= 0', { path: File.expand_path(file_url[:path]), require: false }] - else - [place_or_version, { require: false }] - end -end +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +source ENV['GEM_SOURCE'] || "https://rubygems.org" -ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments -minor_version = ruby_version_segments[0..1].join('.') +group :test do + gem 'voxpupuli-test', '~> 5.0', :require => false + gem 'coveralls', :require => false + gem 'simplecov-console', :require => false + gem 'puppet_metadata', '~> 1.0', :require => false +end group :development do - gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 2.8.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "puppet-module-posix-default-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby] - gem "puppet-module-posix-dev-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby] - gem "puppet-module-win-default-r#{minor_version}", '~> 1.0', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-win-dev-r#{minor_version}", '~> 1.0', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem 'guard-rake', :require => false + gem 'overcommit', '>= 0.39.1', :require => false end + group :system_tests do - gem "puppet-module-posix-system-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby] - gem "puppet-module-win-system-r#{minor_version}", '~> 1.0', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem 'voxpupuli-acceptance', '~> 1.0', :require => false end -puppet_version = ENV['PUPPET_GEM_VERSION'] -facter_version = ENV['FACTER_GEM_VERSION'] -hiera_version = ENV['HIERA_GEM_VERSION'] - -gems = {} - -gems['puppet'] = location_for(puppet_version) - -# If facter or hiera versions have been specified via the environment -# variables - -gems['facter'] = location_for(facter_version) if facter_version -gems['hiera'] = location_for(hiera_version) if hiera_version - -gems.each do |gem_name, gem_params| - gem gem_name, *gem_params +group :release do + gem 'github_changelog_generator', '>= 1.16.1', :require => false if RUBY_VERSION >= '2.5' + gem 'voxpupuli-release', '>= 1.2.0', :require => false + gem 'puppet-strings', '>= 2.2', :require => false end -# Evaluate Gemfile.local and ~/.gemfile if they exist -extra_gemfiles = [ - "#{__FILE__}.local", - File.join(Dir.home, '.gemfile'), -] +gem 'rake', :require => false +gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test] + +puppetversion = ENV['PUPPET_VERSION'] || '>= 6.0' +gem 'puppet', puppetversion, :require => false, :groups => [:test] -extra_gemfiles.each do |gemfile| - if File.file?(gemfile) && File.readable?(gemfile) - eval(File.read(gemfile), binding) - end -end # vim: syntax=ruby diff --git a/Rakefile b/Rakefile index 0f8754e..f92f051 100644 --- a/Rakefile +++ b/Rakefile @@ -1,89 +1,72 @@ -# frozen_string_literal: true +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -require 'bundler' -require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? -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 +# Attempt to load voxpupuli-test (which pulls in puppetlabs_spec_helper), +# otherwise attempt to load it directly. +begin + require 'voxpupuli/test/rake' +rescue LoadError + begin + require 'puppetlabs_spec_helper/rake_tasks' + rescue LoadError + end end -def changelog_project - return unless Rake.application.top_level_tasks.include? "changelog" +# load optional tasks for acceptance +# only available if gem group releases is installed +begin + require 'voxpupuli/acceptance/rake' +rescue LoadError +end - returnVal = nil - returnVal ||= begin - metadata_source = JSON.load(File.read('metadata.json'))['source'] - metadata_source_match = metadata_source && metadata_source.match(%r{.*\/([^\/]*?)(?:\.git)?\Z}) +# load optional tasks for releases +# only available if gem group releases is installed +begin + require 'voxpupuli/release/rake_tasks' +rescue LoadError +end - metadata_source_match && metadata_source_match[1] +desc "Run main 'test' task and report merged results to coveralls" +task test_with_coveralls: [:test] do + if Dir.exist?(File.expand_path('../lib', __FILE__)) + require 'coveralls/rake/task' + Coveralls::RakeTask.new + Rake::Task['coveralls:push'].invoke + else + puts 'Skipping reporting to coveralls. Module has no lib dir' end - - raise "unable to find the changelog_project in .sync.yml or calculate it from the source 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 = "v%s" % 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 +desc 'Generate REFERENCE.md' +task :reference, [:debug, :backtrace] do |t, args| + patterns = '' + Rake::Task['strings:generate:reference'].invoke(patterns, args[:debug], args[:backtrace]) end -PuppetLint.configuration.send('disable_relative') - - -if Bundler.rubygems.find_name('github_changelog_generator').any? +begin + require 'github_changelog_generator/task' + require 'puppet_blacksmith' 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; LABEL THEM ON GITHUB" - config.configure_sections = { - "Changed" => { - "prefix" => "### Changed", - "labels" => ["backwards-incompatible"], - }, - "Added" => { - "prefix" => "### Added", - "labels" => ["enhancement", "feature"], - }, - "Fixed" => { - "prefix" => "### Fixed", - "labels" => ["bug", "documentation", "bugfix"], - }, - } + metadata = Blacksmith::Modulefile.new + config.future_release = "v#{metadata.version}" if metadata.version =~ /^\d+\.\d+.\d+$/ + config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module." + config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog} + config.user = 'voxpupuli' + config.project = metadata.metadata['name'] end -else - desc 'Generate a Changelog from GitHub' - task :changelog do - raise < 1.15' - condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0')" -EOM + + # Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715 + require 'rbconfig' + if RbConfig::CONFIG['host_os'] =~ /linux/ + task :changelog do + puts 'Fixing line endings...' + changelog_file = File.join(__dir__, 'CHANGELOG.md') + changelog_txt = File.read(changelog_file) + new_contents = changelog_txt.gsub(%r{\r\n}, "\n") + File.open(changelog_file, "w") {|file| file.puts new_contents } + end end -end +rescue LoadError +end +# vim: syntax=ruby diff --git a/spec/classes/coverage_spec.rb b/spec/classes/coverage_spec.rb deleted file mode 100644 index c083569..0000000 --- a/spec/classes/coverage_spec.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'rspec-puppet' - -at_exit { RSpec::Puppet::Coverage.report! } diff --git a/spec/default_facts.yml b/spec/default_facts.yml deleted file mode 100644 index 98bc25a..0000000 --- a/spec/default_facts.yml +++ /dev/null @@ -1,9 +0,0 @@ -# Use default_module_facts.yml for module specific facts. -# -# Facts specified here will override the values provided by rspec-puppet-facts. ---- -ipaddress: "172.16.254.254" -ipaddress6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" -is_pe: false -macaddress: "AA:AA:AA:AA:AA:AA" -path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9b1fa6f..4d617f3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,73 +1,17 @@ # frozen_string_literal: true -RSpec.configure do |c| - c.mock_with :rspec -end - -require 'puppetlabs_spec_helper/module_spec_helper' -require 'rspec-puppet-facts' - -require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb')) - -include RspecPuppetFacts - -default_facts = { - puppetversion: Puppet.version, - facterversion: Facter.version, -} - -default_fact_files = [ - File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')), - File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')), -] - -default_fact_files.each do |f| - next unless File.exist?(f) && File.readable?(f) && File.size?(f) - - begin - default_facts.merge!(YAML.safe_load(File.read(f), [], [], true)) - rescue => 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 -end +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -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 - end +# puppetlabs_spec_helper will set up coverage if the env variable is set. +# We want to do this if lib exists and it hasn't been explicitly set. +ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../lib', __dir__)) - # Filter backtrace noise - backtrace_exclusion_patterns = [ - %r{spec_helper}, - %r{gems}, - ] +require 'voxpupuli/test/spec_helper' - 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 +if File.exist?(File.join(__dir__, 'default_module_facts.yml')) + facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml'))) + facts&.each do |name, value| + add_custom_fact name.to_sym, value end end - -# Ensures that a module is defined -# @param module_name Name of the module -def ensure_module_defined(module_name) - module_name.split('::').reduce(Object) do |last_module, next_module| - last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false) - last_module.const_get(next_module, false) - end -end - -# 'spec_overrides' from sync.yml will appear below this line From 729e15382129cb67f53d37dfb2f746a08e8c1287 Mon Sep 17 00:00:00 2001 From: fe80 Date: Thu, 20 Jan 2022 17:16:25 +0100 Subject: [PATCH 05/11] fix github workflow and rubocop linter --- .github/workflows/ci.yml | 16 +---- spec/classes/varnish_spec.rb | 135 ++++++++++++++++++----------------- 2 files changed, 72 insertions(+), 79 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5dad05..086a667 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,11 +4,9 @@ name: CI -on: pull_request - -concurrency: - group: ${{ github.head_ref }} - cancel-in-progress: true +on: + - pull_request + - push jobs: setup_matrix: @@ -56,11 +54,3 @@ jobs: bundler-cache: true - name: Run tests run: bundle exec rake parallel_spec - - tests: - needs: - - unit - runs-on: ubuntu-latest - name: Test suite - steps: - - run: echo Test suite completed diff --git a/spec/classes/varnish_spec.rb b/spec/classes/varnish_spec.rb index 2f838a5..adf3734 100644 --- a/spec/classes/varnish_spec.rb +++ b/spec/classes/varnish_spec.rb @@ -1,9 +1,12 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'varnish', type: :class do on_supported_os.each do |os, facts| context "on #{os}" do let(:facts) { facts } + it { is_expected.to compile.with_all_deps } # Temporary variable before remove init support @@ -12,7 +15,7 @@ facts[:os]['release']['major'].to_i >= 7 ) || ( facts[:os]['release']['name'] == 'Ubuntu' && - facts[:os]['release']['major'].to_f >- 16.04 + facts[:os]['release']['major'].to_f >= 16.04 ) || ( facts[:os]['release']['name'] == 'Debian' && facts[:os]['release']['major'].to_i >= 8 @@ -27,39 +30,39 @@ it { is_expected.to contain_class('varnish::service') } if facts[:os]['family'] == 'RedHat' - it { is_expected.to contain_class('epel') } - - it do - is_expected.to contain_yumrepo('varnish-cache').with( - descr: 'varnishcache_varnish41', - baseurl: format( - 'https://packagecloud.io/varnishcache/varnish41/el/%s/$basearch', - facts[:os]['release']['major'], - ), - gpgkey: 'https://packagecloud.io/varnishcache/varnish41/gpgkey', - metadata_expire: '300', - repo_gpgcheck: '1', - gpgcheck: '0', - sslverify: '1', - sslcacert: '/etc/pki/tls/certs/ca-bundle.crt' - ) - end - - it do - is_expected.to contain_yumrepo('varnish-cache-source').with( - descr: 'varnishcache_varnish41-source', - baseurl: format( - 'https://packagecloud.io/varnishcache/varnish41/el/%s/SRPMS', - facts[:os]['release']['major'], - ), - gpgkey: 'https://packagecloud.io/varnishcache/varnish41/gpgkey', - metadata_expire: '300', - repo_gpgcheck: '1', - gpgcheck: '0', - sslverify: '1', - sslcacert: '/etc/pki/tls/certs/ca-bundle.crt' - ) - end + it { is_expected.to contain_class('epel') } + + it do + is_expected.to contain_yumrepo('varnish-cache').with( + descr: 'varnishcache_varnish41', + baseurl: format( + 'https://packagecloud.io/varnishcache/varnish41/el/%s/$basearch', + facts[:os]['release']['major'] + ), + gpgkey: 'https://packagecloud.io/varnishcache/varnish41/gpgkey', + metadata_expire: '300', + repo_gpgcheck: '1', + gpgcheck: '0', + sslverify: '1', + sslcacert: '/etc/pki/tls/certs/ca-bundle.crt' + ) + end + + it do + is_expected.to contain_yumrepo('varnish-cache-source').with( + descr: 'varnishcache_varnish41-source', + baseurl: format( + 'https://packagecloud.io/varnishcache/varnish41/el/%s/SRPMS', + facts[:os]['release']['major'] + ), + gpgkey: 'https://packagecloud.io/varnishcache/varnish41/gpgkey', + metadata_expire: '300', + repo_gpgcheck: '1', + gpgcheck: '0', + sslverify: '1', + sslcacert: '/etc/pki/tls/certs/ca-bundle.crt' + ) + end else it { is_expected.to contain_package('apt-transport-https') } @@ -129,35 +132,35 @@ group: 'root', mode: '0644', notify: 'Exec[varnish_systemctl_daemon_reload]', - content: < Date: Thu, 20 Jan 2022 17:25:18 +0100 Subject: [PATCH 06/11] fix puppet-lint --- .devcontainer/Dockerfile | 6 ----- .devcontainer/README.md | 34 -------------------------- .devcontainer/devcontainer.json | 17 ------------- examples/init.pp | 20 +++++++-------- manifests/config.pp | 24 +++++++++--------- manifests/init.pp | 29 ++++++++++------------ manifests/install.pp | 11 ++++----- manifests/params.pp | 28 +++++++++------------ manifests/repo.pp | 43 +++++++++++++++------------------ manifests/secret.pp | 15 ++++-------- manifests/service.pp | 10 +++----- manifests/vcl.pp | 9 +++---- spec/defines/vcl_spec.rb | 2 ++ spec/spec_helper_system.rb | 16 ------------ spec/system/basic_spec.rb | 13 ---------- 15 files changed, 85 insertions(+), 192 deletions(-) delete mode 100644 .devcontainer/Dockerfile delete mode 100644 .devcontainer/README.md delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 spec/spec_helper_system.rb delete mode 100644 spec/system/basic_spec.rb diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 12ed4ff..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM puppet/pdk:latest - -# [Optional] Uncomment this section to install additional packages. -# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ -# && apt-get -y install --no-install-recommends - diff --git a/.devcontainer/README.md b/.devcontainer/README.md deleted file mode 100644 index cc4675e..0000000 --- a/.devcontainer/README.md +++ /dev/null @@ -1,34 +0,0 @@ -# devcontainer - - -For format details, see https://aka.ms/devcontainer.json. - -For config options, see the README at: -https://github.com/microsoft/vscode-dev-containers/tree/v0.140.1/containers/puppet - -``` json -{ - "name": "Puppet Development Kit (Community)", - "dockerFile": "Dockerfile", - - // Set *default* container specific settings.json values on container create. - "settings": { - "terminal.integrated.shell.linux": "/bin/bash" - }, - - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "puppet.puppet-vscode", - "rebornix.Ruby" - ] - - // Use 'forwardPorts' to make a list of ports inside the container available locally. - "forwardPorts": [], - - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pdk --version", -} -``` - - - diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index fe7a8b1..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "Puppet Development Kit (Community)", - "dockerFile": "Dockerfile", - - "settings": { - "terminal.integrated.profiles.linux": { - "bash": { - "path": "bash", - } - } - }, - - "extensions": [ - "puppet.puppet-vscode", - "rebornix.Ruby" - ] -} diff --git a/examples/init.pp b/examples/init.pp index 43b28e0..84b362c 100644 --- a/examples/init.pp +++ b/examples/init.pp @@ -1,14 +1,13 @@ node default { - $version = '6.0lts' # == Package Versions - case $::osfamily { + case $facts['os']['family'] { 'Debian': { - if $::operatingsystem == 'Debian' and versioncmp($::lsbdistrelease,'8.0') >= 0 and $version == '3.0' { + if $facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['full'] , '8.0') >= 0 and $version == '3.0' { $package_ensure = '3.0.7-1~jessie' - } elsif $::operatingsystem == 'Ubuntu' and versioncmp($::lsbdistrelease,'16.04') >= 0 and $version == '4.0' { + } elsif $facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '16.04') >= 0 and $version == '4.0' { $package_ensure = '4.0.5-1~xenial' } else { $package_ensure = 'present' @@ -16,7 +15,7 @@ } 'RedHat': { - if $::operatingsystemmajrelease == '7' and $version == '4.0' { + if $facts['os']['release']['major'] == '7' and $version == '4.0' { $package_ensure = '4.0.4-1.el7' } else { $package_ensure = 'present' @@ -30,10 +29,10 @@ # == Varnish - class { '::varnish': + class { 'varnish': varnish_version => $version, package_ensure => $package_ensure, - listen => ['127.0.0.1:8888',"${::ipaddress}:6081"], + listen => ['127.0.0.1:8888',"${facts['networking']['ip']}:6081"], storage_additional => ['file,/var/lib/varnish/varnish_additional.bin,1G'], storage_type => 'malloc', storage_size => '64M', @@ -42,12 +41,12 @@ # == Nginx + test file - class { '::nginx': + class { 'nginx': server_purge => true, confd_purge => true, } - if $::osfamily == 'Debian' { + if $facts['os']['family'] == 'Debian' { $nginx_port = 8080 } else { $nginx_port = 80 @@ -64,8 +63,7 @@ owner => 'root', group => 'root', mode => '0644', - content => "VarnishHello, I am Varnish ${version} running on ${::hostname}\n", + content => "VarnishHello, I am Varnish ${version} running on ${facts['networking']['hostname']}\n", require => Package['nginx'], } - } diff --git a/manifests/config.pp b/manifests/config.pp index b34515a..c11507b 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -3,35 +3,34 @@ # This class is called from varnish # class varnish::config { - - if versioncmp("${::varnish::version_major}.${::varnish::version_minor}",'4.1') >= 0 { + if versioncmp("${varnish::version_major}.${varnish::version_minor}",'4.1') >= 0 { $jail_opt = '-j unix,user=varnish,ccgroup=varnish' } else { $jail_opt = '-u varnish -g varnish' } # Deploy Varnish 4+ SELinux hack on RHEL6 - if $::osfamily == 'RedHat' and $::operatingsystemmajrelease == '6' and $::varnish::version_major != '3' { - if $::selinux_current_mode == 'enforcing' { - ::selinux::module { 'varnishpol': + if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '6' and $varnish::version_major != '3' { + # lint:ignore:legacy_facts + if $facts['selinux_current_mode'] == 'enforcing' { + selinux::module { 'varnishpol': ensure => present, source_te => 'puppet:///modules/varnish/varnishpol.te', - before => Service[$::varnish::service_name], - notify => Service[$::varnish::service_name], + before => Service[$varnish::service_name], + notify => Service[$varnish::service_name], } } + # lint:endignore } - file { $::varnish::params::sysconfig: + file { $varnish::params::sysconfig: owner => 'root', group => 'root', mode => '0644', content => template('varnish/sysconfig.erb'), } - - if $::varnish::params::service_provider == 'systemd' { - + if $varnish::params::service_provider == 'systemd' { file { '/etc/systemd/system/varnish.service': ensure => file, owner => 'root', @@ -45,8 +44,7 @@ command => '/bin/systemctl daemon-reload', refreshonly => true, require => File['/etc/systemd/system/varnish.service'], - notify => Service[$::varnish::service_name], + notify => Service[$varnish::service_name], } } - } diff --git a/manifests/init.pp b/manifests/init.pp index 0366d4c..d5851e4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -63,9 +63,8 @@ String $package_name = 'varnish', String $service_name = 'varnish', Optional[String] $vcl_reload_cmd = undef, - String $vcl_reload_path = $::path, + String $vcl_reload_path = $facts['path'], ) { - if $package_ensure == 'present' { $version_major = regsubst($varnish_version, '^(\d+)\.(\d+).*$', '\1') $version_minor = regsubst($varnish_version, '^(\d+)\.(\d+).*$', '\2') @@ -83,35 +82,33 @@ default => '', } - include ::varnish::params + include varnish::params if $vcl_reload_cmd == undef { - $vcl_reload = $::varnish::params::vcl_reload + $vcl_reload = $varnish::params::vcl_reload } else { $vcl_reload = $vcl_reload_cmd } if $addrepo { - class { '::varnish::repo': - before => Class['::varnish::install'], + class { 'varnish::repo': + before => Class['varnish::install'], } } - include ::varnish::install - + include varnish::install - class { '::varnish::secret': + class { 'varnish::secret': secret => $secret, - require => Class['::varnish::install'], + require => Class['varnish::install'], } - class { '::varnish::config': - require => Class['::varnish::secret'], - notify => Class['::varnish::service'], + class { 'varnish::config': + require => Class['varnish::secret'], + notify => Class['varnish::service'], } - class { '::varnish::service': - require => Class['::varnish::config'], + class { 'varnish::service': + require => Class['varnish::config'], } - } diff --git a/manifests/install.pp b/manifests/install.pp index 2b94048..feccd22 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -1,14 +1,13 @@ # == Class varnish::install # class varnish::install { - - if $::varnish::addrepo == true { - Package[$::varnish::package_name] { - require => $::varnish::repo::package_require, + if $varnish::addrepo == true { + Package[$varnish::package_name] { + require => $varnish::repo::package_require, } } - package { $::varnish::package_name: - ensure => $::varnish::package_ensure, + package { $varnish::package_name: + ensure => $varnish::package_ensure, } } diff --git a/manifests/params.pp b/manifests/params.pp index c7f8947..3001e61 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -4,17 +4,14 @@ # It sets variables according to platform # class varnish::params { - - case $::osfamily { + case $facts['os']['family'] { 'RedHat': { - $sysconfig = '/etc/sysconfig/varnish' - case $::operatingsystemmajrelease { - + case $facts['os']['release']['major'] { '6': { $os_service_provider = 'sysvinit' - $vcl_reload = $::varnish::version_major ? { + $vcl_reload = $varnish::version_major ? { '6' => '/usr/sbin/varnishreload', '5' => '/usr/sbin/varnish_reload_vcl', '4' => '/usr/sbin/varnish_reload_vcl', @@ -24,7 +21,7 @@ '7': { $os_service_provider = 'systemd' - $vcl_reload = $::varnish::version_major ? { + $vcl_reload = $varnish::version_major ? { '6' => '/usr/sbin/varnishreload', '5' => '/sbin/varnish_reload_vcl', '4' => '/usr/sbin/varnish_reload_vcl', @@ -40,7 +37,7 @@ } 'Debian': { - $vcl_reload = $::varnish::version_major ? { + $vcl_reload = $varnish::version_major ? { '6' => '/usr/sbin/varnishreload', '5' => '/usr/share/varnish/reload-vcl -q', '4' => '/usr/share/varnish/reload-vcl -q', @@ -48,7 +45,7 @@ } $sysconfig = '/etc/default/varnish' - case $::operatingsystem { + case $facts['os']['name'] { 'Ubuntu': { $systemd_version = '16.04' } @@ -56,11 +53,11 @@ $systemd_version = '8' } default: { - fail("Unsupported Debian OS: ${::operatingsystem}") + fail("Unsupported Debian OS: ${facts['os']['name']}") } } - if versioncmp($::lsbdistrelease,$systemd_version) >= 0 { + if versioncmp($facts['os']['release']['full'], $systemd_version) >= 0 { $os_service_provider = 'systemd' } else { $os_service_provider = 'sysvinit' @@ -68,15 +65,15 @@ } default: { - fail("${::osfamily} not supported") + fail("${facts['os']['family']} not supported") } } # == Service provider depends on Varnish version and OS - if $::varnish::version_major == '3' { - if $::operatingsystem == 'Debian' { - if versioncmp($::lsbdistrelease,'8.0') >= 0 { + if $varnish::version_major == '3' { + if $facts['os']['name'] == 'Debian' { + if versioncmp($facts['os']['release']['full'], '8.0') >= 0 { $service_provider = 'systemd' } else { $service_provider = 'sysvinit' @@ -87,5 +84,4 @@ } else { $service_provider = $os_service_provider } - } diff --git a/manifests/repo.pp b/manifests/repo.pp index 68759d3..cfb07d0 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -1,29 +1,27 @@ # Add the Varnish repo class varnish::repo { + $ver = "${varnish::version_major}${varnish::version_minor}${varnish::version_lts}" - $ver = "${::varnish::version_major}${::varnish::version_minor}${::varnish::version_lts}" - - case $::osfamily { + case $facts['os']['family'] { 'RedHat': { - if $ver == '50' { - if $::operatingsystemmajrelease == '6' { + if $facts['os']['release']['major'] == '6' { fail('Varnish 5.0 from Packagecloud is not supported on RHEL/CentOS 6') - } elsif $::operatingsystemmajrelease == '7' { + } elsif $facts['os']['release']['major'] == '7' { # https://github.com/varnishcache/pkg-varnish-cache/issues/42 fail('Varnish 5.0 on RHEL/CentOS 7 has a known packaging bug in the varnish_reload_vcl script, please use 5.1 instead. If the bug has been fixed, please submit a pull request to remove this message.') } } - if $::varnish::version_major == '6' and $::operatingsystemmajrelease == '6' { + if $varnish::version_major == '6' and $facts['os']['release']['major'] == '6' { fail('Varnish 6.0 and above from Packagecloud is not supported on RHEL/CentOS 6') } $package_require = undef # Varnish 4 and above need EPEL for jemalloc - if $::varnish::version_major != '3' { - include ::epel + if $varnish::version_major != '3' { + include epel Yumrepo['varnish-cache','varnish-cache-source'] { require => Yumrepo['epel'], } @@ -31,7 +29,7 @@ yumrepo { 'varnish-cache': descr => "varnishcache_varnish${ver}", - baseurl => "https://packagecloud.io/varnishcache/varnish${ver}/el/${::operatingsystemmajrelease}/\$basearch", + baseurl => "https://packagecloud.io/varnishcache/varnish${ver}/el/${facts['os']['release']['major']}/\$basearch", gpgkey => "https://packagecloud.io/varnishcache/varnish${ver}/gpgkey", metadata_expire => '300', repo_gpgcheck => '1', @@ -42,7 +40,7 @@ yumrepo { 'varnish-cache-source': descr => "varnishcache_varnish${ver}-source", - baseurl => "https://packagecloud.io/varnishcache/varnish${ver}/el/${::operatingsystemmajrelease}/SRPMS", + baseurl => "https://packagecloud.io/varnishcache/varnish${ver}/el/${facts['os']['release']['major']}/SRPMS", gpgkey => "https://packagecloud.io/varnishcache/varnish${ver}/gpgkey", metadata_expire => '300', repo_gpgcheck => '1', @@ -52,43 +50,42 @@ } } - 'Debian': { - case $::operatingsystem { + case $facts['os']['name'] { 'Debian': { - if $ver == '50' and $::lsbdistcodename == 'wheezy' { + if $ver == '50' and $facts['os']['distro']['codename'] == 'wheezy' { fail('Varnish 5.0 from Packagecloud is not supported on Debian 7 (Wheezy)') } - if $::varnish::version_major == '6' and $::lsbdistcodename != 'stretch' { + if $varnish::version_major == '6' and $facts['os']['distro']['codename'] != 'stretch' { fail('Varnish 6.0 and above is only supported on Debian 9 (Stretch)') } } 'Ubuntu': { - if $ver == '30' and versioncmp($::operatingsystemmajrelease,'16.04') >= 0 { + if $ver == '30' and versioncmp($facts['os']['release']['full'], '16.04') >= 0 { fail('Varnish 3 from Packagecloud is not supported after Ubuntu 14.04 (Trusty)') } - if $ver == '50' and $::lsbdistcodename == 'trusty' { + if $ver == '50' and $facts['os']['distro']['codename'] == 'trusty' { fail('Varnish 5.0 has a known packaging bug in the reload-vcl script, please use 5.1 instead. If the bug has been fixed, please submit a pull request to remove this message.') } - if $::varnish::version_major == '6' and versioncmp($::operatingsystemmajrelease,'16.04') == -1 { + if $varnish::version_major == '6' and versioncmp($facts['os']['release']['full'], '16.04') == -1 { fail('Varnish 6.0 and above is only supported on Ubuntu 16.04 (Xenial) and newer') } } default: { - fail("Unsupported Debian OS: ${::operatingsystem}") + fail("Unsupported Debian OS: ${facts['os']['name']}") } } ensure_packages('apt-transport-https') - $os_lower = downcase($::operatingsystem) + $os_lower = downcase($facts['os']['name']) $package_require = Exec['apt_update'] - $gpg_key_id = "${::varnish::version_major}.${::varnish::version_minor}${::varnish::version_lts}" ? { + $gpg_key_id = "${varnish::version_major}.${varnish::version_minor}${varnish::version_lts}" ? { '6.1' => '4A066C99B76A0F55A40E3E1E387EF1F5742D76CC', '6.0lts' => '48D81A24CB0456F5D59431D94CFCFD6BA750EDCD', '6.0' => '7C5B46721AF00FD57E68E6E8D2605BF74E8B9DBA', @@ -101,7 +98,7 @@ } ::apt::source { 'varnish-cache': - comment => "Apt source for Varnish ${::varnish::version_major}.${::varnish::version_minor}${::varnish::version_lts}", + comment => "Apt source for Varnish ${varnish::version_major}.${varnish::version_minor}${varnish::version_lts}", location => "https://packagecloud.io/varnishcache/varnish${ver}/${os_lower}/", repos => 'main', require => Package['apt-transport-https'], @@ -117,7 +114,7 @@ } default: { - fail("Unsupported repo osfamily: ${::osfamily}") + fail("Unsupported repo osfamily: ${facts['os']['family']}") } } } diff --git a/manifests/secret.pp b/manifests/secret.pp index 07cd783..ee3e2fe 100644 --- a/manifests/secret.pp +++ b/manifests/secret.pp @@ -1,30 +1,25 @@ # Specify the secret file for varnishadm # This file can be changed without notifying varnish class varnish::secret ( - $secret = undef, + Optional[String] $secret = undef, ) { - if $secret { - - file { $::varnish::secret_file: + file { $varnish::secret_file: owner => 'root', group => 'varnish', mode => '0640', content => "${secret}\n", } - } else { - - file { $::varnish::secret_file: + file { $varnish::secret_file: owner => 'root', group => 'varnish', mode => '0640', } exec { 'Generate Varnish secret file': - unless => "/bin/egrep '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$' '${::varnish::secret_file}' >/dev/null", - command => "/bin/cp /proc/sys/kernel/random/uuid '${::varnish::secret_file}'", + unless => "/bin/egrep '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$' '${varnish::secret_file}' >/dev/null", + command => "/bin/cp /proc/sys/kernel/random/uuid '${varnish::secret_file}'", } - } } diff --git a/manifests/service.pp b/manifests/service.pp index 910e60f..0f641aa 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -4,18 +4,16 @@ # It ensure the service is running # class varnish::service { - # This exec resource receives notifications from varnish::vcl resources exec { 'vcl_reload': - command => $::varnish::vcl_reload, - path => $::varnish::vcl_reload_path, + command => $varnish::vcl_reload, + path => $varnish::vcl_reload_path, refreshonly => true, - require => Service[$::varnish::service_name], + require => Service[$varnish::service_name], } - service { $::varnish::service_name: + service { $varnish::service_name: ensure => 'running', enable => true, } - } diff --git a/manifests/vcl.pp b/manifests/vcl.pp index 5954437..9f8211e 100644 --- a/manifests/vcl.pp +++ b/manifests/vcl.pp @@ -4,12 +4,11 @@ # If the VCL fails to parse, the exec will fail # and Varnish will continue to run with the old config define varnish::vcl ( - $content, - $file = $name + String $content, + String $file = $name ) { - - include ::varnish - include ::varnish::params + include varnish + include varnish::params file { $file: content => $content, diff --git a/spec/defines/vcl_spec.rb b/spec/defines/vcl_spec.rb index 5aa351b..e1f5621 100644 --- a/spec/defines/vcl_spec.rb +++ b/spec/defines/vcl_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'varnish::vcl' do diff --git a/spec/spec_helper_system.rb b/spec/spec_helper_system.rb deleted file mode 100644 index 3e9d37e..0000000 --- a/spec/spec_helper_system.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'rspec-system/spec_helper' -require 'rspec-system-puppet/helpers' - -include RSpecSystemPuppet::Helpers - -RSpec.configure do |c| - proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) - c.tty = true - c.include RSpecSystemPuppet::Helpers - - c.before :suite do - puppet_install - puppet_module_install(source: proj_root, module_name: 'varnish') - shell('puppet module install puppetlabs-stdlib') - end -end diff --git a/spec/system/basic_spec.rb b/spec/system/basic_spec.rb deleted file mode 100644 index 1d58716..0000000 --- a/spec/system/basic_spec.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'spec_helper_system' - -describe 'basic tests' do - it 'class should work without errors' do - pp = <<-EOS - class { 'varnish': } - EOS - - puppet_apply(pp) do |r| - r.exit_code.should == 2 - end - end -end From 68bf714ba6f2770104d60f6575f4cc17f12aa47f Mon Sep 17 00:00:00 2001 From: fe80 Date: Thu, 20 Jan 2022 18:09:18 +0100 Subject: [PATCH 07/11] update puppet support and stdlib * Remove puppet 4 support * Remove Puppet 5 suppot * Add Puppet 7 support * Updated supported stdlib release --- metadata.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metadata.json b/metadata.json index c20a75d..7348ea8 100644 --- a/metadata.json +++ b/metadata.json @@ -22,7 +22,7 @@ }, { "name": "puppetlabs/stdlib", - "version_requirement": ">=4.6.0 < 6.0.0" + "version_requirement": ">=4.6.0 < 9.0.0" } ], "operatingsystem_support": [ @@ -74,7 +74,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 4.7.1 < 6.0.0" + "version_requirement": ">= 6.1.0 < 8.0.0" } ], "description": "Install and configure Varnish Cache", From 36f4a929668c3de7d4bb52bbaadcbdddc568512a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Gonz=C3=A1lez=20Serrano?= Date: Mon, 24 Jan 2022 11:17:10 +0100 Subject: [PATCH 08/11] Allow newer versions of apt dependency Fix claranet#62 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 7348ea8..0e1f5d8 100644 --- a/metadata.json +++ b/metadata.json @@ -18,7 +18,7 @@ }, { "name": "puppetlabs/apt", - "version_requirement": ">= 2.0.0 < 5.0.0" + "version_requirement": ">= 2.0.0 < 9.0.0" }, { "name": "puppetlabs/stdlib", From 8891022f0e47477d2553608c344f41a3f0987cf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Gonz=C3=A1lez=20Serrano?= Date: Mon, 24 Jan 2022 09:10:24 +0100 Subject: [PATCH 09/11] Add support for Debian buster --- README.md | 2 +- Vagrantfile | 3 ++- manifests/params.pp | 15 ++++++++++----- manifests/repo.pp | 4 ++-- metadata.json | 3 ++- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index ae0a5d8..ee13d9e 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ please use the latest version [4.x version from the Puppet Forge](https://forge. ## Module Description This module Supports Varnish versions 3.0, 4.0, 4.1, 5.0, 5.1, 5.2, -6.0, 6.1 across Ubuntu 14.04/16.04/18.04, Debian 7/8/9 and RedHat derivates +6.0, 6.1 across Ubuntu 14.04/16.04/18.04, Debian 7/8/9/10 and RedHat derivates 6/7. This module will install Varnish, **by default version 4.1** from the official diff --git a/Vagrantfile b/Vagrantfile index 5524489..4e23c56 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -11,7 +11,8 @@ PUPPET_VERSION = "5.5.10" BOXES = [ { name: "debian7", box: "debian/wheezy64", version: "7.11.2" }, { name: "debian8", box: "debian/jessie64", version: "8.11.0" }, - { name: "debian8", box: "debian/stretch64", version: "9.8.0" }, + { name: "debian9", box: "debian/stretch64", version: "9.8.0" }, + { name: "debian10", box: "debian/buster64", version: "10.11.0" }, { name: "ubuntu14", box: "ubuntu/trusty64", version: "20190301.0.1" }, { name: "ubuntu16", box: "ubuntu/xenial64", version: "20190221.0.0" }, diff --git a/manifests/params.pp b/manifests/params.pp index 3001e61..436233c 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -37,11 +37,16 @@ } 'Debian': { - $vcl_reload = $varnish::version_major ? { - '6' => '/usr/sbin/varnishreload', - '5' => '/usr/share/varnish/reload-vcl -q', - '4' => '/usr/share/varnish/reload-vcl -q', - '3' => '/usr/share/varnish/reload-vcl -q', + if versioncmp($varnish::version_full,'6.1') >= 0 and versioncmp($facts['os']['release']['full'],'10.0') >= 0 { + $vcl_reload = '/usr/share/varnish/varnishreload' + } + else { + $vcl_reload = $varnish::version_major ? { + '6' => '/usr/sbin/varnishreload', + '5' => '/usr/share/varnish/reload-vcl -q', + '4' => '/usr/share/varnish/reload-vcl -q', + '3' => '/usr/share/varnish/reload-vcl -q', + } } $sysconfig = '/etc/default/varnish' diff --git a/manifests/repo.pp b/manifests/repo.pp index cfb07d0..5516d5e 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -57,8 +57,8 @@ fail('Varnish 5.0 from Packagecloud is not supported on Debian 7 (Wheezy)') } - if $varnish::version_major == '6' and $facts['os']['distro']['codename'] != 'stretch' { - fail('Varnish 6.0 and above is only supported on Debian 9 (Stretch)') + if $varnish::version_major == '6' and versioncmp($facts['os']['release']['full'],'9.0') == -1 { + fail('Varnish 6.0 and above is only supported on Debian 9 (Stretch) and above') } } diff --git a/metadata.json b/metadata.json index 7348ea8..8347193 100644 --- a/metadata.json +++ b/metadata.json @@ -67,7 +67,8 @@ "operatingsystemrelease": [ "7", "8", - "9" + "9", + "10" ] } ], From 523694331324ef4010ee82e7cd45658e4005d387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Gonz=C3=A1lez=20Serrano?= Date: Mon, 24 Jan 2022 09:22:58 +0100 Subject: [PATCH 10/11] Add GPG keys for varnish 6.[2-6] --- README.md | 4 ++-- manifests/repo.pp | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ee13d9e..7ca3a81 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,8 @@ please use the latest version [4.x version from the Puppet Forge](https://forge. ## Module Description This module Supports Varnish versions 3.0, 4.0, 4.1, 5.0, 5.1, 5.2, -6.0, 6.1 across Ubuntu 14.04/16.04/18.04, Debian 7/8/9/10 and RedHat derivates -6/7. +6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6 across Ubuntu 14.04/16.04/18.04, +Debian 7/8/9/10 and RedHat derivates 6/7. This module will install Varnish, **by default version 4.1** from the official Packagecloud repositories, adding EPEL for RedHat-like systems and working diff --git a/manifests/repo.pp b/manifests/repo.pp index 5516d5e..bd4c6dc 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -86,6 +86,11 @@ $os_lower = downcase($facts['os']['name']) $package_require = Exec['apt_update'] $gpg_key_id = "${varnish::version_major}.${varnish::version_minor}${varnish::version_lts}" ? { + '6.6' => 'A0378A38E4EACA3660789E570BAC19E3F6C90CD5', + '6.5' => 'A487F9BE81D9DF5121488CFE1C7B4E9FF149D65B', + '6.4' => 'A9897320C397E3A60C03E8BF821AD320F71BFF3D', + '6.3' => '920A8A7AA7120A8604BCCD294A42CD6EB810E55D', + '6.2' => 'B54813B54CA95257D3590B3F1B0096460868C7A9', '6.1' => '4A066C99B76A0F55A40E3E1E387EF1F5742D76CC', '6.0lts' => '48D81A24CB0456F5D59431D94CFCFD6BA750EDCD', '6.0' => '7C5B46721AF00FD57E68E6E8D2605BF74E8B9DBA', From 8368693f8c42e34cf4f2f84bc9ec8d86e5edc301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Gonz=C3=A1lez=20Serrano?= Date: Mon, 24 Jan 2022 08:51:13 +0100 Subject: [PATCH 11/11] Fix unitfile. Fix #65 --- spec/classes/varnish_spec.rb | 8 ++++---- templates/varnish.service.erb | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/spec/classes/varnish_spec.rb b/spec/classes/varnish_spec.rb index adf3734..d52db8d 100644 --- a/spec/classes/varnish_spec.rb +++ b/spec/classes/varnish_spec.rb @@ -137,6 +137,9 @@ Description=Varnish HTTP accelerator After=network.target + [Install] + WantedBy=multi-user.target + [Service] Type=forking LimitNOFILE=131072 @@ -155,10 +158,7 @@ -p thread_pool_max=1000 \\ -p thread_pool_timeout=120 \\ -S /etc/varnish/secret \\ - -s file,/var/lib/varnish/varnish_storage.bin,1G \\ - - [Install] - WantedBy=multi-user.target + -s file,/var/lib/varnish/varnish_storage.bin,1G EOF ) end diff --git a/templates/varnish.service.erb b/templates/varnish.service.erb index 8476fa2..baacdde 100644 --- a/templates/varnish.service.erb +++ b/templates/varnish.service.erb @@ -2,6 +2,9 @@ Description=Varnish HTTP accelerator After=network.target +[Install] +WantedBy=multi-user.target + [Service] Type=forking LimitNOFILE=131072 @@ -42,10 +45,7 @@ ExecStart=/usr/sbin/varnishd <%= scope['::varnish::config::jail_opt'] %> \ -p <%= k %>=<%= v %> \ <% end -%> -S <%= scope['::varnish::secret_file'] %> \ - -s <%= scope['::varnish::storage_type'] %>,<% if scope['::varnish::storage_type'] == 'file' -%><%= scope['::varnish::storage_file'] %>,<% end -%><%= scope['::varnish::storage_size'] %> \ -<% scope['::varnish::storage_additional'].each do |k| -%> - -s <%= k %> \ -<% end -%> - -[Install] -WantedBy=multi-user.target +<% _default_storage_parts = [ scope['varnish::storage_type'], scope['varnish::storage_size'] ] + _default_storage_parts.insert(1, scope['varnish::storage_file']) if scope['varnish::storage_type'] == 'file' + _default_storage = _default_storage_parts.join(',') -%> + -s <%= [ [ _default_storage ] + scope['varnish::storage_additional'] ].join(" \\\n -s ") %>