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/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..f1a55dc --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,23 @@ +// 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 +{ + "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/.gitpod.Dockerfile b/.gitpod.Dockerfile new file mode 100644 index 0000000..0814c5e --- /dev/null +++ b/.gitpod.Dockerfile @@ -0,0 +1,18 @@ +FROM gitpod/workspace-full +RUN sudo wget https://apt.puppet.com/puppet-tools-release-bionic.deb && \ + wget https://apt.puppetlabs.com/puppet6-release-bionic.deb && \ + sudo dpkg -i puppet6-release-bionic.deb && \ + sudo dpkg -i puppet-tools-release-bionic.deb && \ + sudo apt-get update && \ + sudo apt-get install -y pdk zsh puppet-agent && \ + sudo apt-get clean && \ + sudo rm -rf /var/lib/apt/lists/* +RUN sudo usermod -s $(which zsh) gitpod && \ + sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" && \ + echo "plugins=(git gitignore github gem pip bundler python ruby docker docker-compose)" >> /home/gitpod/.zshrc && \ + echo 'PATH="$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/puppetlabs/bin:/opt/puppetlabs/puppet/bin"' >> /home/gitpod/.zshrc && \ + sudo /opt/puppetlabs/puppet/bin/gem install puppet-debugger hub -N && \ + mkdir -p /home/gitpod/.config/puppet && \ + /opt/puppetlabs/puppet/bin/ruby -r yaml -e "puts ({'disabled' => true}).to_yaml" > /home/gitpod/.config/puppet/analytics.yml +RUN rm -f puppet6-release-bionic.deb puppet-tools-release-bionic.deb +ENTRYPOINT /usr/bin/zsh diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 0000000..18406c5 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,9 @@ +image: + file: .gitpod.Dockerfile + +tasks: + - init: pdk bundle install + +vscode: + extensions: + - puppet.puppet-vscode@1.0.0:oSzfTkDf6Cmc1jOjgW33VA== diff --git a/.pdkignore b/.pdkignore index e6215cd..bb3fc21 100644 --- a/.pdkignore +++ b/.pdkignore @@ -32,6 +32,7 @@ /.gitignore /.gitlab-ci.yml /.pdkignore +/.puppet-lint.rc /Rakefile /rakelib/ /.rspec @@ -40,3 +41,6 @@ /.yardopts /spec/ /.vscode/ +/.sync.yml +/.devcontainer/ +/.editorconfig diff --git a/.puppet-lint.rc b/.puppet-lint.rc index cc96ece..e5cc4f8 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1 +1,2 @@ +--fail-on-warnings --relative diff --git a/.rubocop.yml b/.rubocop.yml index 5307849..8f782e7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,12 +1,12 @@ --- require: +- rubocop-performance - rubocop-rspec -- rubocop-i18n AllCops: DisplayCopNames: true - TargetRubyVersion: '2.1' + TargetRubyVersion: '2.4' Include: - - "./**/*.rb" + - "**/*.rb" Exclude: - bin/* - ".vendor/**/*" @@ -18,16 +18,9 @@ AllCops: - "**/Puppetfile" - "**/Vagrantfile" - "**/Guardfile" -Metrics/LineLength: +Layout/LineLength: Description: People have wide screens, use them. Max: 200 -GetText: - Enabled: false -GetText/DecorateString: - Description: We don't want to decorate test output. - Exclude: - - spec/**/* - Enabled: false RSpec/BeforeAfterAll: Description: Beware of using after(:all) as it may cause state to leak between tests. A necessary evil in acceptance testing. @@ -36,14 +29,13 @@ 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. EnforcedStyle: braces_for_chaining -Style/BracesAroundHashParameters: - Description: Braces are required by Ruby 2.7. Cop removed from RuboCop v0.80.0. - See https://github.com/rubocop-hq/rubocop/pull/7643 - Enabled: true Style/ClassAndModuleChildren: Description: Compact style reduces the required amount of indentation. EnforcedStyle: compact @@ -72,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 @@ -87,26 +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 -GetText/DecorateFunctionMessage: +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 -GetText/DecorateStringFormattingUsingInterpolation: +Layout/EmptyComment: Enabled: false -GetText/DecorateStringFormattingUsingPercent: +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: @@ -119,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 e94097d..24e72b1 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,16 +1,26 @@ --- +common: + disable_legacy_facts: true + appveyor.yml: delete: true .gitlab-ci.yml: delete: true +.gitpod.Dockerfile: + unmanaged: false +.gitpod.yml: + unmanaged: false + .rubocop_todo.yml: delete: true .travis.yml: - simplecov: true - deploy: true + dist: focal + simplecov: false + before_install_pre: + - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin || true user: rehanone secure: "WiS9j4aI93DobVH/O/z6aHKOY8UL2hwn4+fflKuhvZzJPxfsYYfvQsyX43qetpVAIW7DCZLfO1QQlLF1/ywhe8Y9XRy923R6E7WckYPCGtGBpeTdS7p3Biss2H+ikxI9/5UFlewrdFxLxqgKz8lGLCt8zL1r7ggPWjJBfWEBtk2J9mj4BRTTGt6SWTSHwkdqjloQsPu32SXWY4nsU+87p+lO49YTOH2cS+54/DRCpccPl2AL+kXISDGiDZtlMyGdL2c0Z1e8etmOxbHN2X80YyOQY2GiKdGhzVfx5TDPElDXkOO5JkkZWmsz2D6BJYvu+s9awIJ6/pzGFDghZIK2MSgfUjJd9Vwt1lm48kHKsJ3DsSRIOHK+2ft/3nUl8y7j7KKQMcKKVN35/0uy/cXnD4acuxCh84e5bc0pmYy0gxLhLF6C9Ahv8pls7HhA+jaoUBNXIgCb685w6EgrkaeGMx1vz7VfZo56viod/zZ7XCXg8o5s7vthKMtYLnuGIEl2DvBC3KKtGvl4RnzFVUcZcB5lHgLZozskcwuWFtqd/AgqdIVRzKc6KmRWo8TkE/qOV79MaUpKGONmLMQfsz01HMn4m/NAmu4J55kFgFYkrkwy+9c/3Z9Ytce7goOnyxYYd0fFfaSM8vJCl7oe8Zb3znK2atMmpQAfDwYBwUNe1jU=" docker_sets: @@ -21,19 +31,65 @@ appveyor.yml: - set: docker/debian-10 - set: docker/debian-9 - set: docker/debian-8 - - set: docker/centos-8 + #- set: docker/centos-8 - set: docker/centos-7 + - set: docker/opensuse-15 + docker_defaults: + dist: focal + branches: + - master + remove_branches: + - main + +.pdkignore: + paths: + - /.editorconfig Gemfile: required: + ':development': + - gem: 'puppet-lint-absolute_template_path' + - gem: 'puppet-lint-absolute_classname-check' + - gem: 'puppet-lint-alias-check' + - gem: 'puppet-lint-classes_and_types_beginning_with_digits-check' + - gem: 'puppet-lint-concatenated_template_files-check' + - gem: 'puppet-lint-file_ensure-check' + - gem: 'puppet-lint-file_source_rights-check' + - gem: 'puppet-lint-leading_zero-check' + - gem: 'puppet-lint-resource_reference_syntax' + - gem: 'puppet-lint-strict_indent-check' + - gem: 'puppet-lint-top_scope_facts-check' + - gem: 'puppet-lint-topscope-variable-check' + - gem: 'puppet-lint-trailing_comma-check' + - gem: 'puppet-lint-unquoted_string-check' + - gem: 'puppet-lint-variable_contains_upcase' + - gem: 'puppet-lint-version_comparison-check' + # https://github.com/puppetlabs/pdk-templates#enabling-beaker-system-tests ':system_tests': - gem: 'puppet-module-posix-system-r#{minor_version}' + version: '~> 1.0' platforms: ruby - gem: 'puppet-module-win-system-r#{minor_version}' + version: '~> 1.0' platforms: - mswin - mingw - x64_mingw + - gem: 'beaker' + version: '~> 4.0' + - gem: 'beaker-hostgenerator' + - gem: 'beaker-puppet' + - gem: 'beaker-puppet_install_helper' + - gem: 'beaker-module_install_helper' + - gem: 'beaker-rspec' + - gem: 'beaker-docker' + +Rakefile: + linter_fail_on_warnings: true + +spec/spec_helper.rb: + mock_with: ':rspec' + coverage_report: true spec/spec.opts: delete: true diff --git a/.travis.yml b/.travis.yml index 233b1b6..3a990b9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,10 @@ --- os: linux -dist: xenial +dist: focal language: ruby cache: bundler before_install: + - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin || true - bundle -v - rm -f Gemfile.lock - "# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner" @@ -13,7 +14,7 @@ before_install: - gem --version - bundle -v script: - - 'SIMPLECOV=yes bundle exec rake $CHECK' + - 'bundle exec rake $CHECK' bundler_args: --without system_tests rvm: - 2.5.7 @@ -29,7 +30,7 @@ jobs: include: - bundler_args: --with system_tests - dist: trusty + dist: focal env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/ubuntu-20.04 BEAKER_TESTMODE=apply rvm: 2.5.7 script: bundle exec rake beaker @@ -38,7 +39,7 @@ jobs: sudo: required - bundler_args: --with system_tests - dist: trusty + dist: focal env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/ubuntu-18.04 BEAKER_TESTMODE=apply rvm: 2.5.7 script: bundle exec rake beaker @@ -47,7 +48,7 @@ jobs: sudo: required - bundler_args: --with system_tests - dist: trusty + dist: focal env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/ubuntu-16.04 BEAKER_TESTMODE=apply rvm: 2.5.7 script: bundle exec rake beaker @@ -56,7 +57,7 @@ jobs: sudo: required - bundler_args: --with system_tests - dist: trusty + dist: focal env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/ubuntu-14.04 BEAKER_TESTMODE=apply rvm: 2.5.7 script: bundle exec rake beaker @@ -65,7 +66,7 @@ jobs: sudo: required - bundler_args: --with system_tests - dist: trusty + dist: focal env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/debian-10 BEAKER_TESTMODE=apply rvm: 2.5.7 script: bundle exec rake beaker @@ -74,7 +75,7 @@ jobs: sudo: required - bundler_args: --with system_tests - dist: trusty + dist: focal env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/debian-9 BEAKER_TESTMODE=apply rvm: 2.5.7 script: bundle exec rake beaker @@ -83,7 +84,7 @@ jobs: sudo: required - bundler_args: --with system_tests - dist: trusty + dist: focal env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/debian-8 BEAKER_TESTMODE=apply rvm: 2.5.7 script: bundle exec rake beaker @@ -92,8 +93,8 @@ jobs: sudo: required - bundler_args: --with system_tests - dist: trusty - env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/centos-8 BEAKER_TESTMODE=apply + dist: focal + env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/centos-7 BEAKER_TESTMODE=apply rvm: 2.5.7 script: bundle exec rake beaker services: docker @@ -101,8 +102,8 @@ jobs: sudo: required - bundler_args: --with system_tests - dist: trusty - env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/centos-7 BEAKER_TESTMODE=apply + dist: focal + env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/opensuse-15 BEAKER_TESTMODE=apply rvm: 2.5.7 script: bundle exec rake beaker services: docker @@ -111,10 +112,6 @@ jobs: - env: CHECK="check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint" stage: static - - - env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec - rvm: 2.4.5 - stage: spec - env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec rvm: 2.5.7 @@ -124,8 +121,8 @@ jobs: stage: deploy branches: only: - - master - /^v\d/ + - master notifications: email: false deploy: diff --git a/CHANGELOG.md b/CHANGELOG.md index a873dbd..8a1a3f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,23 +1,23 @@ ## 4.0.0 (July 8, 2020) -Improvements: +**Improvements:** - Update nginx repository from unsupported ppa to Official Debian/Ubuntu packages. - Added support for Ubuntu 20.04. ## 3.4.0 (July 5, 2020) -Improvements: +**Improvements:** - Updated `pdk` templates. -Bugfixes: +**Bugfixes:** - Fixed type for `service_port` parameter. ## 3.3.0 (May 6, 2020) -Improvements: +**Improvements:** - Removed unused test files. - Updated `pdk` templates. @@ -25,7 +25,7 @@ Improvements: ## 3.2.0 (February 13, 2020) -Improvements: +**Improvements:** - Added support for CentOS 8. - Updated os support matrix. @@ -33,7 +33,7 @@ Improvements: ## 3.1.0 (August 25, 2019) -Improvements: +**Improvements:** - Added support for Debian 10. - Updated os support matrix. @@ -41,23 +41,23 @@ Improvements: ## 3.0.2 (June 15, 2019) -Improvements: +**Improvements:** - Updated os support matrix. ## 3.0.1 (April 29, 2019) -Improvements: +**Improvements:** - Updated os support matrix. -Bugfixes: +**Bugfixes:** - Fix minor documentation errors. ## 3.0.0 (April 29, 2019) -Improvements: +**Improvements:** - Raise the version bound for puppetlabs-apt dependency. - Raise the minimum puppet version to 5.5.10. @@ -65,20 +65,20 @@ Improvements: ## 2.1.1 (January 3, 2019) -Improvements: +**Improvements:** - Updated `pdk` templates. ## 2.1.0 (October 14, 2018) -Improvements: +**Improvements:** - Updated `pdk` templates. - Added support for `puppet` version 6. ## 2.0.4 (September 1, 2018) -Improvements: +**Improvements:** - Updated `pdk` templates. - Added tests for Debian 9 release. @@ -87,7 +87,7 @@ Improvements: ## 2.0.3 (May 29, 2018) -Improvements: +**Improvements:** - Updated module dependencies. - Added tests for Ubuntu 18.04 release. @@ -95,7 +95,7 @@ Improvements: ## 2.0.2 (May 7, 2018) -Improvements: +**Improvements:** - Updated `pdk` templates. - Updated minimum required `puppet` version to `4.10.0`. @@ -103,23 +103,23 @@ Improvements: ## 2.0.1 (April 21, 2018) -Bugfixes: +**Bugfixes:** - Fix minor documentation errors. ## 2.0.0 (April 20, 2018) -Features: +**Features:** - Added `task` for managing nginx service. -Improvements: +**Improvements:** - Updated module to be `pdk` compliant. - Updated module data to `hiera 5`. ## 1.0.0 (February 17, 2018) -Improvements: +**Improvements:** - Added unit tests to cover all supported OS entries. - Added Puppet 5 support. @@ -128,7 +128,7 @@ Improvements: ## 0.4.0 (July 16, 2017) -Improvements: +**Improvements:** - Added `repo_ensure` parameter. - Added `package_manage` parameter. @@ -136,13 +136,13 @@ Improvements: - Update minimum puppet version required is set to `4.7.0`. - Updated `puppetlabs-apt` module dependency versions. -Bugfixes: +**Bugfixes:** - Fix the style issues in chaining arrows. ## 0.3.0 (December 25, 2016) -Features: +**Features:** - Add support for RedHad, CentOS and Scientific Linux from version 5 to 7. This includes updates from Official Nginx channel for both stable and mainline builds. - Introduce proper Puppet 4 types for parameters. @@ -151,13 +151,12 @@ Features: ## 0.2.0 (July 18, 2016) -Features: +**Features:** - Added option to work with templates in the vhost. ## 0.1.0 (May 22, 2016) -Features: +**Features:** - Initial release - diff --git a/Gemfile b/Gemfile index 57770cb..405d33c 100644 --- a/Gemfile +++ b/Gemfile @@ -17,21 +17,41 @@ 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 "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-posix-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby] - gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby] - gem "puppet-module-win-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-win-dev-r#{minor_version}", '~> 0.4', 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] + gem "puppet-lint-absolute_template_path", require: false + gem "puppet-lint-absolute_classname-check", require: false + gem "puppet-lint-alias-check", require: false + gem "puppet-lint-classes_and_types_beginning_with_digits-check", require: false + gem "puppet-lint-concatenated_template_files-check", require: false + gem "puppet-lint-file_ensure-check", require: false + gem "puppet-lint-file_source_rights-check", require: false + gem "puppet-lint-leading_zero-check", require: false + gem "puppet-lint-resource_reference_syntax", require: false + gem "puppet-lint-strict_indent-check", require: false + gem "puppet-lint-top_scope_facts-check", require: false + gem "puppet-lint-topscope-variable-check", require: false + gem "puppet-lint-trailing_comma-check", require: false + gem "puppet-lint-unquoted_string-check", require: false + gem "puppet-lint-variable_contains_upcase", require: false + gem "puppet-lint-version_comparison-check", require: false + gem "puppet-lint-legacy_facts-check", require: false end group :system_tests do - gem "puppet-module-posix-system-r#{minor_version}", require: false, platforms: [:ruby] - gem "puppet-module-win-system-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] + 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 "beaker", '~> 4.0', require: false + gem "beaker-hostgenerator", require: false + gem "beaker-puppet", require: false + gem "beaker-puppet_install_helper", require: false + gem "beaker-module_install_helper", require: false + gem "beaker-rspec", require: false + gem "beaker-docker", require: false end puppet_version = ENV['PUPPET_GEM_VERSION'] @@ -48,16 +68,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/README.md b/README.md index e728036..4b6560c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # rehan-nginx -[![Puppet Forge](http://img.shields.io/puppetforge/v/rehan/nginx.svg)](https://forge.puppetlabs.com/rehan/nginx) [![Build Status](https://travis-ci.org/rehanone/puppet-nginx.svg?branch=master)](https://travis-ci.org/rehanone/puppet-nginx) +[![Puppet Forge](http://img.shields.io/puppetforge/v/rehan/nginx.svg)](https://forge.puppetlabs.com/rehan/nginx) [![Build Status](https://travis-ci.com/rehanone/puppet-nginx.svg?branch=master)](https://travis-ci.com/rehanone/puppet-nginx) #### Table of Contents 1. [Overview](#overview) @@ -34,9 +34,7 @@ $ puppet module install rehan-nginx The module does expect all the data to be provided through 'Hiera'. See [Usage](#usage) for examples on how to configure it. #### Requirements -This module is designed to be as clean and compliant with latest puppet code guidelines. It works with: - - - `puppet >=5.5.10` +This module is designed to be as clean and compliant with latest puppet code guidelines. ## Usage diff --git a/Rakefile b/Rakefile index cb7ed0c..4669782 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,6 @@ # 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' @@ -41,6 +42,7 @@ def changelog_future_release end PuppetLint.configuration.send('disable_relative') +PuppetLint.configuration.fail_on_warnings = true if Bundler.rubygems.find_name('github_changelog_generator').any? GitHubChangelogGenerator::RakeTask.new :changelog do |config| @@ -52,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", @@ -60,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 @@ -72,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/manifests/init.pp b/manifests/init.pp index b1f1197..477afc0 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,29 +1,26 @@ class nginx ( Boolean $repo_manage, String $repo_ensure, - Enum[stable, mainline] - $repo_branch, - Struct[ - { + Enum[stable, mainline] $repo_branch, + Struct[{ stable => Stdlib::HTTPSUrl, mainline => Stdlib::HTTPSUrl, - } - ] - $repo_sources, + }] $repo_sources, Boolean $package_manage, String $package_ensure, String $package_name, - Array[String] - $package_extras, + Array[String] $package_extras, Boolean $service_enable, String $service_ensure, Boolean $service_manage, String $service_name, Array[ - Struct[{ - port => Stdlib::Port, - protocol => Enum[tcp, udp], - }] + Struct[ + { + port => Stdlib::Port, + protocol => Enum[tcp, udp], + } + ] ] $service_ports, String $install_location, Boolean $firewall_manage, diff --git a/manifests/install.pp b/manifests/install.pp index e3dff15..52982da 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -8,7 +8,6 @@ if $nginx::package_manage { package { $nginx::package_name: ensure => $nginx::package_ensure, - alias => 'nginx', } } } diff --git a/manifests/resource/config.pp b/manifests/resource/config.pp index c29600a..93f0738 100644 --- a/manifests/resource/config.pp +++ b/manifests/resource/config.pp @@ -1,11 +1,9 @@ - define nginx::resource::config ( String $source, - Enum[ present, absent ] - $ensure = present, - ) { + Enum[ present, absent ] $ensure = present, +) { - $install_location = $::nginx::install_location + $install_location = $nginx::install_location file { "${install_location}/conf.d/${name}.conf": ensure => $ensure, diff --git a/manifests/resource/vhost.pp b/manifests/resource/vhost.pp index 5cba0e3..fa1181a 100644 --- a/manifests/resource/vhost.pp +++ b/manifests/resource/vhost.pp @@ -1,9 +1,8 @@ define nginx::resource::vhost ( - String $source = '', - String $content = '', - Enum[ present, absent ] - $ensure = present, - Boolean $enabled = true, + String $source = '', + String $content = '', + Enum[ present, absent ] $ensure = present, + Boolean $enabled = true, ) { if (empty($source)) and (empty($content)) { @@ -19,13 +18,13 @@ } $file_content = $content ? { - '' => undef, + '' => undef, default => $content, } - $install_location = $::nginx::install_location - $sites_available = "${install_location}/sites-available" - $sites_enabled = "${install_location}/sites-enabled" + $install_location = $nginx::install_location + $sites_available = "${install_location}/sites-available" + $sites_enabled = "${install_location}/sites-enabled" $ensure_certs_dir = $ensure ? { 'present' => directory, @@ -40,7 +39,7 @@ require => File["${nginx::install_location}/certs"], } - $ensure_sites_available = $ensure ? { + $ensure_sites_available = $ensure ? { 'present' => file, default => $ensure, } diff --git a/metadata.json b/metadata.json index 7f12f52..bf83b6a 100644 --- a/metadata.json +++ b/metadata.json @@ -10,11 +10,11 @@ "dependencies": [ { "name": "puppetlabs-stdlib", - "version_requirement": ">= 5.0.0 < 7.0.0" + "version_requirement": ">= 5.0.0 < 8.0.0" }, { "name": "puppetlabs-apt", - "version_requirement": ">= 6.0.0 < 8.0.0" + "version_requirement": ">= 6.0.0 < 9.0.0" } ], "operatingsystem_support": [ @@ -53,15 +53,14 @@ { "operatingsystem": "Fedora", "operatingsystemrelease": [ - "30", - "31", - "32" + "32", + "33", + "34" ] }, { "operatingsystem": "SLES", "operatingsystemrelease": [ - "11", "12", "15" ] @@ -80,9 +79,6 @@ "14.04", "16.04", "18.04", - "18.10", - "19.04", - "19.10", "20.04" ] }, @@ -93,7 +89,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 5.5.10 < 7.0.0" + "version_requirement": ">= 5.5.10 < 8.0.0" } ], "tags": [ @@ -101,7 +97,7 @@ "nginx", "reserse proxy" ], - "pdk-version": "1.18.0", - "template-url": "pdk-default#1.18.0", - "template-ref": "tags/1.18.0-0-g095317c" + "pdk-version": "2.1.0", + "template-url": "pdk-default#2.1.0", + "template-ref": "tags/2.1.0-0-ga675ea5" } diff --git a/spec/acceptance/nodesets/docker/opensuse-15.yml b/spec/acceptance/nodesets/docker/opensuse-15.yml new file mode 100644 index 0000000..8fcc2ab --- /dev/null +++ b/spec/acceptance/nodesets/docker/opensuse-15.yml @@ -0,0 +1,13 @@ +HOSTS: + opensuse15-64: + docker_cmd: '["/usr/lib/systemd/systemd", "--system"]' + image: opensuse/leap:15 + platform: sles-15-x64 + packaging_platform: sles-15-x64 + docker_image_commands: + - zypper --non-interactive --no-gpg-checks install wget gzip + - wget https://yum.puppet.com/puppet6-release-sles-15.noarch.rpm + - zypper --non-interactive --no-gpg-checks install puppet6-release-sles-15.noarch.rpm + - zypper --non-interactive --no-gpg-checks install puppet-agent + hypervisor: docker + roles: [] diff --git a/spec/classes/nginx_spec.rb b/spec/classes/nginx_spec.rb index c6b7ce9..a9a75af 100644 --- a/spec/classes/nginx_spec.rb +++ b/spec/classes/nginx_spec.rb @@ -19,6 +19,10 @@ } end + it { + is_expected.to compile.with_all_deps + } + case facts[:os][:family] when 'Debian' it { diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d3778ca..16764b6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +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' @@ -42,6 +46,7 @@ end c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] c.after(:suite) do + RSpec::Puppet::Coverage.report!(0) end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index ee991ba..35fb3da 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,95 +1,24 @@ require 'beaker-rspec' +require 'beaker-puppet' require 'beaker/puppet_install_helper' require 'beaker/module_install_helper' -def install_bolt_on(hosts) - on(hosts, "/opt/puppetlabs/puppet/bin/gem install --source http://rubygems.delivery.puppetlabs.net bolt -v '> 0.0.1'", acceptable_exit_codes: [0, 1]).stdout -end - -def pe_install? - ENV['PUPPET_INSTALL_TYPE'] =~ %r{pe}i -end +UNSUPPORTED_PLATFORMS = ['windows', 'darwin'].freeze -run_puppet_install_helper -install_bolt_on(hosts) unless pe_install? +run_puppet_install_helper unless ENV['BEAKER_provision'] == 'no' +install_ca_certs unless ENV['PUPPET_INSTALL_TYPE'].match?(%r{pe}i) install_module_on(hosts) install_module_dependencies_on(hosts) -hosts.each do |host| - apply_manifest_on(host, 'package { "python-software-properties": }') - apply_manifest_on(host, 'package { "software-properties-common": }') -end - -UNSUPPORTED_PLATFORMS = ['RedHat', 'Suse', 'windows', 'AIX', 'Solaris'].freeze - -DEFAULT_PASSWORD = if default[:hypervisor] == 'vagrant' - 'vagrant' - elsif default[:hypervisor] == 'vcloud' - 'Qu@lity!' - end - -def puppet_version - (on default, puppet('--version')).output.chomp -end - -def run_puppet_access_login(user:, password: - '~!@#$%^*-/ aZ', lifetime: '5y') - on(master, puppet('access', 'login', '--username', user, '--lifetime', lifetime), stdin: password) -end - -def run_task(task_name:, params: nil, password: DEFAULT_PASSWORD) - if pe_install? - run_puppet_task(task_name: task_name, params: params) - else - run_bolt_task(task_name: task_name, params: params, password: password) - end -end - -def run_bolt_task(task_name:, params: nil, password: DEFAULT_PASSWORD) - on(master, "/opt/puppetlabs/puppet/bin/bolt task run #{task_name} --modules /etc/puppetlabs/code/modules/service --nodes localhost --password #{password} #{params}", acceptable_exit_codes: [0, 1]).stdout # rubocop:disable Metrics/LineLength -end - -def run_puppet_task(task_name:, params: nil) - on(master, puppet('task', 'run', task_name, '--nodes', fact_on(master, 'fqdn'), params.to_s), acceptable_exit_codes: [0, 1]).stdout -end - -def expect_multiple_regexes(result:, regexes:) - regexes.each do |regex| - expect(result).to match(regex) - end -end - -# This method allows a block to be passed in and if an exception is raised -# that matches the 'error_matcher' matcher, the block will wait a set number -# of seconds before retrying. -# Params: -# - max_retry_count - Max number of retries -# - retry_wait_interval_secs - Number of seconds to wait before retry -# - error_matcher - Matcher which the exception raised must match to allow retry -# Example Usage: -# retry_on_error_matching(3, 5, /OpenGPG Error/) do -# apply_manifest(pp, :catch_failures => true) -# end -def retry_on_error_matching(max_retry_count = 3, retry_wait_interval_secs = 5, error_matcher = nil) - try = 0 - begin - try += 1 - yield - rescue StandardError => e - raise unless try < max_retry_count && (error_matcher.nil? || e.message =~ error_matcher) - sleep retry_wait_interval_secs - retry - end -end - RSpec.configure do |c| - File.expand_path(File.join(File.dirname(__FILE__), '..')) - # Readable test descriptions c.formatter = :documentation # Configure all nodes in nodeset c.before :suite do - run_puppet_access_login(user: 'admin') if pe_install? && puppet_version =~ %r{(5\.\d\.\d)} end end + +def return_puppet_version + (on default, puppet('--version')).output.chomp +end