diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..12ed4ff --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,6 @@ +FROM puppet/pdk:latest + +# [Optional] Uncomment this section to install additional packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 0000000..a719361 --- /dev/null +++ b/.devcontainer/README.md @@ -0,0 +1,38 @@ +# 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 new file mode 100644 index 0000000..fe7a8b1 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,17 @@ +{ + "name": "Puppet Development Kit (Community)", + "dockerFile": "Dockerfile", + + "settings": { + "terminal.integrated.profiles.linux": { + "bash": { + "path": "bash", + } + } + }, + + "extensions": [ + "puppet.puppet-vscode", + "rebornix.Ruby" + ] +} diff --git a/.fixtures-latest.yml b/.fixtures-latest.yml index e46dc43..1a807b4 100644 --- a/.fixtures-latest.yml +++ b/.fixtures-latest.yml @@ -2,23 +2,22 @@ # See https://github.com/puppetlabs/puppetlabs_spec_helper#using-fixtures for details --- fixtures: - repositories: + forge_modules: stdlib: - repo: https://github.com/puppetlabs/puppetlabs-stdlib.git + repo: puppetlabs/stdlib postgresql: - repo: https://github.com/puppetlabs/puppetlabs-postgresql.git + repo: puppetlabs/postgresql # Needed by Postgresql module apt: - repo: https://github.com/puppetlabs/puppetlabs-apt.git + repo: puppetlabs/apt python: - repo: https://github.com/voxpupuli/puppet-python.git + repo: puppet/python # Needed by Python module epel: - repo: https://github.com/voxpupuli/puppet-epel.git + repo: puppet/epel systemd: - repo: https://github.com/camptocamp/puppet-systemd.git + repo: puppet/systemd yumrepo_core: - repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core - puppet_version: ">= 6.0.0" + repo: puppetlabs/yumrepo_core symlinks: patroni: "#{source_dir}" diff --git a/.fixtures.yml b/.fixtures.yml index 41a7238..2373b43 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -2,30 +2,29 @@ # See https://github.com/puppetlabs/puppetlabs_spec_helper#using-fixtures for details --- fixtures: - repositories: + forge_modules: stdlib: - repo: https://github.com/puppetlabs/puppetlabs-stdlib.git - ref: v6.0.0 + repo: puppetlabs/stdlib + ref: '9.4.1' postgresql: - repo: https://github.com/puppetlabs/puppetlabs-postgresql.git - ref: v6.4.0 + repo: puppetlabs/postgresql + ref: '10.0.2' # Needed by Postgresql module apt: - repo: https://github.com/puppetlabs/puppetlabs-apt.git - ref: v7.5.0 + repo: puppetlabs/apt + ref: '9.1.0' python: - repo: https://github.com/voxpupuli/puppet-python.git - ref: v4.1.0 + repo: puppet/python + ref: '7.0.0' # Needed by Python module epel: - repo: https://github.com/voxpupuli/puppet-epel.git - ref: v3.0.0 + repo: puppet/epel + ref: '5.0.0' systemd: - repo: https://github.com/camptocamp/puppet-systemd.git - ref: 2.0.0 + repo: puppet/systemd + ref: '6.1.0' yumrepo_core: - repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core - ref: 1.0.1 - puppet_version: ">= 6.0.0" + repo: puppetlabs/yumrepo_core + ref: '2.0.0' symlinks: patroni: "#{source_dir}" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b93ccf7..3ad9440 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,39 +15,35 @@ jobs: fail-fast: false matrix: include: - - ruby: 2.5.7 - puppet: 6 - fixtures: .fixtures.yml - allow_failure: false - - ruby: 2.7.0 + - ruby: 2.7.8 puppet: 7 fixtures: .fixtures.yml allow_failure: false - - ruby: 2.4.9 - puppet: 5 - fixtures: .fixtures.yml - allow_failure: false - - ruby: 2.5.7 - puppet: 6 + - ruby: 2.7.8 + puppet: 7 fixtures: .fixtures-latest.yml allow_failure: true - - ruby: 2.7.0 - puppet: 7 + - ruby: 3.2.2 + puppet: 8 + fixtures: .fixtures.yml + allow_failure: false + - ruby: 3.2.2 + puppet: 8 fixtures: .fixtures-latest.yml allow_failure: true env: BUNDLE_WITHOUT: system_tests:release PUPPET_GEM_VERSION: "~> ${{ matrix.puppet }}.0" - FACTER_GEM_VERSION: "< 4.0" FIXTURES_YML: ${{ matrix.fixtures }} name: Puppet ${{ matrix.puppet }} (Ruby ${{ matrix.ruby }} fixtures=${{ matrix.fixtures }}) steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} bundler-cache: true + cache-version: 2 bundler: '2.1.0' - name: Validate run: bundle exec rake check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint @@ -59,14 +55,14 @@ jobs: fail-fast: false matrix: set: - - "centos-7" - - "rocky-8" - - "debian-9" - - "debian-10" - - "ubuntu-1804" + - "el8" + - "el9" + - "debian-11" + - "ubuntu-2004" + - "ubuntu-2204" puppet: - - "puppet6" - "puppet7" + - "puppet8" env: BUNDLE_WITHOUT: development:release BEAKER_debug: true @@ -83,12 +79,13 @@ jobs: sudo apt-get remove mysql-server --purge sudo apt-get install apparmor-profiles sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup ruby uses: ruby/setup-ruby@v1 with: ruby-version: '2.7' bundler-cache: true + cache-version: 2 bundler: '2.1.0' - name: Run tests run: bundle exec rake beaker diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 1e8347b..da72f01 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -14,12 +14,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Ruby uses: ruby/setup-ruby@v1 with: ruby-version: '2.7' bundler-cache: true + cache-version: 2 bundler: '2.1.0' - name: Build and Deploy env: diff --git a/.gitignore b/.gitignore index 2767022..988dcbb 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ .project .envrc /inventory.yaml +/spec/fixtures/litmus_inventory.yaml diff --git a/.pdkignore b/.pdkignore index e6215cd..fcf8a0e 100644 --- a/.pdkignore +++ b/.pdkignore @@ -25,6 +25,7 @@ .project .envrc /inventory.yaml +/spec/fixtures/litmus_inventory.yaml /appveyor.yml /.fixtures.yml /Gemfile @@ -40,3 +41,5 @@ /.yardopts /spec/ /.vscode/ +/.sync.yml +/.devcontainer/ diff --git a/.puppet-lint.rc b/.puppet-lint.rc index 53fcb9a..75071c7 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1,2 +1,5 @@ +--no-80chars-check +--no-140chars-check +--no-manifest_whitespace_opening_brace_after-check --relative --fail_on_warnings diff --git a/.rubocop.yml b/.rubocop.yml index 5307849..bb2b4a9 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,12 +1,12 @@ --- require: +- rubocop-performance - rubocop-rspec -- rubocop-i18n AllCops: DisplayCopNames: true - TargetRubyVersion: '2.1' + TargetRubyVersion: '2.5' Include: - - "./**/*.rb" + - "**/*.rb" Exclude: - bin/* - ".vendor/**/*" @@ -18,16 +18,9 @@ AllCops: - "**/Puppetfile" - "**/Vagrantfile" - "**/Guardfile" -Metrics/LineLength: +Layout/LineLength: Description: People have wide screens, use them. Max: 200 -GetText: - Enabled: false -GetText/DecorateString: - Description: We don't want to decorate test output. - Exclude: - - spec/**/* - Enabled: false RSpec/BeforeAfterAll: Description: Beware of using after(:all) as it may cause state to leak between tests. A necessary evil in acceptance testing. @@ -36,14 +29,13 @@ RSpec/BeforeAfterAll: RSpec/HookArgument: Description: Prefer explicit :each argument, matching existing module's style EnforcedStyle: each +RSpec/DescribeSymbol: + Exclude: + - spec/unit/facter/**/*.rb Style/BlockDelimiters: Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to be consistent then. EnforcedStyle: braces_for_chaining -Style/BracesAroundHashParameters: - Description: Braces are required by Ruby 2.7. Cop removed from RuboCop v0.80.0. - See https://github.com/rubocop-hq/rubocop/pull/7643 - Enabled: true Style/ClassAndModuleChildren: Description: Compact style reduces the required amount of indentation. EnforcedStyle: compact @@ -72,41 +64,193 @@ Style/TrailingCommaInArguments: Description: Prefer always trailing comma on multiline argument lists. This makes diffs, and re-ordering nicer. EnforcedStyleForMultiline: comma -Style/TrailingCommaInLiteral: +Style/TrailingCommaInArrayLiteral: Description: Prefer always trailing comma on multiline literals. This makes diffs, and re-ordering nicer. EnforcedStyleForMultiline: comma Style/SymbolArray: Description: Using percent style obscures symbolic intent of array's contents. EnforcedStyle: brackets +Layout/FirstHashElementIndentation: + Enabled: false +Performance/RegexpMatch: + Enabled: false RSpec/MessageSpies: EnforcedStyle: receive +RSpec/NamedSubject: + Enabled: false Style/Documentation: Exclude: - lib/puppet/parser/functions/**/* - spec/**/* +Style/HashEachMethods: + Enabled: false Style/WordArray: EnforcedStyle: brackets +Performance/AncestorsInclude: + Enabled: true +Performance/BigDecimalWithNumericArgument: + Enabled: true +Performance/BlockGivenWithExplicitBlock: + Enabled: true +Performance/CaseWhenSplat: + Enabled: true +Performance/ConstantRegexp: + Enabled: true +Performance/MethodObjectAsBlock: + Enabled: true +Performance/RedundantSortBlock: + Enabled: true +Performance/RedundantStringChars: + Enabled: true +Performance/ReverseFirst: + Enabled: true +Performance/SortReverse: + Enabled: true +Performance/Squeeze: + Enabled: true +Performance/StringInclude: + Enabled: true +Performance/Sum: + Enabled: true Style/CollectionMethods: Enabled: true Style/MethodCalledOnDoEndBlock: Enabled: true Style/StringMethods: Enabled: true -GetText/DecorateFunctionMessage: +Bundler/InsecureProtocolSource: + Enabled: false +Gemspec/DuplicatedAssignment: + Enabled: false +Gemspec/OrderedDependencies: + Enabled: false +Gemspec/RequiredRubyVersion: Enabled: false -GetText/DecorateStringFormattingUsingInterpolation: +Gemspec/RubyVersionGlobalsUsage: Enabled: false -GetText/DecorateStringFormattingUsingPercent: +Layout/ArgumentAlignment: + Enabled: false +Layout/BeginEndAlignment: + Enabled: false +Layout/ClosingHeredocIndentation: + Enabled: false +Layout/EmptyComment: + Enabled: false +Layout/EmptyLineAfterGuardClause: + Enabled: false +Layout/EmptyLinesAroundArguments: + Enabled: false +Layout/EmptyLinesAroundAttributeAccessor: Enabled: false Layout/EndOfLine: Enabled: false -Layout/IndentHeredoc: +Layout/FirstArgumentIndentation: + Enabled: false +Layout/HashAlignment: + Enabled: false +Layout/HeredocIndentation: + Enabled: false +Layout/LeadingEmptyLines: + Enabled: false +Layout/SpaceAroundMethodCallOperator: + Enabled: false +Layout/SpaceInsideArrayLiteralBrackets: + Enabled: false +Layout/SpaceInsideReferenceBrackets: + Enabled: false +Lint/BigDecimalNew: + Enabled: false +Lint/BooleanSymbol: + Enabled: false +Lint/ConstantDefinitionInBlock: + Enabled: false +Lint/DeprecatedOpenSSLConstant: + Enabled: false +Lint/DisjunctiveAssignmentInConstructor: + Enabled: false +Lint/DuplicateElsifCondition: + Enabled: false +Lint/DuplicateRequire: + Enabled: false +Lint/DuplicateRescueException: + Enabled: false +Lint/EmptyConditionalBody: + Enabled: false +Lint/EmptyFile: + Enabled: false +Lint/ErbNewArguments: + Enabled: false +Lint/FloatComparison: + Enabled: false +Lint/HashCompareByIdentity: + Enabled: false +Lint/IdentityComparison: + Enabled: false +Lint/InterpolationCheck: + Enabled: false +Lint/MissingCopEnableDirective: + Enabled: false +Lint/MixedRegexpCaptureTypes: + Enabled: false +Lint/NestedPercentLiteral: + Enabled: false +Lint/NonDeterministicRequireOrder: + Enabled: false +Lint/OrderedMagicComments: + Enabled: false +Lint/OutOfRangeRegexpRef: + Enabled: false +Lint/RaiseException: + Enabled: false +Lint/RedundantCopEnableDirective: + Enabled: false +Lint/RedundantRequireStatement: + Enabled: false +Lint/RedundantSafeNavigation: + Enabled: false +Lint/RedundantWithIndex: + Enabled: false +Lint/RedundantWithObject: + Enabled: false +Lint/RegexpAsCondition: + Enabled: false +Lint/ReturnInVoidContext: + Enabled: false +Lint/SafeNavigationConsistency: + Enabled: false +Lint/SafeNavigationWithEmpty: + Enabled: false +Lint/SelfAssignment: + Enabled: false +Lint/SendWithMixinArgument: + Enabled: false +Lint/ShadowedArgument: + Enabled: false +Lint/StructNewOverride: + Enabled: false +Lint/ToJSON: + Enabled: false +Lint/TopLevelReturnWithArgument: + Enabled: false +Lint/TrailingCommaInAttributeDeclaration: + Enabled: false +Lint/UnreachableLoop: + Enabled: false +Lint/UriEscapeUnescape: + Enabled: false +Lint/UriRegexp: + Enabled: false +Lint/UselessMethodDefinition: + Enabled: false +Lint/UselessTimes: Enabled: false Metrics/AbcSize: Enabled: false Metrics/BlockLength: Enabled: false +Metrics/BlockNesting: + Enabled: false Metrics/ClassLength: Enabled: false Metrics/CyclomaticComplexity: @@ -119,19 +263,265 @@ Metrics/ParameterLists: Enabled: false Metrics/PerceivedComplexity: Enabled: false +Migration/DepartmentName: + Enabled: false +Naming/AccessorMethodName: + Enabled: false +Naming/BlockParameterName: + Enabled: false +Naming/HeredocDelimiterCase: + Enabled: false +Naming/HeredocDelimiterNaming: + Enabled: false +Naming/MemoizedInstanceVariableName: + Enabled: false +Naming/MethodParameterName: + Enabled: false +Naming/RescuedExceptionsVariableName: + Enabled: false +Naming/VariableNumber: + Enabled: false +Performance/BindCall: + Enabled: false +Performance/DeletePrefix: + Enabled: false +Performance/DeleteSuffix: + Enabled: false +Performance/InefficientHashSearch: + Enabled: false +Performance/UnfreezeString: + Enabled: false +Performance/UriDefaultParser: + Enabled: false +RSpec/Be: + Enabled: false +RSpec/Capybara/CurrentPathExpectation: + Enabled: false +RSpec/Capybara/FeatureMethods: + Enabled: false +RSpec/Capybara/VisibilityMatcher: + Enabled: false +RSpec/ContextMethod: + Enabled: false +RSpec/ContextWording: + Enabled: false RSpec/DescribeClass: Enabled: false +RSpec/EmptyHook: + Enabled: false +RSpec/EmptyLineAfterExample: + Enabled: false +RSpec/EmptyLineAfterExampleGroup: + Enabled: false +RSpec/EmptyLineAfterHook: + Enabled: false RSpec/ExampleLength: Enabled: false -RSpec/MessageExpectation: +RSpec/ExampleWithoutDescription: + Enabled: false +RSpec/ExpectChange: + Enabled: false +RSpec/ExpectInHook: + Enabled: false +RSpec/FactoryBot/AttributeDefinedStatically: + Enabled: false +RSpec/FactoryBot/CreateList: + Enabled: false +RSpec/FactoryBot/FactoryClassName: + Enabled: false +RSpec/HooksBeforeExamples: + Enabled: false +RSpec/ImplicitBlockExpectation: + Enabled: false +RSpec/ImplicitSubject: + Enabled: false +RSpec/LeakyConstantDeclaration: + Enabled: false +RSpec/LetBeforeExamples: + Enabled: false +RSpec/MissingExampleGroupArgument: Enabled: false RSpec/MultipleExpectations: Enabled: false +RSpec/MultipleMemoizedHelpers: + Enabled: false +RSpec/MultipleSubjects: + Enabled: false RSpec/NestedGroups: Enabled: false +RSpec/PredicateMatcher: + Enabled: false +RSpec/ReceiveCounts: + Enabled: false +RSpec/ReceiveNever: + Enabled: false +RSpec/RepeatedExampleGroupBody: + Enabled: false +RSpec/RepeatedExampleGroupDescription: + Enabled: false +RSpec/RepeatedIncludeExample: + Enabled: false +RSpec/ReturnFromStub: + Enabled: false +RSpec/SharedExamples: + Enabled: false +RSpec/StubbedMock: + Enabled: false +RSpec/UnspecifiedException: + Enabled: false +RSpec/VariableDefinition: + Enabled: false +RSpec/VoidExpect: + Enabled: false +RSpec/Yield: + Enabled: false +Security/Open: + Enabled: false +Style/AccessModifierDeclarations: + Enabled: false +Style/AccessorGrouping: + Enabled: false Style/AsciiComments: Enabled: false +Style/BisectedAttrAccessor: + Enabled: false +Style/CaseLikeIf: + Enabled: false +Style/ClassEqualityComparison: + Enabled: false +Style/ColonMethodDefinition: + Enabled: false +Style/CombinableLoops: + Enabled: false +Style/CommentedKeyword: + Enabled: false +Style/Dir: + Enabled: false +Style/DoubleCopDisableDirective: + Enabled: false +Style/EmptyBlockParameter: + Enabled: false +Style/EmptyLambdaParameter: + Enabled: false +Style/Encoding: + Enabled: false +Style/EvalWithLocation: + Enabled: false +Style/ExpandPathArguments: + Enabled: false +Style/ExplicitBlockArgument: + Enabled: false +Style/ExponentialNotation: + Enabled: false +Style/FloatDivision: + Enabled: false +Style/FrozenStringLiteralComment: + Enabled: false +Style/GlobalStdStream: + Enabled: false +Style/HashAsLastArrayItem: + Enabled: false +Style/HashLikeCase: + Enabled: false +Style/HashTransformKeys: + Enabled: false +Style/HashTransformValues: + Enabled: false Style/IfUnlessModifier: Enabled: false +Style/KeywordParametersOrder: + Enabled: false +Style/MinMax: + Enabled: false +Style/MixinUsage: + Enabled: false +Style/MultilineWhenThen: + Enabled: false +Style/NegatedUnless: + Enabled: false +Style/NumericPredicate: + Enabled: false +Style/OptionalBooleanParameter: + Enabled: false +Style/OrAssignment: + Enabled: false +Style/RandomWithOffset: + Enabled: false +Style/RedundantAssignment: + Enabled: false +Style/RedundantCondition: + Enabled: false +Style/RedundantConditional: + Enabled: false +Style/RedundantFetchBlock: + Enabled: false +Style/RedundantFileExtensionInRequire: + Enabled: false +Style/RedundantRegexpCharacterClass: + Enabled: false +Style/RedundantRegexpEscape: + Enabled: false +Style/RedundantSelfAssignment: + Enabled: false +Style/RedundantSort: + Enabled: false +Style/RescueStandardError: + Enabled: false +Style/SingleArgumentDig: + Enabled: false +Style/SlicingWithRange: + Enabled: false +Style/SoleNestedConditional: + Enabled: false +Style/StderrPuts: + Enabled: false +Style/StringConcatenation: + Enabled: false +Style/Strip: + Enabled: false Style/SymbolProc: Enabled: false +Style/TrailingBodyOnClass: + Enabled: false +Style/TrailingBodyOnMethodDefinition: + Enabled: false +Style/TrailingBodyOnModule: + Enabled: false +Style/TrailingCommaInHashLiteral: + Enabled: false +Style/TrailingMethodEndStatement: + Enabled: false +Style/UnpackFirst: + Enabled: false +Lint/DuplicateBranch: + Enabled: false +Lint/DuplicateRegexpCharacterClassElement: + Enabled: false +Lint/EmptyBlock: + Enabled: false +Lint/EmptyClass: + Enabled: false +Lint/NoReturnInBeginEndBlocks: + Enabled: false +Lint/ToEnumArguments: + Enabled: false +Lint/UnexpectedBlockArity: + Enabled: false +Lint/UnmodifiedReduceAccumulator: + Enabled: false +Performance/CollectionLiteralInLoop: + Enabled: false +Style/ArgumentsForwarding: + Enabled: false +Style/CollectionCompact: + Enabled: false +Style/DocumentDynamicEvalDefinition: + Enabled: false +Style/NegatedIfElseCondition: + Enabled: false +Style/NilLambda: + Enabled: false +Style/RedundantArgument: + Enabled: false +Style/SwapValues: + Enabled: false diff --git a/.sync.yml b/.sync.yml index 852163e..b3ec10c 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,28 +1,14 @@ .github/workflows/ci.yaml: - unit_name: Puppet ${{ matrix.puppet }} (Ruby ${{ matrix.ruby }} fixtures=${{ matrix.fixtures }}) - unit_includes: - - ruby: '2.4.9' - puppet: '5' - fixtures: .fixtures.yml - allow_failure: false - - ruby: '2.5.7' - puppet: '6' - fixtures: .fixtures-latest.yml - allow_failure: true - - ruby: '2.7.0' - puppet: '7' - fixtures: .fixtures-latest.yml - allow_failure: true acceptance_matrix: set: - - centos-7 - - rocky-8 - - debian-9 - - debian-10 - - ubuntu-1804 + - el8 + - el9 + - debian-11 + - ubuntu-2004 + - ubuntu-2204 puppet: - - puppet6 - puppet7 + - puppet8 .travis.yml: delete: true .gitlab-ci.yml: @@ -38,17 +24,13 @@ Rakefile: spec/spec_helper.rb: coverage_report: true minimum_code_coverage_percentage: 100 -spec/acceptance/nodesets/centos-7.yml: +spec/acceptance/nodesets/el8.yml: unmanaged: true -spec/acceptance/nodesets/rocky-8.yml: +spec/acceptance/nodesets/el9.yml: unmanaged: true -spec/acceptance/nodesets/ubuntu-1604.yml: - delete: true -spec/acceptance/nodesets/ubuntu-1804.yml: +spec/acceptance/nodesets/ubuntu-2004.yml: unmanaged: true -spec/acceptance/nodesets/debian-8.yml: - delete: true -spec/acceptance/nodesets/debian-9.yml: +spec/acceptance/nodesets/ubuntu-2204.yml: unmanaged: true -spec/acceptance/nodesets/debian-10.yml: +spec/acceptance/nodesets/debian-11.yml: unmanaged: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d7f1765..5e35566 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,4 +3,4 @@ 1. Update metadata.json version, eg: `pdk bundle exec rake module:bump:{major,minor,patch}` 1. Run release task, eg: `pdk bundle exec rake release` 1. Update GitHub pages, eg: `pdk bundle exec rake strings:gh_pages:update` -1. Push to GitHub: `git push --tags origin master` +1. Push to GitHub: `git push --tags origin main` diff --git a/Gemfile b/Gemfile index b8186f7..a7fdc62 100644 --- a/Gemfile +++ b/Gemfile @@ -17,32 +17,24 @@ ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments minor_version = ruby_version_segments[0..1].join('.') group :development do - gem "facter", '< 4.0', require: false - gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') - gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') - gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') - gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') - gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-posix-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby] - gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby] - gem "puppet-module-win-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-win-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-lint-param-docs", require: false - gem "github_changelog_generator", require: false, git: 'https://github.com/skywinder/github-changelog-generator', ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018' if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2') - gem "coveralls", require: false + gem "voxpupuli-test", '6.0.0', require: false + gem "rubocop-performance", '~> 1.18', require: false + gem "faraday", '~> 1.0', require: false + gem "github_changelog_generator", require: false + gem "puppet-blacksmith", require: false + gem "puppet-strings", require: false + gem "coveralls", require: false end group :system_tests do - gem "puppet-module-posix-system-r#{minor_version}", '~> 0.5', require: false, platforms: [:ruby] - gem "puppet-module-win-system-r#{minor_version}", '~> 0.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 4.0') + gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 4.29') gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1') gem "beaker-pe", require: false gem "beaker-hostgenerator" gem "beaker-rspec" gem "beaker-docker" gem "beaker-puppet" + gem "beaker-puppet_install_helper", require: false + gem "beaker-module_install_helper", require: false end puppet_version = ENV['PUPPET_GEM_VERSION'] @@ -61,16 +53,6 @@ gems['puppet'] = location_for(puppet_version) gems['facter'] = location_for(facter_version) if facter_version gems['hiera'] = location_for(hiera_version) if hiera_version -if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)} - # If we're using a Puppet gem on Windows which handles its own win32-xxx gem - # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445). - gems['win32-dir'] = ['<= 0.4.9', require: false] - gems['win32-eventlog'] = ['<= 0.6.5', require: false] - gems['win32-process'] = ['<= 0.7.5', require: false] - gems['win32-security'] = ['<= 0.2.5', require: false] - gems['win32-service'] = ['0.8.8', require: false] -end - gems.each do |gem_name, gem_params| gem gem_name, *gem_params end diff --git a/Rakefile b/Rakefile index 1505b25..a010b3a 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,7 @@ # frozen_string_literal: true -require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? +require 'bundler' +require 'beaker-rspec/rake_task' if Bundler.rubygems.find_name('beaker-rspec').any? require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-syntax/tasks/puppet-syntax' require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? @@ -39,9 +40,13 @@ def changelog_future_release returnVal end +PuppetLint.configuration.send('disable_80chars') +PuppetLint.configuration.send('disable_140chars') +PuppetLint.configuration.send('disable_manifest_whitespace_opening_brace_after') PuppetLint.configuration.send('disable_relative') PuppetLint.configuration.send('fail_on_warnings') + 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? @@ -52,7 +57,7 @@ if Bundler.rubygems.find_name('github_changelog_generator').any? config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)." config.add_pr_wo_labels = true config.issues = false - config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM" + config.merge_prefix = "### Merged pull requests:" config.configure_sections = { "Changed" => { "prefix" => "### Changed", @@ -60,11 +65,11 @@ if Bundler.rubygems.find_name('github_changelog_generator').any? }, "Added" => { "prefix" => "### Added", - "labels" => ["feature", "enhancement"], + "labels" => ["enhancement", "feature"], }, "Fixed" => { "prefix" => "### Fixed", - "labels" => ["bugfix"], + "labels" => ["bug", "documentation", "bugfix"], }, } end @@ -72,16 +77,15 @@ else desc 'Generate a Changelog from GitHub' task :changelog do raise <= Gem::Version.new('2.2.2')" + version: '~> 1.15' + condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0')" EOM end end diff --git a/data/os/Debian/10.yaml b/data/os/Debian/10.yaml deleted file mode 100644 index c6f29b0..0000000 --- a/data/os/Debian/10.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -patroni::python_venv_version: '3.7' diff --git a/data/os/Debian/11.yaml b/data/os/Debian/11.yaml new file mode 100644 index 0000000..7483d1a --- /dev/null +++ b/data/os/Debian/11.yaml @@ -0,0 +1,2 @@ +--- +patroni::python_venv_version: '3.9' diff --git a/data/os/Debian/9.yaml b/data/os/Debian/9.yaml deleted file mode 100644 index 71b5b12..0000000 --- a/data/os/Debian/9.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -patroni::python_venv_version: '3.5' diff --git a/data/os/RedHat.yaml b/data/os/RedHat.yaml index 4fbd39f..16c673a 100644 --- a/data/os/RedHat.yaml +++ b/data/os/RedHat.yaml @@ -2,3 +2,4 @@ patroni::config_path: '/opt/app/patroni/etc/postgresql.yml' patroni::install_dependencies: - gcc +patroni::manage_venv_package: false diff --git a/data/os/RedHat/8.yaml b/data/os/RedHat/8.yaml index a343877..a9d39c9 100644 --- a/data/os/RedHat/8.yaml +++ b/data/os/RedHat/8.yaml @@ -1,4 +1,4 @@ --- patroni::manage_postgresql_repo: false patroni::python_class_version: '3' -patroni::python_venv_version: '3' +patroni::python_venv_version: '3.6' diff --git a/data/os/RedHat/9.yaml b/data/os/RedHat/9.yaml new file mode 100644 index 0000000..f19d62b --- /dev/null +++ b/data/os/RedHat/9.yaml @@ -0,0 +1,4 @@ +--- +patroni::manage_postgresql_repo: false +patroni::python_class_version: '3' +patroni::python_venv_version: '3.9' diff --git a/data/os/Ubuntu/18.04.yaml b/data/os/Ubuntu/18.04.yaml deleted file mode 100644 index 5c79d5d..0000000 --- a/data/os/Ubuntu/18.04.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -patroni::python_venv_version: '3.6' diff --git a/data/os/Ubuntu/20.04.yaml b/data/os/Ubuntu/20.04.yaml new file mode 100644 index 0000000..1fe6d21 --- /dev/null +++ b/data/os/Ubuntu/20.04.yaml @@ -0,0 +1,2 @@ +--- +patroni::python_venv_version: '3.8' diff --git a/data/os/Ubuntu/22.04.yaml b/data/os/Ubuntu/22.04.yaml new file mode 100644 index 0000000..7534044 --- /dev/null +++ b/data/os/Ubuntu/22.04.yaml @@ -0,0 +1,2 @@ +--- +patroni::python_venv_version: '3.10' diff --git a/manifests/init.pp b/manifests/init.pp index 77aacca..fc6886a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -224,6 +224,8 @@ # @param python_venv_version # The version of Python to pass to Python virtualenv defined type # Only used when `install_method` is `pip` +# @param manage_venv_package +# Whether to manage the Python venv package # @param config_path # Path to Patroni configuration file # @param config_owner @@ -377,6 +379,7 @@ Stdlib::Absolutepath $install_dir = '/opt/app/patroni', String $python_class_version = '36', String $python_venv_version = '3.6', + Boolean $manage_venv_package = true, String $config_path = '/opt/app/patroni/etc/postgresql.yml', String $config_owner = 'postgres', String $config_group = 'postgres', @@ -447,9 +450,10 @@ if $install_method == 'pip' { if $manage_python { class { 'python': - version => $python_class_version, - dev => 'present', - virtualenv => 'present', + version => $python_class_version, + dev => 'present', + venv => 'present', + manage_venv_package => $manage_venv_package, } } @@ -460,26 +464,12 @@ creates => $install_dir, } - if $facts['os']['family'] == 'RedHat' { - python::virtualenv { 'patroni': - version => $python_venv_version, - venv_dir => $install_dir, - virtualenv => 'virtualenv-3', - systempkgs => true, - distribute => false, - environment => ["PIP_PREFIX=${install_dir}"], - require => Exec['patroni-mkdir-install_dir'], - } - } - - if $facts['os']['family'] == 'Debian' { - python::pyvenv { 'patroni': - version => $python_venv_version, - venv_dir => $install_dir, - systempkgs => true, - environment => ["PIP_PREFIX=${install_dir}"], - require => Exec['patroni-mkdir-install_dir'], - } + python::pyvenv { 'patroni': + version => $python_venv_version, + venv_dir => $install_dir, + systempkgs => true, + environment => ["PIP_PREFIX=${install_dir}"], + require => Exec['patroni-mkdir-install_dir'], } if $custom_pip_provider { @@ -527,11 +517,12 @@ if $install_method == 'pip' { $config_dir = dirname($config_path) file { 'patroni_config_dir': - ensure => 'directory', - path => $config_dir, - owner => 'postgres', - group => 'postgres', - mode => '0755', + ensure => 'directory', + path => $config_dir, + owner => 'postgres', + group => 'postgres', + mode => '0755', + require => Python::Pyvenv['patroni'], } } diff --git a/metadata.json b/metadata.json index 58ec906..f8493d7 100644 --- a/metadata.json +++ b/metadata.json @@ -10,61 +10,54 @@ "dependencies": [ { "name": "puppetlabs/stdlib", - "version_requirement": ">= 6.4.0 < 7.0.0" + "version_requirement": ">= 6.4.0 < 10.0.0" }, { "name": "puppetlabs/postgresql", - "version_requirement": ">= 6.4.0 < 7.0.0" + "version_requirement": ">= 6.4.0 < 11.0.0" }, { "name": "puppet/python", - "version_requirement": ">= 4.1.0 <6.0.0" + "version_requirement": ">= 6.0.0 <8.0.0" }, { - "name": "camptocamp/systemd", - "version_requirement": ">= 2.0.0 <3.0.0" + "name": "puppet/systemd", + "version_requirement": ">= 5.0.0 <7.0.0" } ], "operatingsystem_support": [ { - "operatingsystem": "CentOS", - "operatingsystemrelease": [ - "7", - "8" - ] - }, - { - "operatingsystem": "OracleLinux", + "operatingsystem": "RedHat", "operatingsystemrelease": [ - "7", - "8" + "8", + "9" ] }, { - "operatingsystem": "RedHat", + "operatingsystem": "Rocky", "operatingsystemrelease": [ - "7", - "8" + "8", + "9" ] }, { - "operatingsystem": "Rocky", + "operatingsystem": "Debian", "operatingsystemrelease": [ - "8" + "11" ] }, { - "operatingsystem": "Debian", + "operatingsystem": "Ubuntu", "operatingsystemrelease": [ - "9", - "10" + "20.04", + "22.04" ] } ], "requirements": [ { "name": "puppet", - "version_requirement": ">= 5.5.10 < 8.0.0" + "version_requirement": ">= 7.0.0 < 9.0.0" } ], "tags": [ @@ -74,7 +67,7 @@ "cluster", "ha" ], - "pdk-version": "2.5.0", - "template-url": "https://github.com/tailored-automation/pdk-templates.git#master", - "template-ref": "remotes/origin/master-0-g684aff8" + "pdk-version": "3.0.0", + "template-url": "https://github.com/tailored-automation/pdk-templates.git#main", + "template-ref": "heads/main-0-g8e0611a" } diff --git a/spec/acceptance/nodesets/centos-7.yml b/spec/acceptance/nodesets/centos-7.yml deleted file mode 100644 index a3faf2c..0000000 --- a/spec/acceptance/nodesets/centos-7.yml +++ /dev/null @@ -1,35 +0,0 @@ -HOSTS: - patroni1: - roles: - - agent - - default - - patroni1 - platform: el-7-x86_64 - hypervisor: docker - image: centos:7 - docker_preserve_image: true - docker_cmd: - - '/usr/sbin/init' - docker_image_commands: - - 'yum install -y wget which cronie iproute initscripts' - docker_container_name: 'patroni1-el7' - patroni2: - roles: - - agent - - patroni2 - platform: el-7-x86_64 - hypervisor: docker - image: centos:7 - docker_preserve_image: true - docker_cmd: - - '/usr/sbin/init' - docker_image_commands: - - 'yum install -y wget which cronie iproute initscripts' - docker_container_name: 'patroni2-el7' -CONFIG: - log_level: debug - type: foss -ssh: - password: root - auth_methods: ["password"] - diff --git a/spec/acceptance/nodesets/debian-10.yml b/spec/acceptance/nodesets/debian-11.yml similarity index 67% rename from spec/acceptance/nodesets/debian-10.yml rename to spec/acceptance/nodesets/debian-11.yml index c4f5b5b..799125e 100644 --- a/spec/acceptance/nodesets/debian-10.yml +++ b/spec/acceptance/nodesets/debian-11.yml @@ -4,36 +4,44 @@ HOSTS: - agent - default - patroni1 - platform: debian-10-amd64 + platform: debian-11-amd64 hypervisor: docker - image: debian:10 + image: debian:11 docker_preserve_image: true docker_cmd: - '/sbin/init' docker_image_commands: - - 'apt-get install -y wget net-tools systemd-sysv locales apt-transport-https ca-certificates' + - 'apt-get install -y wget net-tools systemd-sysv locales apt-transport-https ca-certificates iproute2' - 'echo "LC_ALL=en_US.UTF-8" >> /etc/environment' - 'echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen' - 'echo "LANG=en_US.UTF-8" > /etc/locale.conf' - 'locale-gen en_US.UTF-8' - docker_container_name: 'patroni1-debian10' + docker_env: + - LANG=en_US.UTF-8 + - LANGUAGE=en_US.UTF-8 + - LC_ALL=en_US.UTF-8 + docker_container_name: 'patroni1-debian11' patroni2: roles: - agent - patroni2 - platform: debian-10-amd64 + platform: debian-11-amd64 hypervisor: docker - image: debian:10 + image: debian:11 docker_preserve_image: true docker_cmd: - '/sbin/init' docker_image_commands: - - 'apt-get install -y wget net-tools systemd-sysv locales apt-transport-https ca-certificates' + - 'apt-get install -y wget net-tools systemd-sysv locales apt-transport-https ca-certificates iproute2' - 'echo "LC_ALL=en_US.UTF-8" >> /etc/environment' - 'echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen' - 'echo "LANG=en_US.UTF-8" > /etc/locale.conf' - 'locale-gen en_US.UTF-8' - docker_container_name: 'patroni2-debian10' + docker_env: + - LANG=en_US.UTF-8 + - LANGUAGE=en_US.UTF-8 + - LC_ALL=en_US.UTF-8 + docker_container_name: 'patroni2-debian11' CONFIG: log_level: debug type: foss diff --git a/spec/acceptance/nodesets/debian-9.yml b/spec/acceptance/nodesets/debian-9.yml deleted file mode 100644 index 7d64f5e..0000000 --- a/spec/acceptance/nodesets/debian-9.yml +++ /dev/null @@ -1,43 +0,0 @@ -HOSTS: - patroni1: - roles: - - agent - - default - - patroni1 - platform: debian-9-amd64 - hypervisor: docker - image: debian:9 - docker_preserve_image: true - docker_cmd: - - '/sbin/init' - docker_image_commands: - - 'apt-get install -y wget net-tools systemd-sysv locales apt-transport-https ca-certificates' - - 'echo "LC_ALL=en_US.UTF-8" >> /etc/environment' - - 'echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen' - - 'echo "LANG=en_US.UTF-8" > /etc/locale.conf' - - 'locale-gen en_US.UTF-8' - docker_container_name: 'patroni1-debian9' - patroni2: - roles: - - agent - - patroni2 - platform: debian-9-amd64 - hypervisor: docker - image: debian:9 - docker_preserve_image: true - docker_cmd: - - '/sbin/init' - docker_image_commands: - - 'apt-get install -y wget net-tools systemd-sysv locales apt-transport-https ca-certificates' - - 'echo "LC_ALL=en_US.UTF-8" >> /etc/environment' - - 'echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen' - - 'echo "LANG=en_US.UTF-8" > /etc/locale.conf' - - 'locale-gen en_US.UTF-8' - docker_container_name: 'patroni2-debian9' -CONFIG: - log_level: debug - type: foss -ssh: - password: root - auth_methods: ["password"] - diff --git a/spec/acceptance/nodesets/rocky-8.yml b/spec/acceptance/nodesets/el8.yml similarity index 84% rename from spec/acceptance/nodesets/rocky-8.yml rename to spec/acceptance/nodesets/el8.yml index 81fc62d..ec57a08 100644 --- a/spec/acceptance/nodesets/rocky-8.yml +++ b/spec/acceptance/nodesets/el8.yml @@ -14,6 +14,10 @@ HOSTS: - 'yum install -y dnf-utils' - 'dnf config-manager --set-enabled powertools' - 'yum install -y wget which cronie iproute initscripts langpacks-en glibc-all-langpacks' + docker_env: + - LANG=en_US.UTF-8 + - LANGUAGE=en_US.UTF-8 + - LC_ALL=en_US.UTF-8 docker_container_name: 'patroni1-el8' patroni2: roles: @@ -29,6 +33,10 @@ HOSTS: - 'yum install -y dnf-utils' - 'dnf config-manager --set-enabled powertools' - 'yum install -y wget which cronie iproute initscripts langpacks-en glibc-all-langpacks' + docker_env: + - LANG=en_US.UTF-8 + - LANGUAGE=en_US.UTF-8 + - LC_ALL=en_US.UTF-8 docker_container_name: 'patroni2-el8' CONFIG: log_level: debug diff --git a/spec/acceptance/nodesets/el9.yml b/spec/acceptance/nodesets/el9.yml new file mode 100644 index 0000000..06d4b91 --- /dev/null +++ b/spec/acceptance/nodesets/el9.yml @@ -0,0 +1,47 @@ +HOSTS: + patroni1: + roles: + - agent + - default + - patroni1 + platform: el-9-x86_64 + hypervisor: docker + image: rockylinux/rockylinux:9 + docker_preserve_image: true + docker_cmd: + - '/usr/sbin/init' + docker_image_commands: + - 'yum install -y dnf-utils' + - 'dnf config-manager --set-enabled crb' + - 'yum install -y wget which cronie iproute initscripts langpacks-en glibc-all-langpacks' + docker_env: + - LANG=en_US.UTF-8 + - LANGUAGE=en_US.UTF-8 + - LC_ALL=en_US.UTF-8 + docker_container_name: 'patroni1-el9' + patroni2: + roles: + - agent + - patroni2 + platform: el-9-x86_64 + hypervisor: docker + image: rockylinux/rockylinux:9 + docker_preserve_image: true + docker_cmd: + - '/usr/sbin/init' + docker_image_commands: + - 'yum install -y dnf-utils' + - 'dnf config-manager --set-enabled crb' + - 'yum install -y wget which cronie iproute initscripts langpacks-en glibc-all-langpacks' + docker_env: + - LANG=en_US.UTF-8 + - LANGUAGE=en_US.UTF-8 + - LC_ALL=en_US.UTF-8 + docker_container_name: 'patroni2-el9' +CONFIG: + log_level: debug + type: foss +ssh: + password: root + auth_methods: ["password"] + diff --git a/spec/acceptance/nodesets/ubuntu-1804.yml b/spec/acceptance/nodesets/ubuntu-2004.yml similarity index 66% rename from spec/acceptance/nodesets/ubuntu-1804.yml rename to spec/acceptance/nodesets/ubuntu-2004.yml index d7ae7c1..264b536 100644 --- a/spec/acceptance/nodesets/ubuntu-1804.yml +++ b/spec/acceptance/nodesets/ubuntu-2004.yml @@ -4,30 +4,38 @@ HOSTS: - agent - default - patroni1 - platform: ubuntu-18.04-amd64 + platform: ubuntu-20.04-amd64 hypervisor : docker - image: ubuntu:18.04 + image: ubuntu:20.04 docker_preserve_image: true docker_cmd: '["/sbin/init"]' docker_image_commands: - "rm -f /etc/dpkg/dpkg.cfg.d/excludes" - 'apt-get install -y wget net-tools locales apt-transport-https ca-certificates iproute2' - 'locale-gen en_US.UTF-8' - docker_container_name: 'patroni1-ubuntu1804' + docker_env: + - LANG=en_US.UTF-8 + - LANGUAGE=en_US.UTF-8 + - LC_ALL=en_US.UTF-8 + docker_container_name: 'patroni1-ubuntu2004' patroni2: roles: - agent - patroni2 - platform: ubuntu-18.04-amd64 + platform: ubuntu-20.04-amd64 hypervisor : docker - image: ubuntu:18.04 + image: ubuntu:20.04 docker_preserve_image: true docker_cmd: '["/sbin/init"]' docker_image_commands: - "rm -f /etc/dpkg/dpkg.cfg.d/excludes" - 'apt-get install -y wget net-tools locales apt-transport-https ca-certificates iproute2' - 'locale-gen en_US.UTF-8' - docker_container_name: 'patroni2-ubuntu1804' + docker_env: + - LANG=en_US.UTF-8 + - LANGUAGE=en_US.UTF-8 + - LC_ALL=en_US.UTF-8 + docker_container_name: 'patroni2-ubuntu2004' CONFIG: log_level: debug type: foss diff --git a/spec/acceptance/nodesets/ubuntu-2204.yml b/spec/acceptance/nodesets/ubuntu-2204.yml new file mode 100644 index 0000000..702b3a0 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-2204.yml @@ -0,0 +1,45 @@ +HOSTS: + patroni1: + roles: + - agent + - default + - patroni1 + platform: ubuntu-22.04-amd64 + hypervisor : docker + image: ubuntu:22.04 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - "rm -f /etc/dpkg/dpkg.cfg.d/excludes" + - 'apt-get install -y wget net-tools locales apt-transport-https ca-certificates iproute2' + - 'locale-gen en_US.UTF-8' + docker_env: + - LANG=en_US.UTF-8 + - LANGUAGE=en_US.UTF-8 + - LC_ALL=en_US.UTF-8 + docker_container_name: 'patroni1-ubuntu2204' + patroni2: + roles: + - agent + - patroni2 + platform: ubuntu-22.04-amd64 + hypervisor : docker + image: ubuntu:22.04 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - "rm -f /etc/dpkg/dpkg.cfg.d/excludes" + - 'apt-get install -y wget net-tools locales apt-transport-https ca-certificates iproute2' + - 'locale-gen en_US.UTF-8' + docker_env: + - LANG=en_US.UTF-8 + - LANGUAGE=en_US.UTF-8 + - LC_ALL=en_US.UTF-8 + docker_container_name: 'patroni2-ubuntu2204' +CONFIG: + log_level: debug + type: foss +ssh: + password: root + auth_methods: ["password"] + diff --git a/spec/classes/patroni_spec.rb b/spec/classes/patroni_spec.rb index 6c80cd0..47036e3 100644 --- a/spec/classes/patroni_spec.rb +++ b/spec/classes/patroni_spec.rb @@ -8,20 +8,16 @@ # same tests for OracleLinux and RedHat. supported_os: [ { - 'operatingsystem' => 'CentOS', - 'operatingsystemrelease' => ['7'], - }, - { - 'operatingsystem' => 'Rocky', - 'operatingsystemrelease' => ['8'], + 'operatingsystem' => 'RedHat', + 'operatingsystemrelease' => ['7', '8', '9'], }, { 'operatingsystem' => 'Debian', - 'operatingsystemrelease' => ['9', '10'], + 'operatingsystemrelease' => ['11'], }, { 'operatingsystem' => 'Ubuntu', - 'operatingsystemrelease' => ['18.04'], + 'operatingsystemrelease' => ['20.04', '22.04'], }, ], } @@ -79,7 +75,6 @@ is_expected.to contain_class('python').with( version: platform_data(platform, :python_class_version), dev: 'present', - virtualenv: 'present', ) end it 'installs dependencies' do @@ -94,29 +89,14 @@ ) end - case os_facts[:os]['family'] - when 'RedHat' - it do - is_expected.to contain_python__virtualenv('patroni').with( - version: platform_data(platform, :python_venv_version), - venv_dir: '/opt/app/patroni', - virtualenv: 'virtualenv-3', - systempkgs: 'true', - distribute: 'false', - environment: ['PIP_PREFIX=/opt/app/patroni'], - require: 'Exec[patroni-mkdir-install_dir]', - ) - end - when 'Debian' - it do - is_expected.to contain_python__pyvenv('patroni').with( - version: platform_data(platform, :python_venv_version), - venv_dir: '/opt/app/patroni', - systempkgs: 'true', - environment: ['PIP_PREFIX=/opt/app/patroni'], - require: 'Exec[patroni-mkdir-install_dir]', - ) - end + it do + is_expected.to contain_python__pyvenv('patroni').with( + version: platform_data(platform, :python_venv_version), + venv_dir: '/opt/app/patroni', + systempkgs: 'true', + environment: ['PIP_PREFIX=/opt/app/patroni'], + require: 'Exec[patroni-mkdir-install_dir]', + ) end it do @@ -145,6 +125,7 @@ owner: 'postgres', group: 'postgres', mode: '0755', + require: 'Python::Pyvenv[patroni]', ) end @@ -351,7 +332,6 @@ it { is_expected.to compile.with_all_deps } it { is_expected.not_to contain_class('python') } it { is_expected.not_to contain_exec('patroni-mkdir-install_dir') } - it { is_expected.not_to contain_python__virtualenv('patroni') } it { is_expected.not_to contain_python__pyenv('patroni') } it { is_expected.not_to contain_python__pip('patroni') } @@ -376,21 +356,11 @@ creates: '/usr/local/patroni', ) end - case os_facts[:os]['family'] - when 'RedHat' - it do - is_expected.to contain_python__virtualenv('patroni').with( - venv_dir: '/usr/local/patroni', - environment: ['PIP_PREFIX=/usr/local/patroni'], - ) - end - when 'Debian' - it do - is_expected.to contain_python__pyvenv('patroni').with( - venv_dir: '/usr/local/patroni', - environment: ['PIP_PREFIX=/usr/local/patroni'], - ) - end + it do + is_expected.to contain_python__pyvenv('patroni').with( + venv_dir: '/usr/local/patroni', + environment: ['PIP_PREFIX=/usr/local/patroni'], + ) end it do is_expected.to contain_python__pip('patroni').with( diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9032ed2..a26dbcb 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -25,7 +25,7 @@ next unless File.exist?(f) && File.readable?(f) && File.size?(f) begin - default_facts.merge!(YAML.safe_load(File.read(f), [], [], true)) + default_facts.merge!(YAML.safe_load(File.read(f))) rescue => e RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" end @@ -43,12 +43,23 @@ # by default Puppet runs at warning level Puppet.settings[:strict] = :warning Puppet.settings[:strict_variables] = true - Facter.clear end c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] c.after(:suite) do RSpec::Puppet::Coverage.report!(100) 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 diff --git a/spec/spec_helper_local.rb b/spec/spec_helper_local.rb index 6ecc806..48330fe 100644 --- a/spec/spec_helper_local.rb +++ b/spec/spec_helper_local.rb @@ -3,7 +3,7 @@ def platform_data(p, d) data = { - 'CentOS-7' => { + 'RedHat-7' => { postgresql_version: '9.6', data_dir: '/var/lib/pgsql/9.6/data', bin_dir: '/usr/pgsql-9.6/bin', @@ -11,30 +11,38 @@ def platform_data(p, d) python_class_version: '36', python_venv_version: '3.6', }, - 'Rocky-8' => { + 'RedHat-8' => { manage_postgresql_repo: false, postgres_repo_require: nil, data_dir: '/var/lib/pgsql/data', bin_dir: '/usr/bin', - python_venv_version: '3', + python_venv_version: '3.6', }, - 'Debian-9' => { - data_dir: '/var/lib/postgresql/9.6/main', - bin_dir: '/usr/lib/postgresql/9.6/bin', - python_venv_version: '3.5', + 'RedHat-9' => { + manage_postgresql_repo: false, + postgres_repo_require: nil, + data_dir: '/var/lib/pgsql/data', + bin_dir: '/usr/bin', + python_venv_version: '3.9', + }, + 'Debian-11' => { + data_dir: '/var/lib/postgresql/13/main', + bin_dir: '/usr/lib/postgresql/13/bin', + python_venv_version: '3.9', config_dir: '/etc/patroni', config_path: '/etc/patroni/config.yml', }, - 'Debian-10' => { - data_dir: '/var/lib/postgresql/11/main', - bin_dir: '/usr/lib/postgresql/11/bin', + 'Ubuntu-20.04' => { + data_dir: '/var/lib/postgresql/12/main', + bin_dir: '/usr/lib/postgresql/12/bin', + python_venv_version: '3.8', config_dir: '/etc/patroni', config_path: '/etc/patroni/config.yml', }, - 'Ubuntu-18.04' => { - data_dir: '/var/lib/postgresql/10/main', - bin_dir: '/usr/lib/postgresql/10/bin', - python_venv_version: '3.6', + 'Ubuntu-22.04' => { + data_dir: '/var/lib/postgresql/14/main', + bin_dir: '/usr/lib/postgresql/14/bin', + python_venv_version: '3.10', config_dir: '/etc/patroni', config_path: '/etc/patroni/config.yml', },