diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 12ed4ff..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM puppet/pdk:latest - -# [Optional] Uncomment this section to install additional packages. -# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ -# && apt-get -y install --no-install-recommends - diff --git a/.devcontainer/README.md b/.devcontainer/README.md deleted file mode 100644 index a719361..0000000 --- a/.devcontainer/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# devcontainer - - -For format details, see https://aka.ms/devcontainer.json. - -For config options, see the README at: -https://github.com/microsoft/vscode-dev-containers/tree/v0.140.1/containers/puppet - -``` json -{ - "name": "Puppet Development Kit (Community)", - "dockerFile": "Dockerfile", - - // Set *default* container specific settings.json values on container create. - "settings": { - "terminal.integrated.profiles.linux": { - "bash": { - "path": "bash", - } - } - }, - - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "puppet.puppet-vscode", - "rebornix.Ruby" - ], - - // Use 'forwardPorts' to make a list of ports inside the container available locally. - "forwardPorts": [], - - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pdk --version", -} -``` - - - diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index fe7a8b1..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "Puppet Development Kit (Community)", - "dockerFile": "Dockerfile", - - "settings": { - "terminal.integrated.profiles.linux": { - "bash": { - "path": "bash", - } - } - }, - - "extensions": [ - "puppet.puppet-vscode", - "rebornix.Ruby" - ] -} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ecb10a8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# editorconfig.org + +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +tab_width = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..593e7aa --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,26 @@ + + +## Affected Puppet, Ruby, OS and module versions/distributions + +- Puppet: +- Ruby: +- Distribution: +- Module version: + +## How to reproduce (e.g Puppet code you use) + +## What are you seeing + +## What behaviour did you expect instead + +## Output log + +## Any additional information you'd like to impart diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..342807b --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,20 @@ + +#### Pull Request (PR) description + + +#### This Pull Request (PR) fixes the following issues + diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..f2d08d6 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,6 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +skip-changelog: + - head-branch: ['^release-*', 'release'] diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..f5b5d7a --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,42 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes + +changelog: + exclude: + labels: + - duplicate + - invalid + - modulesync + - question + - skip-changelog + - wont-fix + - wontfix + + categories: + - title: Breaking Changes 🛠 + labels: + - backwards-incompatible + + - title: New Features 🎉 + labels: + - enhancement + + - title: Bug Fixes 🐛 + labels: + - bug + + - title: Documentation Updates 📚 + labels: + - documentation + - docs + + - title: Dependency Updates ⬆️ + labels: + - dependencies + + - title: Other Changes + labels: + - "*" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8c32acf --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,22 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: CI + +# yamllint disable-line rule:truthy +on: + pull_request: {} + push: + branches: + - main + - master + +concurrency: + group: ${{ github.ref_name }} + cancel-in-progress: true + +jobs: + puppet: + name: Puppet + uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v3 diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 0000000..73be88d --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,18 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: "Pull Request Labeler" + +# yamllint disable-line rule:truthy +on: + pull_request_target: {} + +jobs: + labeler: + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v5 diff --git a/.github/workflows/prepare_release.yml b/.github/workflows/prepare_release.yml new file mode 100644 index 0000000..01efa1a --- /dev/null +++ b/.github/workflows/prepare_release.yml @@ -0,0 +1,23 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: 'Prepare Release' + +on: + workflow_dispatch: + inputs: + version: + description: 'Module version to be released. Must be a valid semver string without leading v. (1.2.3)' + required: false + +jobs: + release_prep: + uses: 'voxpupuli/gha-puppet/.github/workflows/prepare_release.yml@v3' + with: + version: ${{ github.event.inputs.version }} + allowed_owner: 'voxpupuli' + secrets: + # Configure secrets here: + # https://docs.github.com/en/actions/security-guides/encrypted-secrets + github_pat: '${{ secrets.PCCI_PAT_RELEASE_PREP }}' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3db60fb --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,23 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: Release + +# yamllint disable-line rule:truthy +on: + push: + tags: + - '*' + +jobs: + release: + name: Release + uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v3 + with: + allowed_owner: 'voxpupuli' + secrets: + # Configure secrets here: + # https://docs.github.com/en/actions/security-guides/encrypted-secrets + username: ${{ secrets.PUPPET_FORGE_USERNAME }} + api_key: ${{ secrets.PUPPET_FORGE_API_KEY }} diff --git a/.gitignore b/.gitignore index c5236c4..adea1b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,33 +1,25 @@ -.git/ -.*.sw[op] -.metadata -.yardoc -.yardwarns -*.iml -/.bundle/ -/.idea/ +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +/pkg/ +/Gemfile.lock +/Gemfile.local +/vendor/ +/.vendor/ +/spec/fixtures/manifests/ +/spec/fixtures/modules/ /.vagrant/ +/.bundle/ +/.ruby-version /coverage/ -/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 -/.vscode/ -/.devcontainer/ -.tmp/ -Puppetfile.lock -.ruby-version +/.idea/ +/.dependencies/ +/.librarian/ +/Puppetfile.lock +*.iml +.*.sw? +/.yardoc/ +/Guardfile +bolt-debug.log +.rerun.json diff --git a/.msync.yml b/.msync.yml new file mode 100644 index 0000000..36e892e --- /dev/null +++ b/.msync.yml @@ -0,0 +1,5 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +modulesync_config_version: '9.4.0' diff --git a/.overcommit.yml b/.overcommit.yml new file mode 100644 index 0000000..4ed994c --- /dev/null +++ b/.overcommit.yml @@ -0,0 +1,67 @@ +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ +# +# Hooks are only enabled if you take action. +# +# To enable the hooks run: +# +# ``` +# bundle exec overcommit --install +# # ensure .overcommit.yml does not harm to you and then +# bundle exec overcommit --sign +# ``` +# +# (it will manage the .git/hooks directory): +# +# Examples howto skip a test for a commit or push: +# +# ``` +# SKIP=RuboCop git commit +# SKIP=PuppetLint git commit +# SKIP=RakeTask git push +# ``` +# +# Don't invoke overcommit at all: +# +# ``` +# OVERCOMMIT_DISABLE=1 git commit +# ``` +# +# Read more about overcommit: https://github.com/brigade/overcommit +# +# To manage this config yourself in your module add +# +# ``` +# .overcommit.yml: +# unmanaged: true +# ``` +# +# to your modules .sync.yml config +--- +PreCommit: + RuboCop: + enabled: true + description: 'Runs rubocop on modified files only' + command: ['bundle', 'exec', 'rubocop'] + RakeTarget: + enabled: true + description: 'Runs lint on modified files only' + targets: + - 'lint' + command: ['bundle', 'exec', 'rake'] + YamlSyntax: + enabled: true + JsonSyntax: + enabled: true + TrailingWhitespace: + enabled: true + +PrePush: + RakeTarget: + enabled: true + description: 'Run rake targets' + targets: + - 'validate' + - 'test' + - 'rubocop' + command: ['bundle', 'exec', 'rake'] diff --git a/.pdkignore b/.pdkignore deleted file mode 100644 index 862847a..0000000 --- a/.pdkignore +++ /dev/null @@ -1,44 +0,0 @@ -.git/ -.*.sw[op] -.metadata -.yardoc -.yardwarns -*.iml -/.bundle/ -/.idea/ -/.vagrant/ -/coverage/ -/bin/ -/doc/ -/Gemfile.local -/Gemfile.lock -/junit/ -/log/ -/pkg/ -/spec/fixtures/manifests/ -/spec/fixtures/modules/* -/tmp/ -/vendor/ -/convert_report.txt -/update_report.txt -.DS_Store -.project -.envrc -/inventory.yaml -/spec/fixtures/litmus_inventory.yaml -/.fixtures.yml -/Gemfile -/.gitattributes -/.github/ -/.gitignore -/.pdkignore -/.puppet-lint.rc -/Rakefile -/rakelib/ -/.rspec -/..yml -/.yardopts -/spec/ -/.vscode/ -/.sync.yml -/.devcontainer/ diff --git a/.pmtignore b/.pmtignore index 137c80c..a9d37aa 100644 --- a/.pmtignore +++ b/.pmtignore @@ -1,3 +1,39 @@ -vendor/ -.*/ -pkg/ +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +/docs/ +/pkg/ +/Gemfile +/Gemfile.lock +/Gemfile.local +/vendor/ +/.vendor/ +/spec/ +/Rakefile +/.vagrant/ +/.bundle/ +/.ruby-version +/coverage/ +/log/ +/.idea/ +/.dependencies/ +/.github/ +/.librarian/ +/Puppetfile.lock +/Puppetfile +*.iml +/.editorconfig +/.fixtures.yml +/.gitignore +/.msync.yml +/.overcommit.yml +/.pmtignore +/.rspec +/.rspec_parallel +/.rubocop.yml +/.sync.yml +.*.sw? +/.yardoc/ +/.yardopts +/Dockerfile +/HISTORY.md diff --git a/.puppet-lint.rc b/.puppet-lint.rc index cc96ece..05d28a2 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1 +1,6 @@ ---relative +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +--fail-on-warnings +--no-parameter_documentation-check +--no-parameter_types-check diff --git a/.rspec b/.rspec deleted file mode 100644 index 16f9cdb..0000000 --- a/.rspec +++ /dev/null @@ -1,2 +0,0 @@ ---color ---format documentation diff --git a/.rubocop.yml b/.rubocop.yml index 33d66a7..fded90c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,725 +1,7 @@ --- -inherit_from: .rubocop_todo.yml +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -require: -- rubocop-performance -- rubocop-rspec -AllCops: - DisplayCopNames: true - TargetRubyVersion: '2.6' - Include: - - "**/*.rb" - Exclude: - - bin/* - - ".vendor/**/*" - - "**/Gemfile" - - "**/Rakefile" - - pkg/**/* - - spec/fixtures/**/* - - vendor/**/* - - "**/Puppetfile" - - "**/Vagrantfile" - - "**/Guardfile" -Layout/LineLength: - Description: People have wide screens, use them. - Max: 200 -RSpec/BeforeAfterAll: - Description: Beware of using after(:all) as it may cause state to leak between tests. - A necessary evil in acceptance testing. - Exclude: - - spec/acceptance/**/*.rb -RSpec/HookArgument: - Description: Prefer explicit :each argument, matching existing module's style - EnforcedStyle: each -RSpec/DescribeSymbol: - Exclude: - - spec/unit/facter/**/*.rb -Style/BlockDelimiters: - Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to - be consistent then. - EnforcedStyle: braces_for_chaining -Style/ClassAndModuleChildren: - Description: Compact style reduces the required amount of indentation. - EnforcedStyle: compact -Style/EmptyElse: - Description: Enforce against empty else clauses, but allow `nil` for clarity. - EnforcedStyle: empty -Style/FormatString: - Description: Following the main puppet project's style, prefer the % format format. - EnforcedStyle: percent -Style/FormatStringToken: - Description: Following the main puppet project's style, prefer the simpler template - tokens over annotated ones. - EnforcedStyle: template -Style/Lambda: - Description: Prefer the keyword for easier discoverability. - EnforcedStyle: literal -Style/RegexpLiteral: - Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168 - EnforcedStyle: percent_r -Style/TernaryParentheses: - Description: Checks for use of parentheses around ternary conditions. Enforce parentheses - on complex expressions for better readability, but seriously consider breaking - it up. - EnforcedStyle: require_parentheses_when_complex -Style/TrailingCommaInArguments: - Description: Prefer always trailing comma on multiline argument lists. This makes - diffs, and re-ordering nicer. - EnforcedStyleForMultiline: comma -Style/TrailingCommaInArrayLiteral: - Description: Prefer always trailing comma on multiline literals. This makes diffs, - and re-ordering nicer. - EnforcedStyleForMultiline: comma -Style/SymbolArray: - Description: Using percent style obscures symbolic intent of array's contents. - EnforcedStyle: brackets -RSpec/MessageSpies: - EnforcedStyle: receive -Style/Documentation: - Exclude: - - lib/puppet/parser/functions/**/* - - spec/**/* -Style/WordArray: - EnforcedStyle: brackets -Performance/AncestorsInclude: - Enabled: true -Performance/BigDecimalWithNumericArgument: - Enabled: true -Performance/BlockGivenWithExplicitBlock: - Enabled: true -Performance/CaseWhenSplat: - Enabled: true -Performance/ConstantRegexp: - Enabled: true -Performance/MethodObjectAsBlock: - Enabled: true -Performance/RedundantSortBlock: - Enabled: true -Performance/RedundantStringChars: - Enabled: true -Performance/ReverseFirst: - Enabled: true -Performance/SortReverse: - Enabled: true -Performance/Squeeze: - Enabled: true -Performance/StringInclude: - Enabled: true -Performance/Sum: - Enabled: true -Style/CollectionMethods: - Enabled: true -Style/MethodCalledOnDoEndBlock: - Enabled: true -Style/StringMethods: - Enabled: true -Bundler/GemFilename: - Enabled: false -Bundler/InsecureProtocolSource: - Enabled: false -Capybara/CurrentPathExpectation: - Enabled: false -Capybara/VisibilityMatcher: - Enabled: false -Gemspec/DuplicatedAssignment: - Enabled: false -Gemspec/OrderedDependencies: - Enabled: false -Gemspec/RequiredRubyVersion: - Enabled: false -Gemspec/RubyVersionGlobalsUsage: - Enabled: false -Layout/ArgumentAlignment: - Enabled: false -Layout/BeginEndAlignment: - Enabled: false -Layout/ClosingHeredocIndentation: - Enabled: false -Layout/EmptyComment: - Enabled: false -Layout/EmptyLineAfterGuardClause: - Enabled: false -Layout/EmptyLinesAroundArguments: - Enabled: false -Layout/EmptyLinesAroundAttributeAccessor: - Enabled: false -Layout/EndOfLine: - Enabled: false -Layout/FirstArgumentIndentation: - Enabled: false -Layout/HashAlignment: - Enabled: false -Layout/HeredocIndentation: - Enabled: false -Layout/LeadingEmptyLines: - Enabled: false -Layout/SpaceAroundMethodCallOperator: - Enabled: false -Layout/SpaceInsideArrayLiteralBrackets: - Enabled: false -Layout/SpaceInsideReferenceBrackets: - Enabled: false -Lint/BigDecimalNew: - Enabled: false -Lint/BooleanSymbol: - Enabled: false -Lint/ConstantDefinitionInBlock: - Enabled: false -Lint/DeprecatedOpenSSLConstant: - Enabled: false -Lint/DisjunctiveAssignmentInConstructor: - Enabled: false -Lint/DuplicateElsifCondition: - Enabled: false -Lint/DuplicateRequire: - Enabled: false -Lint/DuplicateRescueException: - Enabled: false -Lint/EmptyConditionalBody: - Enabled: false -Lint/EmptyFile: - Enabled: false -Lint/ErbNewArguments: - Enabled: false -Lint/FloatComparison: - Enabled: false -Lint/HashCompareByIdentity: - Enabled: false -Lint/IdentityComparison: - Enabled: false -Lint/InterpolationCheck: - Enabled: false -Lint/MissingCopEnableDirective: - Enabled: false -Lint/MixedRegexpCaptureTypes: - Enabled: false -Lint/NestedPercentLiteral: - Enabled: false -Lint/NonDeterministicRequireOrder: - Enabled: false -Lint/OrderedMagicComments: - Enabled: false -Lint/OutOfRangeRegexpRef: - Enabled: false -Lint/RaiseException: - Enabled: false -Lint/RedundantCopEnableDirective: - Enabled: false -Lint/RedundantRequireStatement: - Enabled: false -Lint/RedundantSafeNavigation: - Enabled: false -Lint/RedundantWithIndex: - Enabled: false -Lint/RedundantWithObject: - Enabled: false -Lint/RegexpAsCondition: - Enabled: false -Lint/ReturnInVoidContext: - Enabled: false -Lint/SafeNavigationConsistency: - Enabled: false -Lint/SafeNavigationWithEmpty: - Enabled: false -Lint/SelfAssignment: - Enabled: false -Lint/SendWithMixinArgument: - Enabled: false -Lint/ShadowedArgument: - Enabled: false -Lint/StructNewOverride: - Enabled: false -Lint/ToJSON: - Enabled: false -Lint/TopLevelReturnWithArgument: - Enabled: false -Lint/TrailingCommaInAttributeDeclaration: - Enabled: false -Lint/UnreachableLoop: - Enabled: false -Lint/UriEscapeUnescape: - Enabled: false -Lint/UriRegexp: - Enabled: false -Lint/UselessMethodDefinition: - Enabled: false -Lint/UselessTimes: - Enabled: false -Metrics/AbcSize: - Enabled: false -Metrics/BlockLength: - Enabled: false -Metrics/BlockNesting: - Enabled: false -Metrics/ClassLength: - Enabled: false -Metrics/CyclomaticComplexity: - Enabled: false -Metrics/MethodLength: - Enabled: false -Metrics/ModuleLength: - Enabled: false -Metrics/ParameterLists: - Enabled: false -Metrics/PerceivedComplexity: - Enabled: false -Migration/DepartmentName: - Enabled: false -Naming/AccessorMethodName: - Enabled: false -Naming/BlockParameterName: - Enabled: false -Naming/HeredocDelimiterCase: - Enabled: false -Naming/HeredocDelimiterNaming: - Enabled: false -Naming/MemoizedInstanceVariableName: - Enabled: false -Naming/MethodParameterName: - Enabled: false -Naming/RescuedExceptionsVariableName: - Enabled: false -Naming/VariableNumber: - Enabled: false -Performance/BindCall: - Enabled: false -Performance/DeletePrefix: - Enabled: false -Performance/DeleteSuffix: - Enabled: false -Performance/InefficientHashSearch: - Enabled: false -Performance/UnfreezeString: - Enabled: false -Performance/UriDefaultParser: - Enabled: false -RSpec/Be: - Enabled: false -RSpec/Capybara/FeatureMethods: - Enabled: false -RSpec/ContainExactly: - Enabled: false -RSpec/ContextMethod: - Enabled: false -RSpec/ContextWording: - Enabled: false -RSpec/DescribeClass: - Enabled: false -RSpec/EmptyHook: - Enabled: false -RSpec/EmptyLineAfterExample: - Enabled: false -RSpec/EmptyLineAfterExampleGroup: - Enabled: false -RSpec/EmptyLineAfterHook: - Enabled: false -RSpec/ExampleLength: - Enabled: false -RSpec/ExampleWithoutDescription: - Enabled: false -RSpec/ExpectChange: - Enabled: false -RSpec/ExpectInHook: - Enabled: false -RSpec/FactoryBot/AttributeDefinedStatically: - Enabled: false -RSpec/FactoryBot/CreateList: - Enabled: false -RSpec/FactoryBot/FactoryClassName: - Enabled: false -RSpec/HooksBeforeExamples: - Enabled: false -RSpec/ImplicitBlockExpectation: - Enabled: false -RSpec/ImplicitSubject: - Enabled: false -RSpec/LeakyConstantDeclaration: - Enabled: false -RSpec/LetBeforeExamples: - Enabled: false -RSpec/MatchArray: - Enabled: false -RSpec/MissingExampleGroupArgument: - Enabled: false -RSpec/MultipleExpectations: - Enabled: false -RSpec/MultipleMemoizedHelpers: - Enabled: false -RSpec/MultipleSubjects: - Enabled: false -RSpec/NestedGroups: - Enabled: false -RSpec/PredicateMatcher: - Enabled: false -RSpec/ReceiveCounts: - Enabled: false -RSpec/ReceiveNever: - Enabled: false -RSpec/RepeatedExampleGroupBody: - Enabled: false -RSpec/RepeatedExampleGroupDescription: - Enabled: false -RSpec/RepeatedIncludeExample: - Enabled: false -RSpec/ReturnFromStub: - Enabled: false -RSpec/SharedExamples: - Enabled: false -RSpec/StubbedMock: - Enabled: false -RSpec/UnspecifiedException: - Enabled: false -RSpec/VariableDefinition: - Enabled: false -RSpec/VoidExpect: - Enabled: false -RSpec/Yield: - Enabled: false -Security/Open: - Enabled: false -Style/AccessModifierDeclarations: - Enabled: false -Style/AccessorGrouping: - Enabled: false -Style/BisectedAttrAccessor: - Enabled: false -Style/CaseLikeIf: - Enabled: false -Style/ClassEqualityComparison: - Enabled: false -Style/ColonMethodDefinition: - Enabled: false -Style/CombinableLoops: - Enabled: false -Style/CommentedKeyword: - Enabled: false -Style/Dir: - Enabled: false -Style/DoubleCopDisableDirective: - Enabled: false -Style/EmptyBlockParameter: - Enabled: false -Style/EmptyLambdaParameter: - Enabled: false -Style/Encoding: - Enabled: false -Style/EvalWithLocation: - Enabled: false -Style/ExpandPathArguments: - Enabled: false -Style/ExplicitBlockArgument: - Enabled: false -Style/ExponentialNotation: - Enabled: false -Style/FloatDivision: - Enabled: false -Style/FrozenStringLiteralComment: - Enabled: false -Style/GlobalStdStream: - Enabled: false -Style/HashAsLastArrayItem: - Enabled: false -Style/HashLikeCase: - Enabled: false -Style/HashTransformKeys: - Enabled: false -Style/HashTransformValues: - Enabled: false -Style/IfUnlessModifier: - Enabled: false -Style/KeywordParametersOrder: - Enabled: false -Style/MinMax: - Enabled: false -Style/MixinUsage: - Enabled: false -Style/MultilineWhenThen: - Enabled: false -Style/NegatedUnless: - Enabled: false -Style/NumericPredicate: - Enabled: false -Style/OptionalBooleanParameter: - Enabled: false -Style/OrAssignment: - Enabled: false -Style/RandomWithOffset: - Enabled: false -Style/RedundantAssignment: - Enabled: false -Style/RedundantCondition: - Enabled: false -Style/RedundantConditional: - Enabled: false -Style/RedundantFetchBlock: - Enabled: false -Style/RedundantFileExtensionInRequire: - Enabled: false -Style/RedundantRegexpCharacterClass: - Enabled: false -Style/RedundantRegexpEscape: - Enabled: false -Style/RedundantSelfAssignment: - Enabled: false -Style/RedundantSort: - Enabled: false -Style/RescueStandardError: - Enabled: false -Style/SingleArgumentDig: - Enabled: false -Style/SlicingWithRange: - Enabled: false -Style/SoleNestedConditional: - Enabled: false -Style/StderrPuts: - Enabled: false -Style/StringConcatenation: - Enabled: false -Style/Strip: - Enabled: false -Style/SymbolProc: - Enabled: false -Style/TrailingBodyOnClass: - Enabled: false -Style/TrailingBodyOnMethodDefinition: - Enabled: false -Style/TrailingBodyOnModule: - Enabled: false -Style/TrailingCommaInHashLiteral: - Enabled: false -Style/TrailingMethodEndStatement: - Enabled: false -Style/UnpackFirst: - Enabled: false -Capybara/MatchStyle: - Enabled: false -Capybara/NegationMatcher: - Enabled: false -Capybara/SpecificActions: - Enabled: false -Capybara/SpecificFinders: - Enabled: false -Capybara/SpecificMatcher: - Enabled: false -Gemspec/DeprecatedAttributeAssignment: - Enabled: false -Gemspec/DevelopmentDependencies: - Enabled: false -Gemspec/RequireMFA: - Enabled: false -Layout/LineContinuationLeadingSpace: - Enabled: false -Layout/LineContinuationSpacing: - Enabled: false -Layout/LineEndStringConcatenationIndentation: - Enabled: false -Layout/SpaceBeforeBrackets: - Enabled: false -Lint/AmbiguousAssignment: - Enabled: false -Lint/AmbiguousOperatorPrecedence: - Enabled: false -Lint/AmbiguousRange: - Enabled: false -Lint/ConstantOverwrittenInRescue: - Enabled: false -Lint/DeprecatedConstants: - Enabled: false -Lint/DuplicateBranch: - Enabled: false -Lint/DuplicateMagicComment: - Enabled: false -Lint/DuplicateRegexpCharacterClassElement: - Enabled: false -Lint/EmptyBlock: - Enabled: false -Lint/EmptyClass: - Enabled: false -Lint/EmptyInPattern: - Enabled: false -Lint/IncompatibleIoSelectWithFiberScheduler: - Enabled: false -Lint/LambdaWithoutLiteralBlock: - Enabled: false -Lint/NoReturnInBeginEndBlocks: - Enabled: false -Lint/NonAtomicFileOperation: - Enabled: false -Lint/NumberedParameterAssignment: - Enabled: false -Lint/OrAssignmentToConstant: - Enabled: false -Lint/RedundantDirGlobSort: - Enabled: false -Lint/RefinementImportMethods: - Enabled: false -Lint/RequireRangeParentheses: - Enabled: false -Lint/RequireRelativeSelfPath: - Enabled: false -Lint/SymbolConversion: - Enabled: false -Lint/ToEnumArguments: - Enabled: false -Lint/TripleQuotes: - Enabled: false -Lint/UnexpectedBlockArity: - Enabled: false -Lint/UnmodifiedReduceAccumulator: - Enabled: false -Lint/UselessRescue: - Enabled: false -Lint/UselessRuby2Keywords: - Enabled: false -Metrics/CollectionLiteralLength: - Enabled: false -Naming/BlockForwarding: - Enabled: false -Performance/CollectionLiteralInLoop: - Enabled: false -Performance/ConcurrentMonotonicTime: - Enabled: false -Performance/MapCompact: - Enabled: false -Performance/RedundantEqualityComparisonBlock: - Enabled: false -Performance/RedundantSplitRegexpArgument: - Enabled: false -Performance/StringIdentifierArgument: - Enabled: false -RSpec/BeEq: - Enabled: false -RSpec/BeNil: - Enabled: false -RSpec/ChangeByZero: - Enabled: false -RSpec/ClassCheck: - Enabled: false -RSpec/DuplicatedMetadata: - Enabled: false -RSpec/ExcessiveDocstringSpacing: - Enabled: false -RSpec/FactoryBot/ConsistentParenthesesStyle: - Enabled: false -RSpec/FactoryBot/FactoryNameStyle: - Enabled: false -RSpec/FactoryBot/SyntaxMethods: - Enabled: false -RSpec/IdenticalEqualityAssertion: - Enabled: false -RSpec/NoExpectationExample: - Enabled: false -RSpec/PendingWithoutReason: - Enabled: false -RSpec/Rails/AvoidSetupHook: - Enabled: false -RSpec/Rails/HaveHttpStatus: - Enabled: false -RSpec/Rails/InferredSpecType: - Enabled: false -RSpec/Rails/MinitestAssertions: - Enabled: false -RSpec/Rails/TravelAround: - Enabled: false -RSpec/RedundantAround: - Enabled: false -RSpec/SkipBlockInsideExample: - Enabled: false -RSpec/SortMetadata: - Enabled: false -RSpec/SubjectDeclaration: - Enabled: false -RSpec/VerifiedDoubleReference: - Enabled: false -Security/CompoundHash: - Enabled: false -Security/IoMethods: - Enabled: false -Style/ArgumentsForwarding: - Enabled: false -Style/ArrayIntersect: - Enabled: false -Style/CollectionCompact: - Enabled: false -Style/ComparableClamp: - Enabled: false -Style/ConcatArrayLiterals: - Enabled: false -Style/DirEmpty: - Enabled: false -Style/DocumentDynamicEvalDefinition: - Enabled: false -Style/EmptyHeredoc: - Enabled: false -Style/EndlessMethod: - Enabled: false -Style/EnvHome: - Enabled: false -Style/FetchEnvVar: - Enabled: false -Style/FileEmpty: - Enabled: false -Style/FileRead: - Enabled: false -Style/FileWrite: - Enabled: false -Style/HashConversion: - Enabled: false -Style/HashExcept: - Enabled: false -Style/IfWithBooleanLiteralBranches: - Enabled: false -Style/InPatternThen: - Enabled: false -Style/MagicCommentFormat: - Enabled: false -Style/MapCompactWithConditionalBlock: - Enabled: false -Style/MapToHash: - Enabled: false -Style/MapToSet: - Enabled: false -Style/MinMaxComparison: - Enabled: false -Style/MultilineInPatternThen: - Enabled: false -Style/NegatedIfElseCondition: - Enabled: false -Style/NestedFileDirname: - Enabled: false -Style/NilLambda: - Enabled: false -Style/NumberedParameters: - Enabled: false -Style/NumberedParametersLimit: - Enabled: false -Style/ObjectThen: - Enabled: false -Style/OpenStructUse: - Enabled: false -Style/OperatorMethodCall: - Enabled: false -Style/QuotedSymbols: - Enabled: false -Style/RedundantArgument: - Enabled: false -Style/RedundantConstantBase: - Enabled: false -Style/RedundantDoubleSplatHashBraces: - Enabled: false -Style/RedundantEach: - Enabled: false -Style/RedundantHeredocDelimiterQuotes: - Enabled: false -Style/RedundantInitialize: - Enabled: false -Style/RedundantSelfAssignmentBranch: - Enabled: false -Style/RedundantStringEscape: - Enabled: false -Style/SelectByRegexp: - Enabled: false -Style/StringChars: - Enabled: false -Style/SwapValues: - Enabled: false +inherit_from: .rubocop_todo.yml +inherit_gem: + voxpupuli-test: rubocop.yml diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index 2f1e4f7..0000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "recommendations": [ - "puppet.puppet-vscode", - "rebornix.Ruby" - ] -} diff --git a/.yardopts b/.yardopts deleted file mode 100644 index 29c933b..0000000 --- a/.yardopts +++ /dev/null @@ -1 +0,0 @@ ---markup markdown diff --git a/Gemfile b/Gemfile index ca0e773..2ac98f8 100644 --- a/Gemfile +++ b/Gemfile @@ -1,78 +1,32 @@ -source ENV['GEM_SOURCE'] || 'https://rubygems.org' +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -def location_for(place_or_version, fake_version = nil) - git_url_regex = %r{\A(?(https?|git)[:@][^#]*)(#(?.*))?} - file_url_regex = %r{\Afile:\/\/(?.*)} +source ENV['GEM_SOURCE'] || 'https://rubygems.org' - 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 +group :test do + gem 'voxpupuli-test', '~> 9.0', :require => false + gem 'coveralls', :require => false + gem 'simplecov-console', :require => false + gem 'puppet_metadata', '~> 4.0', :require => false end group :development do - gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.5.1', require: false if Gem::Requirement.create(['>= 3.0.0', '< 3.0.5']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.6.1', require: false if Gem::Requirement.create(['>= 3.1.0', '< 3.1.3']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.6.3', require: false if Gem::Requirement.create(['>= 3.2.0', '< 4.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "racc", '~> 1.4.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false - gem "facterdb", '~> 1.18', require: false - gem "metadata-json-lint", '~> 3.0', require: false - gem "puppetlabs_spec_helper", '~> 6.0', require: false - gem "rspec-puppet-facts", '~> 2.0', require: false - gem "codecov", '~> 0.2', require: false - gem "dependency_checker", '~> 1.0.0', require: false - gem "parallel_tests", '= 3.12.1', require: false - gem "pry", '~> 0.10', require: false - gem "simplecov-console", '~> 0.5', require: false - gem "puppet-debugger", '~> 1.0', require: false - gem "rubocop", '= 1.48.1', require: false - gem "rubocop-performance", '= 1.16.0', require: false - gem "rubocop-rspec", '= 2.19.0', require: false - gem "puppet-strings", '~> 4.0', require: false - gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem 'guard-rake', :require => false + gem 'overcommit', '>= 0.39.1', :require => false end + group :system_tests do - gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] - gem "serverspec", '~> 2.41', require: false + gem 'voxpupuli-acceptance', '~> 3.0', :require => false end -group :release_prep do - gem "puppet-strings", '~> 4.0', require: false - gem "puppetlabs_spec_helper", '~> 6.0', require: false -end - -puppet_version = ENV['PUPPET_GEM_VERSION'] -facter_version = ENV['FACTER_GEM_VERSION'] -hiera_version = ENV['HIERA_GEM_VERSION'] - -gems = {} -gems['puppet'] = location_for(puppet_version) - -# If facter or hiera versions have been specified via the environment -# variables - -gems['facter'] = location_for(facter_version) if facter_version -gems['hiera'] = location_for(hiera_version) if hiera_version - -gems.each do |gem_name, gem_params| - gem gem_name, *gem_params +group :release do + gem 'voxpupuli-release', '~> 3.0', :require => false end -# Evaluate Gemfile.local and ~/.gemfile if they exist -extra_gemfiles = [ - "#{__FILE__}.local", - File.join(Dir.home, '.gemfile'), -] +gem 'rake', :require => false +gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test] + +puppetversion = ENV['PUPPET_GEM_VERSION'] || [">= 7.24", "< 9"] +gem 'puppet', puppetversion, :require => false, :groups => [:test] -extra_gemfiles.each do |gemfile| - if File.file?(gemfile) && File.readable?(gemfile) - eval(File.read(gemfile), binding) - end -end # vim: syntax=ruby diff --git a/Rakefile b/Rakefile index 74415a9..5a13af9 100644 --- a/Rakefile +++ b/Rakefile @@ -1,88 +1,44 @@ -# frozen_string_literal: true - -require 'bundler' -require 'puppet_litmus/rake_tasks' if Gem.loaded_specs.key? 'puppet_litmus' -require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet-syntax/tasks/puppet-syntax' -require 'github_changelog_generator/task' if Gem.loaded_specs.key? 'github_changelog_generator' -require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings' - -def changelog_user - return unless Rake.application.top_level_tasks.include? "changelog" - returnVal = nil || JSON.load(File.read('metadata.json'))['author'] - raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil? - puts "GitHubChangelogGenerator user:#{returnVal}" - returnVal -end - -def changelog_project - return unless Rake.application.top_level_tasks.include? "changelog" - - returnVal = nil - 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] +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +# Attempt to load voxpupuli-test (which pulls in puppetlabs_spec_helper), +# otherwise attempt to load it directly. +begin + require 'voxpupuli/test/rake' +rescue LoadError + begin + require 'puppetlabs_spec_helper/rake_tasks' + rescue LoadError end - - raise "unable to find the changelog_project in .sync.yml or calculate it from the source in metadata.json" if returnVal.nil? - - puts "GitHubChangelogGenerator project:#{returnVal}" - returnVal end -def changelog_future_release - return unless Rake.application.top_level_tasks.include? "changelog" - returnVal = "v%s" % JSON.load(File.read('metadata.json'))['version'] - raise "unable to find the future_release (version) in metadata.json" if returnVal.nil? - puts "GitHubChangelogGenerator future_release:#{returnVal}" - returnVal +# load optional tasks for acceptance +# only available if gem group releases is installed +begin + require 'voxpupuli/acceptance/rake' +rescue LoadError end -PuppetLint.configuration.send('disable_relative') - - -if Gem.loaded_specs.key? 'github_changelog_generator' - 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 +# load optional tasks for releases +# only available if gem group releases is installed +begin + require 'voxpupuli/release/rake_tasks' +rescue LoadError + # voxpupuli-release not present 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 + GCGConfig.user = 'voxpupuli' + GCGConfig.project = 'puppet-powerdns' +end + +desc "Run main 'test' task and report merged results to coveralls" +task test_with_coveralls: [:test] do + if Dir.exist?(File.expand_path('../lib', __FILE__)) + require 'coveralls/rake/task' + Coveralls::RakeTask.new + Rake::Task['coveralls:push'].invoke + else + puts 'Skipping reporting to coveralls. Module has no lib dir' end end +# vim: syntax=ruby diff --git a/lib/puppet/provider/powerdns_autoprimary/pdnsutil.rb b/lib/puppet/provider/powerdns_autoprimary/pdnsutil.rb index c826a60..d9b5568 100644 --- a/lib/puppet/provider/powerdns_autoprimary/pdnsutil.rb +++ b/lib/puppet/provider/powerdns_autoprimary/pdnsutil.rb @@ -14,10 +14,11 @@ def initialize(value = {}) def self.instances pdnsutil('list-autoprimaries').split("\n").map do |line| raise Puppet::Error, "Cannot parse invalid autoprimary line: #{line}" unless line =~ %r{^IP=(\S+),\s+NS=(\S+),\s+account=(\S*)$} + new( ensure: :present, - name: Regexp.last_match(1) + '@' + Regexp.last_match(2), - account: Regexp.last_match(3), + name: "#{Regexp.last_match(1)}@#{Regexp.last_match(2)}", + account: Regexp.last_match(3) ) end end @@ -57,6 +58,7 @@ def exists? def flush return if @property_flush.empty? + content = @property_flush[:content] || @resource[:content] virsh_define(content) @property_flush.clear diff --git a/lib/puppet/provider/powerdns_zone_private/pdnsutil.rb b/lib/puppet/provider/powerdns_zone_private/pdnsutil.rb index 410e53a..a39c0c1 100644 --- a/lib/puppet/provider/powerdns_zone_private/pdnsutil.rb +++ b/lib/puppet/provider/powerdns_zone_private/pdnsutil.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + # This file contains a provider for the resource type `powerdns_zone`, # require 'tempfile' Puppet::Type.type(:powerdns_zone_private).provide( - :pdnsutil, + :pdnsutil ) do desc "A provider for the resource type `powerdns_zone`, which manages a zone on powerdns @@ -66,11 +68,12 @@ def content @serial = '1' return c end - soarec = records[soanr].split(' ') + soarec = records[soanr].split @serial = soarec[-5] soarec[-5] = '_SERIAL_' - records[soanr] = soarec[0..3].join("\t") + "\t" + soarec[4..10].join(' ') - records.sort.join("\n") + "\n" end + records[soanr] = "#{soarec[0..3].join("\t")}\t#{soarec[4..10].join(' ')}" + "#{records.sort.join("\n")}\n" + end # rubocop:enable Metrics/AbcSize # rubocop:enable Metrics/MethodLength diff --git a/lib/puppet/type/powerdns_record.rb b/lib/puppet/type/powerdns_record.rb index 4361361..c300df1 100644 --- a/lib/puppet/type/powerdns_record.rb +++ b/lib/puppet/type/powerdns_record.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Puppet::Type.newtype(:powerdns_record) do @doc = ' ensure a zone exists.' diff --git a/lib/puppet/type/powerdns_zone.rb b/lib/puppet/type/powerdns_zone.rb index 31de8f6..2d04019 100644 --- a/lib/puppet/type/powerdns_zone.rb +++ b/lib/puppet/type/powerdns_zone.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'puppet/parameter/boolean' Puppet::Type.newtype(:powerdns_zone) do @@ -121,11 +123,11 @@ def soa_record def records # Collect records that target this zone. - @records ||= catalog.resources.map { |resource| + @records ||= catalog.resources.map do |resource| next unless resource.is_a?(Puppet::Type.type(:powerdns_record)) resource if resource[:target_zone] == title - }.compact + end.compact end def should_content @@ -136,9 +138,8 @@ def should_content if r[:rname] == '.' content.push([r[:target_zone], r[:rttl], r[:rclass], r[:rtype], r[:rcontent]].join("\t")) else - content.push([r[:rname] + '.' + r[:target_zone], r[:rttl], r[:rclass], r[:rtype], r[:rcontent]].join("\t")) + content.push(["#{r[:rname]}.#{r[:target_zone]}", r[:rttl], r[:rclass], r[:rtype], r[:rcontent]].join("\t")) end - # rubocop:enable Style/StringConcatenation end content.push("$ORIGIN .\n") # add this, since it's always in the output.. content.sort.join("\n") @@ -150,16 +151,16 @@ def generate # without content powerdns_zone_private_opts = {} - [:name, - :config_name, - :config_dir, - :show_diff, - :manage_records].each do |p| + %i[name + config_name + config_dir + show_diff + manage_records].each do |p| powerdns_zone_private_opts[p] = self[p] unless self[p].nil? end powerdns_zone_private_opts['ensure'] = self['zone_ensure'] - excluded_metaparams = [:before, :notify, :require, :subscribe, :tag] + excluded_metaparams = %i[before notify require subscribe tag] Puppet::Type.metaparams.each do |metaparam| powerdns_zone_private_opts[metaparam] = self[metaparam] unless self[metaparam].nil? || excluded_metaparams.include?(metaparam) @@ -167,7 +168,6 @@ def generate [Puppet::Type.type(:powerdns_zone_private).new(powerdns_zone_private_opts)] end - # rubocop:enable Metrics/AbcSize # rubocop:enable Metrics/MethodLength def eval_generate @@ -186,6 +186,6 @@ def eval_generate # autorequire the powerdns_records autorequire(:powerdns_record) do + # placeholder end - # rubocop:enable Lint/EmptyBlock end diff --git a/lib/puppet/type/powerdns_zone_private.rb b/lib/puppet/type/powerdns_zone_private.rb index f39a78d..d855cc8 100644 --- a/lib/puppet/type/powerdns_zone_private.rb +++ b/lib/puppet/type/powerdns_zone_private.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # private resource which collected all the records through powerdns_zone require 'puppet/parameter/boolean' @@ -51,7 +53,7 @@ munge do |value| if @resource[:manage_records] - value.to_s.gsub(%r{\n+$}, '') + "\n" + "#{value.to_s.gsub(%r{\n+$}, '')}\n" else '' end @@ -59,17 +61,17 @@ def should_to_s(value) if @resource[:show_diff] - ":\n" + value + ":\n#{value}" else - '{md5}' + Digest::MD5.hexdigest(value.to_s) + "{md5}#{Digest::MD5.hexdigest(value.to_s)}" end end - def is_to_s(value) # rubocop:disable Naming/PredicateName + def is_to_s(value) if @resource[:show_diff] - ":\n" + value + ":\n#{value}" else - '{md5}' + Digest::MD5.hexdigest(value.to_s) + "{md5}#{Digest::MD5.hexdigest(value.to_s)}" end end end @@ -79,6 +81,6 @@ def is_to_s(value) # rubocop:disable Naming/PredicateName ['pdns'] end autorequire(:powerdns_zone) do + # placeholder end - # rubocop:enable Lint/EmptyBlock end diff --git a/pdk.yaml b/pdk.yaml deleted file mode 100644 index 4bef4bd..0000000 --- a/pdk.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -ignore: [] diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 2834e27..e7dc26c 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper_acceptance' case default['platform'] diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml deleted file mode 100644 index 62097a8..0000000 --- a/spec/acceptance/nodesets/default.yml +++ /dev/null @@ -1,11 +0,0 @@ -HOSTS: - centos-72-x64: - roles: - - master - platform: el-7-x86_64 - box: puppetlabs/centos-7.2-64-nocm - box_url: https://vagrantcloud.com/puppetlabs/boxes/centos-7.2-64-nocm - hypervisor: vagrant -CONFIG: - log_level: verbose - type: foss \ No newline at end of file diff --git a/spec/classes/coverage_spec.rb b/spec/classes/coverage_spec.rb deleted file mode 100644 index 12513b8..0000000 --- a/spec/classes/coverage_spec.rb +++ /dev/null @@ -1 +0,0 @@ -at_exit { RSpec::Puppet::Coverage.report! } diff --git a/spec/classes/powerdns_init_spec.rb b/spec/classes/powerdns_init_spec.rb index ab80acf..0c3926a 100644 --- a/spec/classes/powerdns_init_spec.rb +++ b/spec/classes/powerdns_init_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + override_facts = { root_home: '/root', service_provider: 'systemd' @@ -52,7 +54,7 @@ context 'powerdns class without parameters' do it { is_expected.to raise_error( - %r{'db_password' must be a non-empty string when 'authoritative' == true}, + %r{'db_password' must be a non-empty string when 'authoritative' == true} ) } end @@ -66,7 +68,7 @@ it { is_expected.to raise_error( - %r{On MySQL 'db_root_password' must be a non-empty string when 'backend_create_tables' == true}, + %r{On MySQL 'db_root_password' must be a non-empty string when 'backend_create_tables' == true} ) } end @@ -106,15 +108,17 @@ # Check the repositories it { is_expected.to contain_class('powerdns::repo') } - case facts[:osfamily] + + case facts[:os]['family'] when 'RedHat' it { is_expected.to contain_yumrepo('powertools') } - if facts[:operatingsystem] != 'Rocky' + + if facts[:os]['name'] != 'Rocky' it { is_expected.to contain_yumrepo('powertools').with('mirrorlist' => 'http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=PowerTools&infra=$infra') } end - if facts[:operatingsystem] == 'Rocky' + if facts[:os]['name'] == 'Rocky' it { is_expected.to contain_yumrepo('powertools').with('mirrorlist' => 'https://mirrors.rockylinux.org/mirrorlist?arch=$basearch&repo=PowerTools-$releasever') } @@ -124,7 +128,7 @@ it { is_expected.to contain_yumrepo('powerdns-recursor') } it { is_expected.to contain_yumrepo('powerdns-recursor').with('baseurl' => 'http://repo.powerdns.com/centos/$basearch/$releasever/rec-49') } end - case facts[:osfamily] + case facts[:os]['family'] when 'Debian' it { is_expected.to contain_apt__key('powerdns') } it { is_expected.to contain_apt__pin('powerdns') } @@ -161,7 +165,7 @@ end end - context 'powerdns class with epel' do + context 'powerdns class with custom_epel=true' do let(:params) do { db_root_password: 'foobar', @@ -173,7 +177,7 @@ it { is_expected.to compile.with_all_deps } - case facts[:osfamily] + case facts[:os]['family'] when 'RedHat' it { is_expected.not_to contain_class('epel') } end @@ -192,7 +196,7 @@ it { is_expected.to compile.with_all_deps } - case facts[:osfamily] + case facts[:os]['family'] when 'RedHat' it { is_expected.to contain_yumrepo('powerdns').with('baseurl' => 'http://repo.powerdns.com/centos/$basearch/$releasever/auth-40') } it { is_expected.to contain_yumrepo('powerdns-recursor').with('baseurl' => 'http://repo.powerdns.com/centos/$basearch/$releasever/rec-40') } @@ -215,11 +219,10 @@ end it { is_expected.to contain_class('powerdns::backends::mysql') } - if facts[:os]['name'] != 'Archlinux' - it { is_expected.to contain_package('pdns-backend-mysql').with('ensure' => 'installed') } - end + + it { is_expected.to contain_package('pdns-backend-mysql').with('ensure' => 'installed') } if facts[:os]['name'] != 'Archlinux' it { is_expected.to contain_mysql__db('powerdns').with('user' => 'foo', 'password' => 'bar', 'host' => '127.0.0.1') } - it { is_expected.to contain_mysql__db('powerdns').with_sql([ mysql_schema_file ]) } + it { is_expected.to contain_mysql__db('powerdns').with_sql([mysql_schema_file]) } # This sets our configuration it { is_expected.to contain_powerdns__config('gmysql-host').with('value' => '127.0.0.1') } @@ -229,12 +232,12 @@ it { is_expected.to contain_powerdns__config('gmysql-port').with('value' => 3307) } it { is_expected.to contain_powerdns__config('launch').with('value' => 'gmysql') } - it { is_expected.to contain_file_line('powerdns-config-gmysql-host-%{config}' % { config: authoritative_config }) } - it { is_expected.to contain_file_line('powerdns-config-gmysql-dbname-%{config}' % { config: authoritative_config }) } - it { is_expected.to contain_file_line('powerdns-config-gmysql-password-%{config}' % { config: authoritative_config }) } - it { is_expected.to contain_file_line('powerdns-config-gmysql-user-%{config}' % { config: authoritative_config }) } - it { is_expected.to contain_file_line('powerdns-config-gmysql-port-%{config}' % { config: authoritative_config }) } - it { is_expected.to contain_file_line('powerdns-config-launch-%{config}' % { config: authoritative_config }) } + it { is_expected.to contain_file_line(format('powerdns-config-gmysql-host-%{config}', config: authoritative_config)) } + it { is_expected.to contain_file_line(format('powerdns-config-gmysql-dbname-%{config}', config: authoritative_config)) } + it { is_expected.to contain_file_line(format('powerdns-config-gmysql-password-%{config}', config: authoritative_config)) } + it { is_expected.to contain_file_line(format('powerdns-config-gmysql-user-%{config}', config: authoritative_config)) } + it { is_expected.to contain_file_line(format('powerdns-config-gmysql-port-%{config}', config: authoritative_config)) } + it { is_expected.to contain_file_line(format('powerdns-config-launch-%{config}', config: authoritative_config)) } end context 'powerdns class with postgresql backend' do @@ -254,9 +257,7 @@ it { is_expected.to contain_package('pdns-backend-bind').with('ensure' => 'purged') } end - if facts[:os]['name'] != 'Archlinux' - it { is_expected.to contain_package(pgsql_backend_package_name).with('ensure' => 'installed') } - end + it { is_expected.to contain_package(pgsql_backend_package_name).with('ensure' => 'installed') } if facts[:os]['name'] != 'Archlinux' it { is_expected.to contain_postgresql__server__db('powerdns').with('user' => 'foo') } it { is_expected.to contain_postgresql_psql('Load SQL schema').with('command' => "\\i #{pgsql_schema_file}") } @@ -281,6 +282,7 @@ end it { is_expected.to contain_class('powerdns::backends::sqlite') } + if facts[:os]['name'] != 'Archlinux' it { is_expected.to contain_package(sqlite_backend_package_name).with('ensure' => 'installed') } it { is_expected.to contain_package(sqlite_binary_package_name).with('ensure' => 'installed') } @@ -290,27 +292,29 @@ 'ensure' => 'file', 'owner' => 'pdns', 'group' => 'pdns', - 'mode' => '0644', + 'mode' => '0644' ) end + it do is_expected.to contain_file('/var/lib/powerdns').with( 'ensure' => 'directory', 'owner' => 'pdns', 'group' => 'pdns', - 'mode' => '0755', + 'mode' => '0755' ) end it do is_expected.to contain_exec('powerdns-sqlite3-create-tables').with( - 'command' => "/usr/bin/env sqlite3 /var/lib/powerdns/db.sqlite3 < #{sqlite_schema_file}", + 'command' => "/usr/bin/env sqlite3 /var/lib/powerdns/db.sqlite3 < #{sqlite_schema_file}" ) end + it { is_expected.to contain_powerdns__config('launch').with('value' => 'gsqlite3') } it { is_expected.to contain_powerdns__config('gsqlite3-database').with('value' => '/var/lib/powerdns/db.sqlite3') } - it { is_expected.to contain_file_line('powerdns-config-gsqlite3-database-%{config}' % { config: authoritative_config }) } + it { is_expected.to contain_file_line(format('powerdns-config-gsqlite3-database-%{config}', config: authoritative_config)) } end context 'powerdns class with bind backend' do @@ -337,8 +341,8 @@ it { is_expected.to contain_powerdns__config('launch').with('value' => 'bind') } - it { is_expected.to contain_file_line('powerdns-config-bind-config-%{config}' % { config: authoritative_config }) } - it { is_expected.to contain_file_line('powerdns-config-launch-%{config}' % { config: authoritative_config }) } + it { is_expected.to contain_file_line(format('powerdns-config-bind-config-%{config}', config: authoritative_config)) } + it { is_expected.to contain_file_line(format('powerdns-config-launch-%{config}', config: authoritative_config)) } it { is_expected.to contain_file_line(format('powerdns-bind-baseconfig')) } end @@ -357,6 +361,7 @@ it { is_expected.to compile.with_all_deps } it { is_expected.to contain_class('powerdns::backends::ldap') } + it { is_expected.to contain_package('pdns-backend-ldap').with('ensure' => 'installed') } if facts[:os]['name'] != 'Archlinux' it { is_expected.to contain_package('pdns-backend-bind').with('ensure' => 'purged') } if facts[:os]['family'] == 'Debian' it { is_expected.to contain_powerdns__config('launch').with('value' => 'ldap') } @@ -366,11 +371,11 @@ it { is_expected.to contain_powerdns__config('ldap-binddn').with('value' => 'foo') } it { is_expected.to contain_powerdns__config('ldap-method').with('value' => 'strict') } - it { is_expected.to contain_file_line('powerdns-config-ldap-host-%{config}' % { config: authoritative_config }) } - it { is_expected.to contain_file_line('powerdns-config-ldap-basedn-%{config}' % { config: authoritative_config }) } - it { is_expected.to contain_file_line('powerdns-config-ldap-secret-%{config}' % { config: authoritative_config }) } - it { is_expected.to contain_file_line('powerdns-config-ldap-binddn-%{config}' % { config: authoritative_config }) } - it { is_expected.to contain_file_line('powerdns-config-ldap-method-%{config}' % { config: authoritative_config }) } + it { is_expected.to contain_file_line(format('powerdns-config-ldap-host-%{config}', config: authoritative_config)) } + it { is_expected.to contain_file_line(format('powerdns-config-ldap-basedn-%{config}', config: authoritative_config)) } + it { is_expected.to contain_file_line(format('powerdns-config-ldap-secret-%{config}', config: authoritative_config)) } + it { is_expected.to contain_file_line(format('powerdns-config-ldap-binddn-%{config}', config: authoritative_config)) } + it { is_expected.to contain_file_line(format('powerdns-config-ldap-method-%{config}', config: authoritative_config)) } end context 'with Sensitive password' do @@ -555,7 +560,7 @@ it { is_expected.to contain_service('pdns-recursor').with('ensure' => 'running') } it { is_expected.to contain_service('pdns-recursor').with('enable' => 'true') } it { is_expected.to contain_service('pdns-recursor').with('name' => recursor_service_name) } - it { is_expected.to contain_service('pdns-recursor').that_requires('Package[%{package}]' % { package: recursor_package_name }) } + it { is_expected.to contain_service('pdns-recursor').that_requires(format('Package[%{package}]', package: recursor_package_name)) } end # Test errors @@ -581,7 +586,7 @@ it { is_expected.to raise_error( - %r{'db_password' must be a non-empty string when 'authoritative' == true}, + %r{'db_password' must be a non-empty string when 'authoritative' == true} ) } end @@ -610,15 +615,16 @@ } end - case facts[:osfamily] + case facts[:os]['family'] when 'RedHat' it { - is_expected.to contain_yumrepo('powerdns') \ - .with('baseurl' => 'http://repo.powerdns.com/centos/$basearch/$releasever/auth-47') + is_expected.to contain_yumrepo('powerdns'). \ + with('baseurl' => 'http://repo.powerdns.com/centos/$basearch/$releasever/auth-47') } + it { - is_expected.to contain_yumrepo('powerdns-recursor') \ - .with('baseurl' => 'http://repo.powerdns.com/centos/$basearch/$releasever/rec-47') + is_expected.to contain_yumrepo('powerdns-recursor'). \ + with('baseurl' => 'http://repo.powerdns.com/centos/$basearch/$releasever/rec-47') } when 'Debian' it { is_expected.to contain_apt__source('powerdns').with_release(%r{auth-47}) } @@ -640,7 +646,7 @@ } end - case facts[:osfamily] + case facts[:os]['family'] when 'RedHat' recursor_dir = '/etc/pdns-recursor' when 'Debian' @@ -652,14 +658,15 @@ # Check the authoritative server it { is_expected.to contain_class('powerdns::recursor') } it { is_expected.to contain_file("#{recursor_dir}/forward_zones.conf").with_ensure('file') } + it { - is_expected.to contain_powerdns__config('forward-zones-file') \ - .with(value: "#{recursor_dir}/forward_zones.conf") + is_expected.to contain_powerdns__config('forward-zones-file'). \ + with(value: "#{recursor_dir}/forward_zones.conf") } it { - is_expected.to contain_file("#{recursor_dir}/forward_zones.conf") \ - .with_content(%r{^example.com=1.1.1.1}) + is_expected.to contain_file("#{recursor_dir}/forward_zones.conf"). \ + with_content(%r{^example.com=1.1.1.1}) } end end diff --git a/spec/default_facts.yml b/spec/default_facts.yml deleted file mode 100644 index 3346c39..0000000 --- a/spec/default_facts.yml +++ /dev/null @@ -1,9 +0,0 @@ -# Use default_module_facts.yml for module specific facts. -# -# Facts specified here will override the values provided by rspec-puppet-facts. ---- -networking: - ip: "172.16.254.254" - ip6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" - mac: "AA:AA:AA:AA:AA:AA" -is_pe: false diff --git a/spec/defines/powerdns_config_spec.rb b/spec/defines/powerdns_config_spec.rb index 0f69d1e..ca4f5dd 100644 --- a/spec/defines/powerdns_config_spec.rb +++ b/spec/defines/powerdns_config_spec.rb @@ -43,13 +43,13 @@ } end - it { is_expected.to contain_file_line('powerdns-config-foo-%{config}' % { config: authoritative_config }) } - it { is_expected.to contain_file_line('powerdns-config-foo-%{config}' % { config: authoritative_config }).with_ensure('present') } - it { is_expected.to contain_file_line('powerdns-config-foo-%{config}' % { config: authoritative_config }).with_path(authoritative_config) } - it { is_expected.to contain_file_line('powerdns-config-foo-%{config}' % { config: authoritative_config }).with_line('foo=bar') } - it { is_expected.to contain_file_line('powerdns-config-foo-%{config}' % { config: authoritative_config }).with_match('^foo=') } - it { is_expected.to contain_file_line('powerdns-config-foo-%{config}' % { config: authoritative_config }).with_match_for_absence(true) } - it { is_expected.to contain_file_line('powerdns-config-foo-%{config}' % { config: authoritative_config }).that_notifies('Service[pdns]') } + it { is_expected.to contain_file_line(format('powerdns-config-foo-%{config}', config: authoritative_config)) } + it { is_expected.to contain_file_line(format('powerdns-config-foo-%{config}', config: authoritative_config)).with_ensure('present') } + it { is_expected.to contain_file_line(format('powerdns-config-foo-%{config}', config: authoritative_config)).with_path(authoritative_config) } + it { is_expected.to contain_file_line(format('powerdns-config-foo-%{config}', config: authoritative_config)).with_line('foo=bar') } + it { is_expected.to contain_file_line(format('powerdns-config-foo-%{config}', config: authoritative_config)).with_match('^foo=') } + it { is_expected.to contain_file_line(format('powerdns-config-foo-%{config}', config: authoritative_config)).with_match_for_absence(true) } + it { is_expected.to contain_file_line(format('powerdns-config-foo-%{config}', config: authoritative_config)).that_notifies('Service[pdns]') } end context 'powerdns::config with recursor type' do @@ -61,7 +61,7 @@ } end - it { is_expected.to contain_file_line('powerdns-config-foo-%{config}' % { config: recursor_config }) } + it { is_expected.to contain_file_line(format('powerdns-config-foo-%{config}', config: recursor_config)) } end context 'powerdns::config with integers' do @@ -72,7 +72,7 @@ } end - it { is_expected.to contain_file_line('powerdns-config-local-port-%{config}' % { config: authoritative_config }) } + it { is_expected.to contain_file_line(format('powerdns-config-local-port-%{config}', config: authoritative_config)) } end # Test for empty values @@ -83,7 +83,7 @@ } end - it { is_expected.to contain_file_line('powerdns-config-gmysql-dnssec-%{config}' % { config: authoritative_config }) } + it { is_expected.to contain_file_line(format('powerdns-config-gmysql-dnssec-%{config}', config: authoritative_config)) } end context 'powerdns::config with empty value for only-notify' do @@ -93,7 +93,7 @@ } end - it { is_expected.to contain_file_line('powerdns-config-only-notify-%{config}' % { config: authoritative_config }) } + it { is_expected.to contain_file_line(format('powerdns-config-only-notify-%{config}', config: authoritative_config)) } end context 'powerdns::config with empty value' do @@ -116,7 +116,7 @@ } end - it { is_expected.to contain_file_line('powerdns-config-foo-%{config}' % { config: authoritative_config }) } + it { is_expected.to contain_file_line(format('powerdns-config-foo-%{config}', config: authoritative_config)) } end # Test incorrect service type @@ -131,7 +131,7 @@ it { is_expected.to raise_error( - %r{expects a match for Enum\['authoritative', 'recursor'\], got}, + %r{expects a match for Enum\['authoritative', 'recursor'\], got} ) } end @@ -146,7 +146,7 @@ end it { - is_expected.to contain_file_line('powerdns-config-webserver-%{config}' % { config: recursor_config }).with_line('webserver=true') + is_expected.to contain_file_line(format('powerdns-config-webserver-%{config}', config: recursor_config)).with_line('webserver=true') } end @@ -160,7 +160,7 @@ end it { - is_expected.to contain_file_line('powerdns-config-webserver-password-%{config}' % { config: recursor_config }).with_line('webserver-password=S3cr3t') + is_expected.to contain_file_line(format('powerdns-config-webserver-password-%{config}', config: recursor_config)).with_line('webserver-password=S3cr3t') } end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6820ceb..58c9b66 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,74 +1,24 @@ # 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 +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -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), permitted_classes: [], permitted_symbols: [], aliases: true)) - rescue StandardError => e - RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" - end -end +# puppetlabs_spec_helper will set up coverage if the env variable is set. +# We want to do this if lib exists and it hasn't been explicitly set. +ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../lib', __dir__)) -# read default_facts and merge them over what is provided by facterdb -default_facts.each do |fact, value| - add_custom_fact fact, value -end +require 'voxpupuli/test/spec_helper' RSpec.configure do |c| - c.default_facts = default_facts - c.before :each do - # set to strictest setting for testing - # by default Puppet runs at warning level - Puppet.settings[:strict] = :warning - Puppet.settings[:strict_variables] = true - end - c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] - c.after(:suite) do - RSpec::Puppet::Coverage.report!(0) - end - - # Filter backtrace noise - backtrace_exclusion_patterns = [ - %r{spec_helper}, - %r{gems}, - ] - - if c.respond_to?(:backtrace_exclusion_patterns) - c.backtrace_exclusion_patterns = backtrace_exclusion_patterns - elsif c.respond_to?(:backtrace_clean_patterns) - c.backtrace_clean_patterns = backtrace_exclusion_patterns - end + c.facterdb_string_keys = false 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) +add_mocked_facts! + +if File.exist?(File.join(__dir__, 'default_module_facts.yml')) + facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml'))) + facts&.each do |name, value| + add_custom_fact name.to_sym, value end end - -# 'spec_overrides' from sync.yml will appear below this line +Dir['./spec/support/spec/**/*.rb'].sort.each { |f| require f } diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 717ed0b..b79530e 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,44 +1,6 @@ -require 'beaker-rspec/spec_helper' -require 'beaker-rspec/helpers/serverspec' -require 'beaker/puppet_install_helper' +# frozen_string_literal: true -RSpec.configure do |c| - # Project root - proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) - fixture_modules = File.join(proj_root, 'spec', 'fixtures', 'modules') +# This file is completely based on voxpupuli/modulesync_config +require 'voxpupuli/acceptance/spec_helper_acceptance' - # Readable test descriptions - c.formatter = :documentation - - # Configure all nodes in nodeset - c.before :suite do - hosts.each do |host| - run_puppet_install_helper unless ENV.fetch('BEAKER_provision') == 'no' - - # Install rsync - install_package(host, 'rsync') - - # A workaround -- this is required for backwards compatibility - on host, 'mkdir -p /etc/puppet/modules/' - on host, 'mkdir -p /etc/puppetlabs/code/' - on host, 'rm -rf /etc/puppetlabs/code/modules' - on host, 'ln -s /etc/puppet/modules/ /etc/puppetlabs/code/' - - # A workaround for systemd-resolved on Ubuntu 18.04. Thanks, systemd. - if host['platform'] == 'ubuntu-1804-amd64' - on host, 'systemctl stop systemd-resolved' - on host, 'echo "nameserver 1.1.1.1" > /etc/resolv.conf' - end - - # Sorry, it's a symlink, PATH doesn't work - on host, 'ln -s /opt/puppetlabs/bin/puppet /usr/bin/puppet' - on host, 'puppet --version' - - # Synchronise modules - rsync_to(host, fixture_modules, '/etc/puppet/modules/') - end - - # Install module and dependencies - puppet_module_install(source: proj_root, module_name: 'powerdns') - end -end +configure_beaker diff --git a/spec/type_aliases/autoprimaries_spec.rb b/spec/type_aliases/autoprimaries_spec.rb index 1e6f792..6e0bdd7 100644 --- a/spec/type_aliases/autoprimaries_spec.rb +++ b/spec/type_aliases/autoprimaries_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'Powerdns::Autoprimaries' do diff --git a/spec/unit/puppet/provider/powerdns_autoprimary/pdnsutil_spec.rb b/spec/unit/puppet/provider/powerdns_autoprimary/pdnsutil_spec.rb index 266f24c..7a249ad 100644 --- a/spec/unit/puppet/provider/powerdns_autoprimary/pdnsutil_spec.rb +++ b/spec/unit/puppet/provider/powerdns_autoprimary/pdnsutil_spec.rb @@ -8,7 +8,7 @@ let(:resource) do Puppet::Type::Powerdns_autoprimary.new( name: '1.2.3.4@ns1.example.com', - provider: described_class.name, + provider: described_class.name ) end diff --git a/spec/unit/puppet/provider/powerdns_zone_private/pdnsutil_spec.rb b/spec/unit/puppet/provider/powerdns_zone_private/pdnsutil_spec.rb index 545e7fc..9410660 100644 --- a/spec/unit/puppet/provider/powerdns_zone_private/pdnsutil_spec.rb +++ b/spec/unit/puppet/provider/powerdns_zone_private/pdnsutil_spec.rb @@ -8,7 +8,7 @@ let(:resource) do Puppet::Type::Powerdns_zone_private.new( name: 'example.com', - provider: described_class.name, + provider: described_class.name ) end diff --git a/spec/unit/puppet/type/powerdns_autoprimary_spec.rb b/spec/unit/puppet/type/powerdns_autoprimary_spec.rb index 110f87b..a7289f3 100644 --- a/spec/unit/puppet/type/powerdns_autoprimary_spec.rb +++ b/spec/unit/puppet/type/powerdns_autoprimary_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'puppet' require 'puppet/type/powerdns_autoprimary' @@ -7,6 +9,7 @@ it 'has its name set' do expect(autoprimary[:name]).to eq('1.2.3.4@ns1.example.com') end + it 'has set account to empty string' do expect(autoprimary[:account]).to eq('') end diff --git a/spec/unit/puppet/type/powerdns_record_spec.rb b/spec/unit/puppet/type/powerdns_record_spec.rb index f816fa6..2b4149f 100644 --- a/spec/unit/puppet/type/powerdns_record_spec.rb +++ b/spec/unit/puppet/type/powerdns_record_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'puppet' require 'puppet/type/powerdns_record' @@ -7,9 +9,11 @@ it 'has its name set' do expect(dns_record[:name]).to eq('www.example.com') end + it 'has set target zone' do expect(dns_record[:target_zone]).to eq('example.com') end + it 'has set rname' do expect(dns_record[:rname]).to eq('www') end diff --git a/spec/unit/puppet/type/powerdns_zone_private_spec.rb b/spec/unit/puppet/type/powerdns_zone_private_spec.rb index 88c7639..37df417 100644 --- a/spec/unit/puppet/type/powerdns_zone_private_spec.rb +++ b/spec/unit/puppet/type/powerdns_zone_private_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'puppet' require 'puppet/type/powerdns_zone_private' @@ -7,9 +9,11 @@ it 'has its name set' do expect(zone[:name]).to eq('example.com') end + it 'has set config_dir to empty string' do expect(zone[:config_dir]).to eq('') end + it 'has set config_name to empty string' do expect(zone[:config_name]).to eq('') end diff --git a/spec/unit/puppet/type/powerdns_zone_spec.rb b/spec/unit/puppet/type/powerdns_zone_spec.rb index 9fda21e..b24a545 100644 --- a/spec/unit/puppet/type/powerdns_zone_spec.rb +++ b/spec/unit/puppet/type/powerdns_zone_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'puppet' require 'puppet/type/powerdns_zone' @@ -7,9 +9,11 @@ it 'has its name set' do expect(zone[:name]).to eq('example.com') end + it 'has set config_dir to empty string' do expect(zone[:config_dir]).to eq('') end + it 'has set config_name to empty string' do expect(zone[:config_name]).to eq('') end