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/.fixtures.yml b/.fixtures.yml deleted file mode 100644 index 31ff168..0000000 --- a/.fixtures.yml +++ /dev/null @@ -1,5 +0,0 @@ -fixtures: - repositories: - stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git" - symlinks: - mdadm: "#{source_dir}" diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9032a01 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +*.rb eol=lf +*.erb eol=lf +*.pp eol=lf +*.sh eol=lf +*.epp eol=lf diff --git a/.gitignore b/.gitignore index d6a5879..988dcbb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,28 @@ -.*.sw? -pkg -spec/fixtures -.rspec_system -.vagrant -.bundle -vendor -log +.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 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..fd0d11a --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,53 @@ +--- +stages: + - syntax + - unit + +default: + cache: + paths: + - vendor/bundle + + before_script: &before_script + - bundle -v + - rm Gemfile.lock || true + - "# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner" + - "# Set `rubygems_version` in the .sync.yml to set a value" + - "# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set" + - '[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION' + - gem --version + - bundle -v + - bundle install --without system_tests --path vendor/bundle --jobs $(nproc) + +syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop-Ruby 2.5.7-Puppet ~> 6: + stage: syntax + image: ruby:2.5.7 + script: + - bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop + variables: + PUPPET_GEM_VERSION: '~> 6' + +parallel_spec-Ruby 2.5.7-Puppet ~> 6: + stage: unit + image: ruby:2.5.7 + script: + - bundle exec rake parallel_spec + variables: + PUPPET_GEM_VERSION: '~> 6' + +syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop-Ruby 2.7.2-Puppet ~> 7: + stage: syntax + image: ruby:2.7.2 + script: + - bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop + variables: + PUPPET_GEM_VERSION: '~> 7' + +parallel_spec-Ruby 2.7.2-Puppet ~> 7: + stage: unit + image: ruby:2.7.2 + script: + - bundle exec rake parallel_spec + variables: + PUPPET_GEM_VERSION: '~> 7' + diff --git a/.pdkignore b/.pdkignore new file mode 100644 index 0000000..c538bea --- /dev/null +++ b/.pdkignore @@ -0,0 +1,47 @@ +.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..7f26096 --- /dev/null +++ b/.pmtignore @@ -0,0 +1,14 @@ +vendor/ +import/ +/spec/fixtures/ +.tmp +*.lock +*.local +.rbenv-gemsets +.ruby-version +build/ +docs/ +tests/ +log/ +junit/ +tmp/ diff --git a/.puppet-lint.rc b/.puppet-lint.rc index 61aadff..cc96ece 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1,2 +1 @@ ---no-autoloader_layout-check ---no-class_inherits_from_params_class-check +--relative diff --git a/.rspec b/.rspec index 8c18f1a..16f9cdb 100644 --- a/.rspec +++ b/.rspec @@ -1,2 +1,2 @@ ---format documentation --color +--format documentation diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..8f782e7 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,519 @@ +--- +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 diff --git a/.sync.yml b/.sync.yml new file mode 100644 index 0000000..8c2c98e --- /dev/null +++ b/.sync.yml @@ -0,0 +1,8 @@ +# This file can be used to customize the files managed by PDK. +# +# See https://github.com/puppetlabs/pdk-templates/blob/main/README.md +# for more information. +# +# See https://github.com/puppetlabs/pdk-templates/blob/main/config_defaults.yml +# for the default values. +--- {} diff --git a/.travis.yml b/.travis.yml index ad609b0..9381ad1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,42 +1,45 @@ --- +os: linux +dist: xenial language: ruby -bundler_args: --without development system_tests -before_install: rm Gemfile.lock || true +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: - - 1.9.3 - - 2.0.0 - - 2.1.0 -script: bundle exec rake test -env: - - PUPPET_VERSION="~> 2.7.0" - - PUPPET_VERSION="~> 3.2.0" - - PUPPET_VERSION="~> 3.3.0" - - PUPPET_VERSION="~> 3.4.0" - - PUPPET_VERSION="~> 3.5.0" STRICT_VARIABLES=yes - - PUPPET_VERSION="~> 3.6.0" STRICT_VARIABLES=yes - - PUPPET_VERSION="~> 3.7.0" STRICT_VARIABLES=yes - - PUPPET_VERSION="~> 3.7.0" STRICT_VARIABLES=yes FUTURE_PARSER=yes -matrix: - exclude: - # Ruby 1.9.3 - - rvm: 1.9.3 - env: PUPPET_VERSION="~> 2.7.0" - - # Ruby 2.0.0 - - rvm: 2.0.0 - env: PUPPET_VERSION="~> 2.7.0" - - # Ruby 2.1.0 - - rvm: 2.1.0 - env: PUPPET_VERSION="~> 2.7.0" - - rvm: 2.1.0 - env: PUPPET_VERSION="~> 3.2.0" - - rvm: 2.1.0 - env: PUPPET_VERSION="~> 3.3.0" - - rvm: 2.1.0 - env: PUPPET_VERSION="~> 3.4.0" - -# Only notify for failed builds. + - 2.5.7 +stages: + - static + - spec + - acceptance + - + if: tag =~ ^v\d + name: deploy +jobs: + fast_finish: true + include: + - + env: CHECK="check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint" + stage: static + - + env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec + rvm: 2.5.7 + stage: spec + - + env: DEPLOY_TO_FORGE=yes + stage: deploy +branches: + only: + - main + - /^v\d/ notifications: - email: - on_success: never + email: false 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/CHANGELOG b/CHANGELOG index 9c1478a..f6169f7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,16 @@ +2019-07-31 Release 2.0.2 +- Support Ubuntu Xenial + +2018-06-20 Release 2.0.1 +- Fix bug with systemd init systems and mdadm service name. + +2018-05-29 Release 2.0.0 +- Remove stdlib dependency +- Remove support for puppet 3 +- Add DataTypes to parameters +- Various deprecation fixes for tests +- Update test matrix to test puppet4/5 with correct ruby versions + 2016-06-06 Release 1.1.0 - Set rspec-puppet dependency from fork back to upstream - Add raid10 support diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..f0079c6 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +## Release 1.1.0 + +**Features** + +**Bugfixes** + +**Known Issues** diff --git a/Gemfile b/Gemfile index ea80580..a167b88 100644 --- a/Gemfile +++ b/Gemfile @@ -1,23 +1,62 @@ -source "https://rubygems.org" - -group :test do - gem "rake" - gem "puppet", ENV['PUPPET_VERSION'] || '~> 3.7.0' - gem "rspec-puppet" - gem "puppetlabs_spec_helper" - gem "metadata-json-lint" - gem "rspec-puppet-facts" +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 +ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments +minor_version = ruby_version_segments[0..1].join('.') + group :development do - gem "travis" - gem "travis-lint" - gem "vagrant-wrapper" - gem "puppet-blacksmith" - gem "guard-rake" + 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 "beaker" - gem "beaker-rspec" + 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'] +facter_version = ENV['FACTER_GEM_VERSION'] +hiera_version = ENV['HIERA_GEM_VERSION'] + +gems = {} + +gems['puppet'] = location_for(puppet_version) + +# If facter or hiera versions have been specified via the environment +# variables + +gems['facter'] = location_for(facter_version) if facter_version +gems['hiera'] = location_for(hiera_version) if hiera_version + +gems.each do |gem_name, gem_params| + gem gem_name, *gem_params +end + +# Evaluate Gemfile.local and ~/.gemfile if they exist +extra_gemfiles = [ + "#{__FILE__}.local", + File.join(Dir.home, '.gemfile'), +] + +extra_gemfiles.each do |gemfile| + if File.file?(gemfile) && File.readable?(gemfile) + eval(File.read(gemfile), binding) + end end +# vim: syntax=ruby diff --git a/Gemfile.lock b/Gemfile.lock index 9cbe1a9..a80a52f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,388 +1,419 @@ GEM remote: https://rubygems.org/ specs: - CFPropertyList (2.2.8) - addressable (2.4.0) - aws-sdk (1.66.0) - aws-sdk-v1 (= 1.66.0) - aws-sdk-v1 (1.66.0) - json (~> 1.4) - nokogiri (>= 1.4.4) - backports (3.6.8) - beaker (2.43.0) - aws-sdk (~> 1.57) - beaker-answers (~> 0.0) - beaker-hiera (~> 0.0) - beaker-pe (~> 0.0) - docker-api - fission (~> 0.4) - fog (~> 1.25, < 1.35.0) - fog-google (~> 0.0.9) - google-api-client (~> 0.8, < 0.9.5) - hocon (~> 0.1) - inifile (~> 2.0) - json (~> 1.8) - mime-types (~> 2.99) - minitest (~> 5.4) + CFPropertyList (2.3.6) + addressable (2.8.0) + public_suffix (>= 2.0.2, < 5.0) + ansi (1.5.0) + ast (2.4.2) + awesome_print (1.9.2) + aws-eventstream (1.2.0) + aws-partitions (1.549.0) + aws-sdk-core (3.125.5) + aws-eventstream (~> 1, >= 1.0.2) + aws-partitions (~> 1, >= 1.525.0) + aws-sigv4 (~> 1.1) + jmespath (~> 1.0) + aws-sdk-ec2 (1.295.0) + aws-sdk-core (~> 3, >= 3.125.0) + aws-sigv4 (~> 1.1) + aws-sigv4 (1.4.0) + aws-eventstream (~> 1, >= 1.0.2) + bcrypt_pbkdf (1.1.0) + bindata (2.4.10) + bolt (3.21.0) + CFPropertyList (~> 2.2) + addressable (~> 2.5) + aws-sdk-ec2 (~> 1) + concurrent-ruby (~> 1.0) + ffi (>= 1.9.25, < 2.0.0) + hiera-eyaml (~> 3) + jwt (~> 2.2) + logging (~> 2.2) + minitar (~> 0.6) net-scp (~> 1.2) - net-ssh (~> 2.9) - open_uri_redirections (~> 0.2.1) - rbvmomi (~> 1.8) - rsync (~> 1.0.9) - stringify-hash (~> 0.0) - unf (~> 0.1) - beaker-answers (0.5.1) - hocon (~> 0.9.5) - require_all (~> 1.3.2) - stringify-hash (~> 0.0.0) - beaker-hiera (0.1.1) - stringify-hash (~> 0.0.0) - beaker-pe (0.4.0) - stringify-hash (~> 0.0.0) - beaker-rspec (5.3.0) - beaker (~> 2.0) - rspec - serverspec (~> 2) - specinfra (~> 2) - builder (3.2.2) - coderay (1.1.1) - diff-lcs (1.2.5) - docker-api (1.28.0) - excon (>= 0.38.0) - json - domain_name (0.5.20160310) + net-ssh (>= 4.0) + net-ssh-krb (~> 0.5) + orchestrator_client (~> 0.5) + puppet (>= 6.18.0) + puppet-resource_api (>= 1.8.1) + puppet-strings (~> 2.3) + puppetfile-resolver (~> 0.5) + r10k (~> 3.10) + ruby_smb (~> 1.0) + terminal-table (~> 3.0) + winrm (~> 2.0) + winrm-fs (~> 1.3) + builder (3.2.4) + codecov (0.6.0) + simplecov (>= 0.15, < 0.22) + coderay (1.1.3) + colored2 (3.1.2) + concurrent-ruby (1.1.9) + connection_pool (2.2.5) + cri (2.15.10) + deep_merge (1.2.2) + dependency_checker (0.3.0) + parallel + puppet_forge (>= 2.2, < 4.0) + rake (~> 13.0) + semantic_puppet (~> 1.0) + diff-lcs (1.5.0) + docile (1.4.0) + docker-api (2.2.0) + excon (>= 0.47.0) + multi_json + domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) - ethon (0.9.0) - ffi (>= 1.3.0) - excon (0.49.0) - facter (2.4.6) - CFPropertyList (~> 2.2.6) - facterdb (0.3.5) - facter + ed25519 (1.3.0) + erubi (1.10.0) + excon (0.90.0) + facter (4.2.7) + hocon (~> 1.3) + thor (>= 1.0.1, < 2.0) + facterdb (1.12.2) + facter (< 5.0.0) jgrep - faraday (0.9.2) + faraday (0.17.4) multipart-post (>= 1.2, < 3) - faraday_middleware (0.10.0) - faraday (>= 0.7.4, < 0.10) - ffi (1.9.10) - fission (0.5.0) - CFPropertyList (~> 2.2) - fog (1.34.0) - fog-atmos - fog-aws (>= 0.6.0) - fog-brightbox (~> 0.4) - fog-core (~> 1.32) - fog-dynect (~> 0.0.2) - fog-ecloud (~> 0.1) - fog-google (>= 0.0.2) - fog-json - fog-local - fog-powerdns (>= 0.1.1) - fog-profitbricks - fog-radosgw (>= 0.0.2) - fog-riakcs - fog-sakuracloud (>= 0.0.4) - fog-serverlove - fog-softlayer - fog-storm_on_demand - fog-terremark - fog-vmfusion - fog-voxel - fog-xml (~> 0.1.1) - ipaddress (~> 0.5) - nokogiri (~> 1.5, >= 1.5.11) - fog-atmos (0.1.0) - fog-core - fog-xml - fog-aws (0.9.2) - fog-core (~> 1.27) - fog-json (~> 1.0) - fog-xml (~> 0.1) - ipaddress (~> 0.8) - fog-brightbox (0.10.1) - fog-core (~> 1.22) - fog-json - inflecto (~> 0.0.2) - fog-core (1.40.0) - builder - excon (~> 0.49) - formatador (~> 0.2) - fog-dynect (0.0.3) - fog-core - fog-json - fog-xml - fog-ecloud (0.3.0) - fog-core - fog-xml - fog-google (0.0.9) - fog-core - fog-json - fog-xml - fog-json (1.0.2) - fog-core (~> 1.0) - multi_json (~> 1.10) - fog-local (0.3.0) - fog-core (~> 1.27) - fog-powerdns (0.1.1) - fog-core (~> 1.27) - fog-json (~> 1.0) - fog-xml (~> 0.1) - fog-profitbricks (0.0.5) - fog-core - fog-xml - nokogiri - fog-radosgw (0.0.5) - fog-core (>= 1.21.0) - fog-json - fog-xml (>= 0.0.1) - fog-riakcs (0.1.0) - fog-core - fog-json - fog-xml - fog-sakuracloud (1.7.5) - fog-core - fog-json - fog-serverlove (0.1.2) - fog-core - fog-json - fog-softlayer (1.1.1) - fog-core - fog-json - fog-storm_on_demand (0.1.1) - fog-core - fog-json - fog-terremark (0.1.0) - fog-core - fog-xml - fog-vmfusion (0.1.0) - fission - fog-core - fog-voxel (0.1.0) - fog-core - fog-xml - fog-xml (0.1.2) - fog-core - nokogiri (~> 1.5, >= 1.5.11) - formatador (0.2.5) - gh (0.14.0) - addressable - backports - faraday (~> 0.8) - multi_json (~> 1.0) - net-http-persistent (>= 2.7) - net-http-pipeline - google-api-client (0.9.4) - addressable (~> 2.3) - googleauth (~> 0.5) - httpclient (~> 2.7) - hurley (~> 0.1) - memoist (~> 0.11) - mime-types (>= 1.6) - representable (~> 2.3.0) - retriable (~> 2.0) - thor (~> 0.19) - googleauth (0.5.1) - faraday (~> 0.9) - jwt (~> 1.4) - logging (~> 2.0) - memoist (~> 0.12) - multi_json (~> 1.11) - os (~> 0.9) - signet (~> 0.7) - guard (2.14.0) - formatador (>= 0.2.4) - listen (>= 2.7, < 4.0) - lumberjack (~> 1.0) - nenv (~> 0.1) - notiffany (~> 0.0) - pry (>= 0.9.12) - shellany (~> 0.0) - thor (>= 0.18.1) - guard-rake (1.0.0) - guard + faraday_middleware (0.14.0) + faraday (>= 0.7.4, < 1.0) + fast_gettext (1.1.2) + ffi (1.15.5) + ffi-compiler (1.0.1) + ffi (>= 1.0.0) rake - hiera (1.3.4) - json_pure - highline (1.7.8) - hocon (0.9.5) - http-cookie (1.0.2) + gettext (3.2.9) + locale (>= 2.0.5) + text (>= 1.3.0) + gettext-setup (0.34) + fast_gettext (~> 1.1.0) + gettext (>= 3.0.2, < 3.3.0) + locale + gssapi (1.3.1) + ffi (>= 1.0.1) + gyoku (1.3.1) + builder (>= 2.1.2) + hiera (3.8.0) + hiera-eyaml (3.2.2) + highline + optimist + highline (2.0.3) + hirb (0.7.3) + hocon (1.3.1) + honeycomb-beeline (2.8.1) + libhoney (~> 1.14, >= 1.14.2) + http (5.0.4) + addressable (~> 2.8) + http-cookie (~> 1.0) + http-form_data (~> 2.2) + llhttp-ffi (~> 0.4.0) + http-accept (1.7.0) + http-cookie (1.0.4) domain_name (~> 0.5) - httpclient (2.8.0) - hurley (0.2) - inflecto (0.0.2) - inifile (2.0.2) - ipaddress (0.8.3) - jgrep (1.4.1) - json - json (1.8.3) - json_pure (1.8.3) - jwt (1.5.4) - launchy (2.4.3) - addressable (~> 2.3) - listen (3.1.5) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - ruby_dep (~> 1.2) + http-form_data (2.3.0) + httpclient (2.8.3) + jgrep (1.5.4) + jmespath (1.5.0) + json (2.1.0) + json-schema (2.8.1) + addressable (>= 2.4) + jwt (2.2.3) + libhoney (1.21.0) + addressable (~> 2.0) + excon + http (>= 2.0, < 6.0) little-plugger (1.1.4) - logging (2.1.0) + llhttp-ffi (0.4.0) + ffi-compiler (~> 1.0) + rake (~> 13.0) + locale (2.1.3) + log4r (1.1.10) + logging (2.3.0) little-plugger (~> 1.1) - multi_json (~> 1.10) - lumberjack (1.0.10) - mcollective-client (2.8.4) - json - stomp - systemu - memoist (0.14.0) + multi_json (~> 1.14) metaclass (0.0.4) - metadata-json-lint (0.0.11) - json + metadata-json-lint (3.0.1) + json-schema (~> 2.8) spdx-licenses (~> 1.0) - method_source (0.8.2) - mime-types (2.99.2) - mini_portile2 (2.0.0) - minitest (5.9.0) + method_source (1.0.0) + mime-types (3.4.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2022.0105) + minitar (0.9) mocha (1.1.0) metaclass (~> 0.0.1) - multi_json (1.12.1) - multipart-post (2.0.0) - nenv (0.3.0) - net-http-persistent (2.9.4) - net-http-pipeline (1.0.1) + molinillo (0.8.0) + multi_json (1.15.0) + multipart-post (2.1.1) + net-http-persistent (4.0.1) + connection_pool (~> 2.2) net-scp (1.2.1) net-ssh (>= 2.6.5) - net-ssh (2.9.4) + net-ssh (6.1.0) + net-ssh-krb (0.5.1) + gssapi (~> 1.3.0) + net-ssh (>= 2.0) net-telnet (0.1.1) netrc (0.11.0) - nokogiri (1.6.7.2) - mini_portile2 (~> 2.0.0.rc2) - notiffany (0.1.0) - nenv (~> 0.1) - shellany (~> 0.0) - open_uri_redirections (0.2.1) - os (0.9.6) - pry (0.10.3) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) - puppet (3.7.5) - facter (> 1.6, < 3) - hiera (~> 1.0) - json_pure - puppet-blacksmith (3.3.1) - puppet (>= 2.7.16) - rest-client - puppet-lint (1.1.0) - puppet-syntax (2.1.0) + nori (2.6.0) + optimist (3.0.1) + orchestrator_client (0.5.2) + faraday + net-http-persistent + parallel (1.21.0) + parallel_tests (3.7.3) + parallel + parser (3.1.0.0) + ast (~> 2.4.1) + pathspec (1.0.0) + pluginator (1.5.0) + pry (0.14.1) + coderay (~> 1.1) + method_source (~> 1.0) + public_suffix (4.0.6) + puppet (7.14.0) + concurrent-ruby (~> 1.0) + deep_merge (~> 1.0) + facter (> 2.0.1, < 5) + fast_gettext (>= 1.1, < 3) + hiera (>= 3.2.1, < 4) + locale (~> 2.1) + multi_json (~> 1.10) + puppet-resource_api (~> 1.5) + scanf (~> 1.0) + semantic_puppet (~> 1.0) + puppet-blacksmith (6.1.1) + puppet-modulebuilder (~> 0.2) + rest-client (~> 2.0) + puppet-debugger (1.2.0) + awesome_print (~> 1.7) + bundler + facterdb (>= 0.4.0) + pluginator (~> 1.5.0) + puppet (>= 5.5) + rb-readline (>= 0.5.5) + table_print (>= 1.0.0) + tty-pager (~> 0.13.0) + puppet-lint (2.5.2) + puppet-module-posix-default-r2.6 (1.1.1) + puppet-module-posix-dev-r2.6 (1.1.1) + bcrypt_pbkdf (~> 1.0) + codecov (~> 0.2) + concurrent-ruby (!= 1.1.6) + dependency_checker (~> 0.2) + ed25519 (~> 1.2) + facterdb (>= 0.8.1, < 2.0.0) + metadata-json-lint (>= 2.0.2, < 4.0.0) + mocha (>= 1.0.0, < 1.2.0) + parallel_tests (~> 3.4) + pry (~> 0.10) + puppet-blacksmith (~> 6.0) + puppet-debugger (~> 1.0) + puppet-lint (>= 2.3.0, < 3.0.0) + puppet-resource_api (~> 1.8) + puppet-strings (~> 2.0) + puppet-syntax (~> 3.0) + puppetlabs_spec_helper (>= 2.9.0, < 4.0.0) + rainbow (~> 2.0) + rspec-puppet (>= 2.3.2, < 3.0.0) + rspec-puppet-facts (>= 1.10.0, < 3) + rspec_junit_formatter (~> 0.2) + rubocop (= 1.6.1) + rubocop-performance (= 1.9.1) + rubocop-rspec (= 2.0.1) + serverspec (~> 2.41) + simplecov (< 0.19.0) + simplecov-console (~> 0.4.2) + specinfra (= 2.82.2) + puppet-module-posix-system-r2.6 (1.1.1) + puppet_litmus (~> 0.20) + puppet-modulebuilder (0.3.0) + minitar (~> 0.9) + pathspec (>= 0.2.1, < 2.0.0) + puppet-resource_api (1.8.14) + hocon (>= 1.0) + puppet-strings (2.9.0) + rgen + yard (~> 0.9.5) + puppet-syntax (3.1.0) + puppet (>= 5) rake - puppetlabs_spec_helper (1.1.1) - mocha - puppet-lint - puppet-syntax + puppet_forge (2.3.4) + faraday (>= 0.9.0, < 0.18.0, != 0.13.1) + faraday_middleware (>= 0.9.0, < 0.15.0) + gettext-setup (~> 0.11) + minitar + semantic_puppet (~> 1.0) + puppet_litmus (0.30.0) + bolt (>= 2.0.1, < 4.0.0) + docker-api (>= 1.34, < 3.0.0) + honeycomb-beeline + parallel + puppet-modulebuilder (>= 0.2.1, < 1.0.0) + retryable (~> 3.0) + rspec + rspec_honeycomb_formatter + tty-spinner (>= 0.5.0, < 1.0.0) + puppetfile-resolver (0.5.0) + molinillo (~> 0.6) + semantic_puppet (~> 1.0) + puppetlabs_spec_helper (3.0.0) + mocha (~> 1.0) + pathspec (>= 0.2.1, < 1.1.0) + puppet-lint (~> 2.0) + puppet-syntax (>= 2.0, < 4) + rspec-puppet (~> 2.0) + r10k (3.14.0) + colored2 (= 3.1.2) + cri (= 2.15.10) + fast_gettext (~> 1.1.0) + gettext (>= 3.0.2, < 3.3.0) + gettext-setup (~> 0.24) + jwt (~> 2.2.3) + log4r (= 1.1.10) + minitar (~> 0.9.0) + multi_json (~> 1.10) + puppet_forge (~> 2.3.0) + rainbow (2.2.2) rake - rspec-puppet - pusher-client (0.6.2) - json - websocket (~> 1.0) - rake (11.1.2) - rb-fsevent (0.9.7) - rb-inotify (0.9.7) - ffi (>= 0.5.0) - rbvmomi (1.8.2) - builder - nokogiri (>= 1.4.1) - trollop - representable (2.3.0) - uber (~> 0.0.7) - require_all (1.3.3) - rest-client (1.8.0) + rake (13.0.6) + rb-readline (0.5.5) + regexp_parser (2.2.0) + rest-client (2.1.0) + http-accept (>= 1.7.0, < 2.0) http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 3.0) - netrc (~> 0.7) - retriable (2.1.0) - rspec (3.4.0) - rspec-core (~> 3.4.0) - rspec-expectations (~> 3.4.0) - rspec-mocks (~> 3.4.0) - rspec-core (3.4.4) - rspec-support (~> 3.4.0) - rspec-expectations (3.4.0) + mime-types (>= 1.16, < 4.0) + netrc (~> 0.8) + retryable (3.0.5) + rexml (3.2.5) + rgen (0.9.0) + rspec (3.10.0) + rspec-core (~> 3.10.0) + rspec-expectations (~> 3.10.0) + rspec-mocks (~> 3.10.0) + rspec-core (3.10.1) + rspec-support (~> 3.10.0) + rspec-expectations (3.10.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) - rspec-its (1.2.0) + rspec-support (~> 3.10.0) + rspec-its (1.3.0) rspec-core (>= 3.0.0) rspec-expectations (>= 3.0.0) - rspec-mocks (3.4.1) + rspec-mocks (3.10.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) - rspec-puppet (2.4.0) + rspec-support (~> 3.10.0) + rspec-puppet (2.11.1) rspec - rspec-puppet-facts (1.6.1) + rspec-puppet-facts (2.0.3) facter - facterdb (>= 0.3.0) - json - mcollective-client + facterdb (>= 0.5.0) puppet - rspec-support (3.4.1) - rsync (1.0.9) - ruby_dep (1.3.1) - serverspec (2.36.0) + rspec-support (3.10.3) + rspec_honeycomb_formatter (0.2.1) + honeycomb-beeline + rspec-core (~> 3.0) + rspec_junit_formatter (0.5.1) + rspec-core (>= 2, < 4, != 2.12.0) + rubocop (1.6.1) + parallel (~> 1.10) + parser (>= 2.7.1.5) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml + rubocop-ast (>= 1.2.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 1.4.0, < 2.0) + rubocop-ast (1.15.1) + parser (>= 3.0.1.1) + rubocop-performance (1.9.1) + rubocop (>= 0.90.0, < 2.0) + rubocop-ast (>= 0.4.0) + rubocop-rspec (2.0.1) + rubocop (~> 1.0) + rubocop-ast (>= 1.1.0) + ruby-progressbar (1.11.0) + ruby_smb (1.1.0) + bindata + rubyntlm + windows_error + rubyntlm (0.6.3) + rubyzip (2.3.2) + scanf (1.0.0) + semantic_puppet (1.0.4) + serverspec (2.41.8) multi_json rspec (~> 3.0) rspec-its - specinfra (~> 2.53) - sfl (2.2) - shellany (0.0.1) - signet (0.7.2) - addressable (~> 2.3) - faraday (~> 0.9) - jwt (~> 1.5) - multi_json (~> 1.10) - slop (3.6.0) - spdx-licenses (1.1.0) - specinfra (2.59.0) + specinfra (~> 2.72) + sfl (2.3) + simplecov (0.18.5) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov-console (0.4.2) + ansi + hirb + simplecov + simplecov-html (0.12.3) + spdx-licenses (1.3.0) + specinfra (2.82.2) net-scp - net-ssh (>= 2.7, < 4.0) - net-telnet + net-ssh (>= 2.7) + net-telnet (= 0.1.1) sfl - stomp (1.3.5) - stringify-hash (0.0.2) - systemu (2.6.5) - thor (0.19.1) - travis (1.8.2) - backports - faraday (~> 0.9) - faraday_middleware (~> 0.9, >= 0.9.1) - gh (~> 0.13) - highline (~> 1.6) - launchy (~> 2.1) - pusher-client (~> 0.4) - typhoeus (~> 0.6, >= 0.6.8) - travis-lint (2.0.0) - json - trollop (2.1.2) - typhoeus (0.8.0) - ethon (>= 0.8.0) - uber (0.0.15) + strings (0.1.8) + strings-ansi (~> 0.1) + unicode-display_width (~> 1.5) + unicode_utils (~> 1.4) + strings-ansi (0.2.0) + table_print (1.5.7) + terminal-table (3.0.2) + unicode-display_width (>= 1.1.1, < 3) + text (1.3.1) + thor (1.2.1) + tty-cursor (0.7.1) + tty-pager (0.13.0) + strings (~> 0.1.8) + tty-screen (~> 0.8) + tty-screen (0.8.1) + tty-spinner (0.9.3) + tty-cursor (~> 0.7) unf (0.1.4) unf_ext - unf_ext (0.0.7.2) - vagrant-wrapper (2.0.3) - websocket (1.2.3) + unf_ext (0.0.8) + unicode-display_width (1.8.0) + unicode_utils (1.4.0) + webrick (1.7.0) + windows_error (0.1.3) + winrm (2.3.6) + builder (>= 2.1.2) + erubi (~> 1.8) + gssapi (~> 1.2) + gyoku (~> 1.0) + httpclient (~> 2.2, >= 2.2.0.2) + logging (>= 1.6.1, < 3.0) + nori (~> 2.0) + rubyntlm (~> 0.6.0, >= 0.6.3) + winrm-fs (1.3.5) + erubi (~> 1.8) + logging (>= 1.6.1, < 3.0) + rubyzip (~> 2.0) + winrm (~> 2.0) + yard (0.9.27) + webrick (~> 1.7.0) PLATFORMS - ruby + x86_64-linux DEPENDENCIES - beaker - beaker-rspec - guard-rake - metadata-json-lint - puppet (~> 3.7.0) - puppet-blacksmith - puppetlabs_spec_helper - rake - rspec-puppet - rspec-puppet-facts - travis - travis-lint - vagrant-wrapper + json (= 2.1.0) + puppet (< 8.0) + puppet-module-posix-default-r2.6 (~> 1.0) + puppet-module-posix-dev-r2.6 (~> 1.0) + puppet-module-posix-system-r2.6 (~> 1.0) + puppet-module-win-default-r2.6 (~> 1.0) + puppet-module-win-dev-r2.6 (~> 1.0) + puppet-module-win-system-r2.6 (~> 1.0) + +BUNDLED WITH + 2.2.31 diff --git a/README.md b/README.md index 2f196db..2d0612b 100644 --- a/README.md +++ b/README.md @@ -169,8 +169,7 @@ and while the mdadm type autorequires the mdadm package, there is no way to ensu that the package gets installed. The mdadm::array is a simple wrapper that includes the mdadm class to ensure the -mdadm package is installed. It doesn't do any parameter validation, it just passes -the parameters to the mdadm type. +mdadm package is installed. So if you don't want to have to do this: diff --git a/Rakefile b/Rakefile index ecc79e6..7721688 100644 --- a/Rakefile +++ b/Rakefile @@ -1,52 +1,87 @@ +# 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/version' -require 'puppet/vendor/semantic/lib/semantic' unless Puppet.version.to_f < 3.6 -require 'puppet-lint/tasks/puppet-lint' 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? -# These gems aren't always present, for instance -# on Travis with --without development -begin - require 'puppet_blacksmith/rake_tasks' -rescue LoadError +def changelog_user + return unless Rake.application.top_level_tasks.include? "changelog" + returnVal = nil || JSON.load(File.read('metadata.json'))['author'] + raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil? + puts "GitHubChangelogGenerator user:#{returnVal}" + returnVal end -Rake::Task[:lint].clear - -PuppetLint.configuration.relative = true -PuppetLint.configuration.send("disable_80chars") -PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}" -PuppetLint.configuration.fail_on_warnings = true - -# Forsake support for Puppet 2.6.2 for the benefit of cleaner code. -# http://puppet-lint.com/checks/class_parameter_defaults/ -PuppetLint.configuration.send('disable_class_parameter_defaults') -# http://puppet-lint.com/checks/class_inherits_from_params_class/ -PuppetLint.configuration.send('disable_class_inherits_from_params_class') - -exclude_paths = [ - "bundle/**/*", - "pkg/**/*", - "vendor/**/*", - "spec/**/*", -] -PuppetLint.configuration.ignore_paths = exclude_paths -PuppetSyntax.exclude_paths = exclude_paths -PuppetSyntax.fail_on_deprecation_notices = false - -desc "Run acceptance tests" -RSpec::Core::RakeTask.new(:acceptance) do |t| - t.pattern = 'spec/acceptance' +def changelog_project + return unless Rake.application.top_level_tasks.include? "changelog" + + 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 -task :metadata do - sh "metadata-json-lint metadata.json" +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 end -desc "Run syntax, lint, and spec tests." -task :test => [ - :syntax, - :lint, - :spec, - :metadata, -] +PuppetLint.configuration.send('disable_relative') + +if Bundler.rubygems.find_name('github_changelog_generator').any? + GitHubChangelogGenerator::RakeTask.new :changelog do |config| + raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil? + config.user = "#{changelog_user}" + config.project = "#{changelog_project}" + config.future_release = "#{changelog_future_release}" + config.exclude_labels = ['maintenance'] + config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)." + config.add_pr_wo_labels = true + config.issues = false + config.merge_prefix = "### UNCATEGORIZED PRS; 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"], + }, + } + 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 + end +end diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..a7ba73b --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,48 @@ +--- +version: 1.1.x.{build} +branches: + only: + - main + - release +skip_commits: + message: /^\(?doc\)?.*/ +clone_depth: 10 +init: + - SET + - 'mkdir C:\ProgramData\PuppetLabs\code && exit 0' + - 'mkdir C:\ProgramData\PuppetLabs\facter && exit 0' + - 'mkdir C:\ProgramData\PuppetLabs\hiera && exit 0' + - 'mkdir C:\ProgramData\PuppetLabs\puppet\var && exit 0' +environment: + matrix: + - + RUBY_VERSION: 25-x64 + CHECK: syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop + - + PUPPET_GEM_VERSION: ~> 6.0 + RUBY_VERSION: 25 + CHECK: parallel_spec + - + PUPPET_GEM_VERSION: ~> 6.0 + RUBY_VERSION: 25-x64 + CHECK: parallel_spec +matrix: + fast_finish: true +install: + - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH% + - bundle install --jobs 4 --retry 2 --without system_tests + - type Gemfile.lock +build: off +test_script: + - bundle exec puppet -V + - ruby -v + - gem -v + - bundle -v + - bundle exec rake %CHECK% +notifications: + - provider: Email + to: + - nobody@nowhere.com + on_build_success: false + on_build_failure: false + on_build_status_changed: false diff --git a/data/common.yaml b/data/common.yaml new file mode 100644 index 0000000..2fbf0ff --- /dev/null +++ b/data/common.yaml @@ -0,0 +1 @@ +--- {} diff --git a/hiera.yaml b/hiera.yaml new file mode 100644 index 0000000..545fff3 --- /dev/null +++ b/hiera.yaml @@ -0,0 +1,21 @@ +--- +version: 5 + +defaults: # Used for any hierarchy level that omits these keys. + datadir: data # This path is relative to hiera.yaml's directory. + data_hash: yaml_data # Use the built-in YAML backend. + +hierarchy: + - name: "osfamily/major release" + paths: + # Used to distinguish between Debian and Ubuntu + - "os/%{facts.os.name}/%{facts.os.release.major}.yaml" + - "os/%{facts.os.family}/%{facts.os.release.major}.yaml" + # Used for Solaris + - "os/%{facts.os.family}/%{facts.kernelrelease}.yaml" + - name: "osfamily" + paths: + - "os/%{facts.os.name}.yaml" + - "os/%{facts.os.family}.yaml" + - name: 'common' + path: 'common.yaml' diff --git a/manifests/array.pp b/manifests/array.pp index 9a3c22a..847d782 100644 --- a/manifests/array.pp +++ b/manifests/array.pp @@ -59,18 +59,18 @@ # } # define mdadm::array ( - $ensure, - $level, - $devices, - $active_devices = undef, - $spare_devices = undef, - $chunk = undef, - $parity = undef, - $bitmap = undef, - $metadata = undef, - $force = undef, - $generate_conf = undef, - $update_initramfs = undef, + Enum['created', 'assembled', 'stopped', 'absent'] $ensure, + String $level, + Array[String] $devices, + Optional[String] $active_devices = undef, + Optional[String] $spare_devices = undef, + Optional[String] $chunk = undef, + Optional[String] $parity = undef, + Optional[String] $bitmap = undef, + Optional[String] $metadata = undef, + Optional[Boolean] $force = undef, + Optional[Boolean] $generate_conf = undef, + Optional[Boolean] $update_initramfs = undef, ) { include mdadm diff --git a/manifests/init.pp b/manifests/init.pp index b429291..ca1fc5f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -20,33 +20,28 @@ # [*service_manage*] # Boolean. Whether to manage the service or not. Default is true. # +# [*service_hassstatus*] +# Boolean. Whether the service has a status command. Default depends upon OS. +# # [*include_cron*] # Boolean. Whether to ensure the mdadm cronjob exists in /etc/cron.d/ # class mdadm ( - $package_name = hiera('mdadm::package_name', $mdadm::params::package_name), - $package_ensure = hiera('mdadm::package_ensure', - $mdadm::params::package_ensure), - $service_name = hiera('mdadm::service_name', $mdadm::params::service_name), - $service_ensure = hiera('mdadm::service_ensure', - $mdadm::params::service_ensure), - $service_manage = hiera('mdadm::service_manage', - $mdadm::params::service_manage), - $service_hasstatus = hiera('mdadm::service_hasstatus', - $mdadm::params::service_hasstatus), - $include_cron = hiera('mdadm::include_cron', $mdadm::params::include_cron), + String $package_name = $mdadm::params::package_name, + String $package_ensure = $mdadm::params::package_ensure, + String $service_name = $mdadm::params::service_name, + Enum['running', 'stopped'] $service_ensure = $mdadm::params::service_ensure, + Boolean $service_manage = $mdadm::params::service_manage, + Boolean $service_hasstatus = $mdadm::params::service_hasstatus, + Boolean $include_cron = $mdadm::params::include_cron, ) inherits mdadm::params { - # validate parameters here - - anchor { 'mdadm::begin': } -> class { 'mdadm::install': } -> - class { 'mdadm::config': } - class { 'mdadm::service': } -> - anchor { 'mdadm::end': } + class { 'mdadm::config': } -> + class { 'mdadm::service': } - Anchor['mdadm::begin'] ~> Class['mdadm::service'] - Class['mdadm::install'] ~> Class['mdadm::service'] - Class['mdadm::config'] ~> Class['mdadm::service'] + contain 'mdadm::install' + contain 'mdadm::config' + contain 'mdadm::service' } diff --git a/manifests/params.pp b/manifests/params.pp index db09b93..c6b4f15 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -4,23 +4,36 @@ # It sets variables according to platform # class mdadm::params { - case $::facts['osfamily'] { + case $facts['osfamily'] { 'Debian': { $package_name = 'mdadm' $package_ensure = 'present' - $service_name = 'mdadm' + + # Under mdadm 3.3.1+ with systemd, the service is called mdmonitor + # This means Debian jessie (mdadm 3.3.2)/stretch (mdadm 3.4) and Ubuntu + # bionic (mdadm 4.0) for instance use 'mdmonitor' as the service name, + # but Ubuntu xenial (mdadm 3.3) and below still use 'mdadm' + if ($facts['operatingsystem'] == 'Ubuntu' and versioncmp($facts['operatingsystemrelease'], '16.10') < 0) or + ($facts['operatingsystem'] == 'Debian' and versioncmp($facts['operatingsystemrelease'], '8') < 0) { + $service_name = 'mdadm' + } else { + $service_name = 'mdmonitor' + } + $service_ensure = 'running' $service_manage = true + # Older mdadm packages don't have a service status - if versioncmp($::facts['lsbdistrelease'], '12') < 0 { + if ($facts['operatingsystem'] == 'Ubuntu' and versioncmp($facts['operatingsystemrelease'], '12.04') < 0) { $service_hasstatus = false } else { $service_hasstatus = true } + $include_cron = true } default: { - fail("${::facts['operatingsystem']} not supported") + fail("${facts['operatingsystem']} not supported") } } } diff --git a/metadata.json b/metadata.json index cfe03cc..f929699 100644 --- a/metadata.json +++ b/metadata.json @@ -1,26 +1,44 @@ { "name": "chartbeat-mdadm", - "version": "1.1.0", + "version": "2.0.2", "author": "chartbeat", "summary": "Module to manage mdadm", "license": "MIT", "source": "https://github.com/chartbeat-labs/puppet-mdadm", "project_page": "https://github.com/chartbeat-labs/puppet-mdadm", "issues_url": "https://github.com/chartbeat-labs/puppet-mdadm/issues", - "description": "Mdadm module for Puppet", "dependencies": [ - { - "name": "puppetlabs/stdlib", - "version_requirement": ">= 3.0.0" - } + ], "operatingsystem_support": [ { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", - "7" + "7", + "8", + "9", + "10" + ] + }, + { + "operatingsystem": "Ubuntu", + "operatingsystemrelease": [ + "10.04", + "12.04", + "16.04", + "18.04" ] } - ] + ], + "requirements": [ + { + "name": "puppet", + "version_requirement": ">= 6.21.0 < 8.0.0" + } + ], + "description": "Mdadm module for Puppet", + "pdk-version": "2.1.1", + "template-url": "https://github.com/puppetlabs/pdk-templates#2.1.1", + "template-ref": "tags/2.1.1-0-g03daa92" } diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb index bf57569..c05b9a9 100644 --- a/spec/classes/config_spec.rb +++ b/spec/classes/config_spec.rb @@ -1,22 +1,20 @@ require 'spec_helper' describe 'mdadm', :type => :class do - describe 'mdadm::config class on Debian' do - let(:facts) {{ - :osfamily => 'Debian', - :lsbdistrelease => '12.04', - }} + on_supported_os.each do |os, facts| + describe "mdadm::config class on #{os}" do + let(:facts) { facts } + context 'with no parameters' do + it { should contain_file('/etc/cron.d/mdadm') } + end - context 'with no parameters' do - it { should contain_file('/etc/cron.d/mdadm') } - end - - context 'with parameters' do - let(:params) {{ - :include_cron => false, - }} + context 'with parameters' do + let(:params) {{ + :include_cron => false, + }} - it { should_not contain_file('/etc/cron.d/mdadm') } + it { should_not contain_file('/etc/cron.d/mdadm') } + end end end end diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index b682153..8442a95 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -1,32 +1,33 @@ require 'spec_helper' describe 'mdadm' do - context 'supported operating systems' do - ['Debian'].each do |osfamily| - describe "mdadm class without any parameters on #{osfamily}" do - let(:params) {{ }} - let(:facts) {{ - :osfamily => osfamily, - :lsbdistrelease => '12.04', - }} - it { should contain_class('mdadm::params') } + on_supported_os.each do |os, facts| + context "supported operating system: #{os}" do + let(:params) {{ }} + let(:facts) { facts } - it { should contain_class('mdadm::install') } - it { should contain_class('mdadm::config') } - it { should contain_class('mdadm::service') } - end + it { should contain_class('mdadm::params') } + it { should contain_class('mdadm::install') } + it { should contain_class('mdadm::config') } + it { should contain_class('mdadm::service') } end end context 'unsupported operating system' do - describe 'mdadm class without any parameters on Solaris/Nexenta' do - let(:facts) {{ - :osfamily => 'Solaris', - :operatingsystem => 'Nexenta', - }} + test_on = { + supported_os: [ + { + 'operatingsystem' => 'Darwin', + }, + ], + } - it { expect { should raise_error(Puppet::Error, /Nexenta not supported/) }} + on_supported_os(test_on).each do |os, facts| + let(:facts) { facts } + describe "mdadm class without any parameters on #{os}" do + it { expect { should raise_error(Puppet::Error, /#{facts[:os]['name']} not supported/) }} + end end end end diff --git a/spec/classes/install_spec.rb b/spec/classes/install_spec.rb index 1dcc8cd..e3e4e8b 100644 --- a/spec/classes/install_spec.rb +++ b/spec/classes/install_spec.rb @@ -1,27 +1,26 @@ require 'spec_helper' describe 'mdadm', :type => :class do - describe 'mdadm::config class on Debian' do - # Default facts used for contexts - let(:facts) {{ - :osfamily => 'Debian', - :lsbdistrelease => '12.04', - }} + on_supported_os.each do |os, facts| + describe "mdadm::install class on #{os}" do + # Default facts used for contexts + let(:facts) { facts } - context 'with no parameters' do - it { should contain_package('mdadm') } - end + context 'with no parameters' do + it { should contain_package('mdadm') } + end - context 'with parameters' do - let(:params) {{ - :package_name => 'raidtools', - :package_ensure => '1.2.3', - }} + context 'with parameters' do + let(:params) {{ + :package_name => 'raidtools', + :package_ensure => '1.2.3', + }} - it { should contain_package('raidtools').with({ - 'ensure' => '1.2.3' + it { should contain_package('raidtools').with({ + 'ensure' => '1.2.3' }) - } + } + end end end end diff --git a/spec/classes/service_spec.rb b/spec/classes/service_spec.rb index c7ed93c..2adeecf 100644 --- a/spec/classes/service_spec.rb +++ b/spec/classes/service_spec.rb @@ -5,7 +5,8 @@ # Default facts used for contexts let(:facts) {{ :osfamily => 'Debian', - :lsbdistrelease => '12.04', + :operatingsystem => 'Ubuntu', + :operatingsystemrelease => '12.04', }} context 'with no parameters' do @@ -46,7 +47,8 @@ context 'with older mdadm package' do let(:facts) {{ :osfamily => 'Debian', - :lsbdistrelease => '10.04', + :operatingsystem => 'Ubuntu', + :operatingsystemrelease => '10.04', }} it { should contain_service('mdadm').with({ @@ -55,6 +57,37 @@ } end + context 'with an older Ubuntu systemd based system' do + let(:facts) {{ + :osfamily => 'Debian', + :operatingsystem => 'Ubuntu', + :operatingsystemrelease => '16.04', + }} + + it { should contain_service('mdadm') } + end + + context 'with a newer Ubuntu systemd based system' do + let(:facts) {{ + :osfamily => 'Debian', + :operatingsystem => 'Ubuntu', + :operatingsystemrelease => '18.04', + }} + + it { should contain_service('mdmonitor') } + end + + context 'with a older Debian systemd based system' do + let(:facts) {{ + :osfamily => 'Debian', + :operatingsystem => 'Debian', + :operatingsystemrelease => '8', + }} + + it { should contain_service('mdmonitor') } + end + + context 'with hassstatus overriden' do let(:params) {{ :service_hasstatus => false diff --git a/spec/default_facts.yml b/spec/default_facts.yml new file mode 100644 index 0000000..f777abf --- /dev/null +++ b/spec/default_facts.yml @@ -0,0 +1,8 @@ +# 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" diff --git a/spec/defines/array_spec.rb b/spec/defines/array_spec.rb index c9e2a45..8f3592e 100644 --- a/spec/defines/array_spec.rb +++ b/spec/defines/array_spec.rb @@ -5,28 +5,27 @@ '/dev/md1' end - let(:facts) {{ - :osfamily => 'Debian', - :lsbdistrelease => '12.04', - }} + on_supported_os.each do |os, facts| + let(:facts) { facts } - context 'when creating an array' do - let(:params) {{ - 'ensure' => 'created', - 'devices' => ['/dev/sdb', '/dev/sdc'], - 'level' => 0, - 'active_devices' => 2, - 'spare_devices' => 0, - 'chunk' => 512, - 'parity' => 'left-symmetric', - 'bitmap' => '/tmp/bitmap', - 'metadata' => '0.9', - 'force' => true, - 'generate_conf' => true, - 'update_initramfs' => true, - }} + context "when creating an array on #{os}" do + let(:params) {{ + 'ensure' => 'created', + 'devices' => ['/dev/sdb', '/dev/sdc'], + 'level' => '0', + 'active_devices' => '2', + 'spare_devices' => '0', + 'chunk' => '512', + 'parity' => 'left-symmetric', + 'bitmap' => '/tmp/bitmap', + 'metadata' => '0.9', + 'force' => true, + 'generate_conf' => true, + 'update_initramfs' => true, + }} - it { should contain_class('mdadm') } - it { should contain_mdadm('/dev/md1') } + it { should contain_class('mdadm') } + it { should contain_mdadm('/dev/md1') } + end end end diff --git a/spec/unit/puppet/parser/functions/check_array_spec.rb b/spec/functions/check_array_spec.rb similarity index 94% rename from spec/unit/puppet/parser/functions/check_array_spec.rb rename to spec/functions/check_array_spec.rb index 38312c3..741cfb1 100644 --- a/spec/unit/puppet/parser/functions/check_array_spec.rb +++ b/spec/functions/check_array_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper' describe 'check_devices' do - let(:scope) { PuppetlabsSpec::PuppetInternals.scope } - describe 'argument handling' do it 'fails with no arguments' do expect { scope.function_check_devices([]) }.to raise_error(Puppet::ParseError) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1ffdf17..9b1fa6f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,73 @@ +# 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 + +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) + last_module.const_get(next_module, false) + end +end + +# 'spec_overrides' from sync.yml will appear below this line diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 76769f5..a1a00c3 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -23,9 +23,5 @@ c.before :suite do # Install module and dependencies puppet_module_install(:source => proj_root, :module_name => 'mdadm') - hosts.each do |host| - on host, puppet('module', 'install', 'puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } - on host, puppet('module', 'install', 'puppetlabs-apt'), { :acceptable_exit_codes => [0,1] } - end end end diff --git a/spec/unit/puppet/provider/mdadm/mdadm_spec.rb b/spec/unit/puppet/provider/mdadm/mdadm_spec.rb index 7403dbe..c74ed16 100644 --- a/spec/unit/puppet/provider/mdadm/mdadm_spec.rb +++ b/spec/unit/puppet/provider/mdadm/mdadm_spec.rb @@ -7,62 +7,63 @@ describe provider_class do before :each do # Create a mock resource - @resource = stub('resource') - @resource.stubs(:name).returns('/dev/md1') - @resource.stubs(:[]).with(:devices).returns(['/dev/sdb', '/dev/sdc']) - @resource.stubs(:[]).with(:level).returns(0) - @resource.stubs(:[]).with(:metadata).returns('0.9') - @resource.stubs(:[]).with(:active_devices).returns(nil) - @resource.stubs(:[]).with(:spare_devices).returns(nil) - @resource.stubs(:[]).with(:parity).returns(nil) - @resource.stubs(:[]).with(:chunk).returns(nil) - @resource.stubs(:[]).with(:force).returns(false) - @resource.stubs(:[]).with(:generate_conf).returns(true) - @resource.stubs(:[]).with(:update_initramfs).returns(true) + @resource = double('resource') + allow(@resource).to receive(:name).and_return('/dev/md1') + allow(@resource).to receive(:[]).with(:devices).and_return(['/dev/sdb', '/dev/sdc']) + allow(@resource).to receive(:[]).with(:level).and_return('0') + allow(@resource).to receive(:[]).with(:metadata).and_return('0.9') + allow(@resource).to receive(:[]).with(:active_devices).and_return(nil) + allow(@resource).to receive(:[]).with(:spare_devices).and_return(nil) + allow(@resource).to receive(:[]).with(:parity).and_return(nil) + allow(@resource).to receive(:[]).with(:chunk).and_return(nil) + allow(@resource).to receive(:[]).with(:force).and_return(false) + allow(@resource).to receive(:[]).with(:generate_conf).and_return(true) + allow(@resource).to receive(:[]).with(:update_initramfs).and_return(true) @provider = provider_class.new(@resource) - @provider.class.stubs(:command).with(:mdadm_cmd).returns('/sbin/mdadm') - @provider.class.stubs(:command).with(:mkconf).returns('/usr/share/mdadm/mkconf') - @provider.class.stubs(:command).with(:yes).returns('/usr/bin/yes') - @provider.class.stubs(:command).with(:update_initramfs).returns('/usr/sbin/update_initramfs') + allow(@provider.class).to receive(:command).with(:mdadm_cmd).and_return('/sbin/mdadm') + allow(@provider.class).to receive(:command).with(:mkconf).and_return('/usr/share/mdadm/mkconf') + allow(@provider.class).to receive(:command).with(:yes).and_return('/usr/bin/yes') + allow(@provider.class).to receive(:command).with(:update_initramfs).and_return('/usr/sbin/update_initramfs') end describe '#create' do it "should execute the correct mdadm command" do - @provider.expects(:execute).with('/sbin/mdadm --create -e 0.9 /dev/md1 --level=0 --raid-devices=2 /dev/sdb /dev/sdc') - @provider.expects(:make_conf) - @provider.expects(:update_initramfs) + expect(@provider).to receive(:execute).with('/sbin/mdadm --create -e 0.9 /dev/md1 --level=0 --raid-devices=2 /dev/sdb /dev/sdc') + expect(@provider).to receive(:make_conf) + expect(@provider).to receive(:update_initramfs) @provider.create end it "should include the supplied parameters" do - @resource.stubs(:[]).with(:devices).returns(['/dev/sdb', '/dev/sdc', '/dev/sdd', '/dev/sde']) - @resource.stubs(:[]).with(:active_devices).returns(3) - @resource.stubs(:[]).with(:spare_devices).returns(1) - @resource.stubs(:[]).with(:metadata).returns('1.2') - @resource.stubs(:[]).with(:parity).returns('right-symmetric') - @resource.stubs(:[]).with(:chunk).returns('512') - @resource.stubs(:[]).with(:force).returns(true) - @resource.stubs(:[]).with(:generate_conf).returns(false) - @resource.stubs(:[]).with(:update_initramfs).returns(false) - @provider.expects(:execute).with('/usr/bin/yes | /sbin/mdadm --create -e 1.2 /dev/md1 --level=0 --raid-devices=3 --spare-devices=1 --parity=right-symmetric --chunk=512 /dev/sdb /dev/sdc /dev/sdd /dev/sde') + allow(@resource).to receive(:[]).with(:devices).and_return(['/dev/sdb', '/dev/sdc', '/dev/sdd', '/dev/sde']) + allow(@resource).to receive(:[]).with(:active_devices).and_return('3') + allow(@resource).to receive(:[]).with(:spare_devices).and_return('1') + allow(@resource).to receive(:[]).with(:metadata).and_return('1.2') + allow(@resource).to receive(:[]).with(:parity).and_return('right-symmetric') + allow(@resource).to receive(:[]).with(:chunk).and_return('512') + allow(@resource).to receive(:[]).with(:force).and_return(true) + allow(@resource).to receive(:[]).with(:generate_conf).and_return(false) + allow(@resource).to receive(:[]).with(:update_initramfs).and_return(false) + + expect(@provider).to receive(:execute).with('/usr/bin/yes | /sbin/mdadm --create -e 1.2 /dev/md1 --level=0 --raid-devices=3 --spare-devices=1 --parity=right-symmetric --chunk=512 /dev/sdb /dev/sdc /dev/sdd /dev/sde') @provider.create end end describe '#assemble' do it 'should execute the correct mdadm command' do - @provider.expects(:execute).with(['/sbin/mdadm', '--assemble', '/dev/md1', - ['/dev/sdb', '/dev/sdc']]) - @provider.expects(:make_conf) - @provider.expects(:update_initramfs) + expect(@provider).to receive(:execute).with(['/sbin/mdadm', '--assemble', '/dev/md1', + ['/dev/sdb', '/dev/sdc']]) + expect(@provider).to receive(:make_conf) + expect(@provider).to receive(:update_initramfs) @provider.assemble end it 'should include the supplied parameters' do - @resource.stubs(:[]).with(:generate_conf).returns(false) - @resource.stubs(:[]).with(:update_initramfs).returns(false) - @provider.expects(:execute).with(['/sbin/mdadm', '--assemble', '/dev/md1', + allow(@resource).to receive(:[]).with(:generate_conf).and_return(false) + allow(@resource).to receive(:[]).with(:update_initramfs).and_return(false) + expect(@provider).to receive(:execute).with(['/sbin/mdadm', '--assemble', '/dev/md1', ['/dev/sdb', '/dev/sdc']]) @provider.assemble end @@ -70,35 +71,39 @@ describe '#stop' do it 'should execute the correct mdadm command' do - @provider.expects(:execute).with(['/sbin/mdadm', '--misc', '--stop', '/dev/md1']) - @provider.expects(:make_conf) - @provider.expects(:update_initramfs) + expect(@provider).to receive(:execute).with(['/sbin/mdadm', '--misc', '--stop', '/dev/md1']) + expect(@provider).to receive(:make_conf) + expect(@provider).to receive(:update_initramfs) @provider.stop end it 'should include the supplied parameters' do - @resource.stubs(:[]).with(:generate_conf).returns(false) - @resource.stubs(:[]).with(:update_initramfs).returns(false) - @provider.expects(:execute).with(['/sbin/mdadm', '--misc', '--stop', '/dev/md1']) + expect(@resource).to receive(:[]).with(:generate_conf).and_return(false) + expect(@resource).to receive(:[]).with(:update_initramfs).and_return(false) + expect(@provider).to receive(:execute).with(['/sbin/mdadm', '--misc', '--stop', '/dev/md1']) @provider.stop end end describe '#exists?' do it 'should return true if array exists' do - @provider.expects(:execute).with(['/sbin/mdadm', '--detail', '--test', '/dev/md1']).returns(0) + allow_message_expectations_on_nil + expect(@provider).to receive(:execute).with(['/sbin/mdadm', '--detail', '--test', '/dev/md1']).and_return(0) + allow($CHILD_STATUS).to receive(:exitstatus).and_return(0) expect(@provider.exists?).to eq(true) end it 'should return false if array does not exist' do - @provider.stubs(:execute).raises(Puppet::ExecutionFailure, 'mdadm array /dev/md1 not found') - $CHILD_STATUS.stubs(:exitstatus).returns(4) + allow_message_expectations_on_nil + allow(@provider).to receive(:execute).and_raise(Puppet::ExecutionFailure, 'mdadm array /dev/md1 not found') + allow($CHILD_STATUS).to receive(:exitstatus).and_return(4) expect(@provider.exists?).to eq(false) end it 'should raise error if command fails' do - @provider.stubs(:execute).raises(Puppet::ExecutionFailure, 'Command not found') - $CHILD_STATUS.stubs(:exitstatus).returns(127) + allow_message_expectations_on_nil + allow(@provider).to receive(:execute).and_raise(Puppet::ExecutionFailure, 'Command not found') + allow($CHILD_STATUS).to receive(:exitstatus).and_return(127) expect { @provider.exists?}.to raise_error(Puppet::ExecutionFailure, /Command not found/) end end diff --git a/spec/unit/puppet/type/mdadm_spec.rb b/spec/unit/puppet/type/mdadm_spec.rb index 0f80f85..d47a0a4 100755 --- a/spec/unit/puppet/type/mdadm_spec.rb +++ b/spec/unit/puppet/type/mdadm_spec.rb @@ -4,7 +4,7 @@ describe Puppet::Type.type(:mdadm) do before :each do - Puppet::Type.type(:mdadm).stubs(:defaultprovider).returns(providerclass) + allow(Puppet::Type.type(:mdadm)).to receive(:defaultprovider).and_return(providerclass) end let(:providerclass) do