From 6a22b4ee0d712967389ad2026f7c340023c8c9c2 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 21 Jun 2024 10:20:51 +0200 Subject: [PATCH 01/15] modulesync 9.0.0 --- .editorconfig | 15 ++ .github/CONTRIBUTING.md | 264 ++++++++++++++++++++++++++ .github/ISSUE_TEMPLATE.md | 26 +++ .github/PULL_REQUEST_TEMPLATE.md | 20 ++ .github/labeler.yml | 3 + .github/workflows/ci.yml | 21 ++ .github/workflows/release.yml | 22 +++ .gitignore | 46 +++-- .gitlab-ci.yml | 41 ---- .msync.yml | 5 + .overcommit.yml | 67 +++++++ .pdkignore | 42 ---- .pmtignore | 38 ++++ .puppet-lint.rc | 4 +- .rspec | 2 - .rubocop.yml | 138 +------------- .sync.yml | 24 +-- .travis.yml | 62 ------ .yardopts | 1 - Gemfile | 73 +------ Rakefile | 112 ++++------- appveyor.yml | 57 ------ spec/acceptance/nodesets/centos-7.yml | 16 -- spec/default_facts.yml | 8 - spec/spec_helper.rb | 60 ++---- 25 files changed, 574 insertions(+), 593 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/CONTRIBUTING.md create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/labeler.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml delete mode 100644 .gitlab-ci.yml create mode 100644 .msync.yml create mode 100644 .overcommit.yml delete mode 100644 .pdkignore create mode 100644 .pmtignore delete mode 100644 .rspec delete mode 100644 .travis.yml delete mode 100644 .yardopts delete mode 100644 appveyor.yml delete mode 100644 spec/acceptance/nodesets/centos-7.yml delete mode 100644 spec/default_facts.yml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ecb10a8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# editorconfig.org + +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +tab_width = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..8809327 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,264 @@ +# Contribution guidelines + +## Table of contents + +* [Contributing](#contributing) +* [Writing proper commits - short version](#writing-proper-commits-short-version) +* [Writing proper commits - long version](#writing-proper-commits-long-version) +* [Dependencies](#dependencies) + * [Note for OS X users](#note-for-os-x-users) +* [The test matrix](#the-test-matrix) +* [Syntax and style](#syntax-and-style) +* [Running the unit tests](#running-the-unit-tests) +* [Unit tests in docker](#unit-tests-in-docker) +* [Integration tests](#integration-tests) + +This module has grown over time based on a range of contributions from +people using it. If you follow these contributing guidelines your patch +will likely make it into a release a little more quickly. + +## Contributing + +Please note that this project is released with a Contributor Code of Conduct. +By participating in this project you agree to abide by its terms. +[Contributor Code of Conduct](https://voxpupuli.org/coc/). + +* Fork the repo. +* Create a separate branch for your change. +* We only take pull requests with passing tests, and documentation. [GitHub Actions](https://docs.github.com/en/actions) run the tests for us. You can also execute them locally. This is explained [in a later section](#the-test-matrix). +* Checkout [our docs](https://voxpupuli.org/docs/reviewing_pr/) we use to review a module and the [official styleguide](https://puppet.com/docs/puppet/6.0/style_guide.html). They provide some guidance for new code that might help you before you submit a pull request. +* Add a test for your change. Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, please add a test. +* Squash your commits down into logical components. Make sure to rebase against our current master. +* Push the branch to your fork and submit a pull request. + +Please be prepared to repeat some of these steps as our contributors review your code. + +Also consider sending in your profile code that calls this component module as an acceptance test or provide it via an issue. This helps reviewers a lot to test your use case and prevents future regressions! + +## Writing proper commits - short version + +* Make commits of logical units. +* Check for unnecessary whitespace with "git diff --check" before committing. +* Commit using Unix line endings (check the settings around "crlf" in git-config(1)). +* Do not check in commented out code or unneeded files. +* The first line of the commit message should be a short description (50 characters is the soft limit, excluding ticket number(s)), and should skip the full stop. +* Associate the issue in the message. The first line should include the issue number in the form "(#XXXX) Rest of message". +* The body should provide a meaningful commit message, which: + *uses the imperative, present tense: `change`, not `changed` or `changes`. + * includes motivation for the change, and contrasts its implementation with the previous behavior. + * Make sure that you have tests for the bug you are fixing, or feature you are adding. + * Make sure the test suites passes after your commit: + * When introducing a new feature, make sure it is properly documented in the README.md + +## Writing proper commits - long version + + 1. Make separate commits for logically separate changes. + + Please break your commits down into logically consistent units + which include new or changed tests relevant to the rest of the + change. The goal of doing this is to make the diff easier to + read for whoever is reviewing your code. In general, the easier + your diff is to read, the more likely someone will be happy to + review it and get it into the code base. + + If you are going to refactor a piece of code, please do so as a + separate commit from your feature or bug fix changes. + + We also really appreciate changes that include tests to make + sure the bug is not re-introduced, and that the feature is not + accidentally broken. + + Describe the technical detail of the change(s). If your + description starts to get too long, that is a good sign that you + probably need to split up your commit into more finely grained + pieces. + + Commits which plainly describe the things which help + reviewers check the patch and future developers understand the + code are much more likely to be merged in with a minimum of + bike-shedding or requested changes. Ideally, the commit message + would include information, and be in a form suitable for + inclusion in the release notes for the version of Puppet that + includes them. + + Please also check that you are not introducing any trailing + whitespace or other "whitespace errors". You can do this by + running "git diff --check" on your changes before you commit. + + 2. Sending your patches + + To submit your changes via a GitHub pull request, we _highly_ + recommend that you have them on a topic branch, instead of + directly on `master`. + It makes things much easier to keep track of, especially if + you decide to work on another thing before your first change + is merged in. + + GitHub has some pretty good + [general documentation](http://help.github.com/) on using + their site. They also have documentation on + [creating pull requests](http://help.github.com/send-pull-requests/). + + In general, after pushing your topic branch up to your + repository on GitHub, you can switch to the branch in the + GitHub UI and click "Pull Request" towards the top of the page + in order to open a pull request. + + + 3. Update the related GitHub issue. + + If there is a GitHub issue associated with the change you + submitted, then you should update the ticket to include the + location of your branch, along with any other commentary you + may wish to make. + +## Dependencies + +The testing and development tools have a bunch of dependencies, +all managed by [bundler](http://bundler.io/) according to the +[Puppet support matrix](http://docs.puppetlabs.com/guides/platforms.html#ruby-versions). + +By default the tests use a baseline version of Puppet. + +If you have Ruby 2.x or want a specific version of Puppet, +you must set an environment variable such as: + +```sh +export PUPPET_GEM_VERSION="~> 6.1.0" +``` + +You can install all needed gems for spec tests into the modules directory by +running: + +```sh +bundle config set --local path '.vendor/' +bundle config set --local without 'development system_tests release' +bundle install --jobs "$(nproc)" +``` + +If you also want to run acceptance tests: + +```sh +bundle config set --local path '.vendor/' +bundle config set --local without 'development release' +bundle config set --local with 'system_tests' +bundle install --jobs "$(nproc)" +``` + +Our all in one solution if you don't know if you need to install or update gems: + +```sh +bundle config set --local path '.vendor/' +bundle config set --local without 'development release' +bundle config set --local with 'system_tests' +bundle install --jobs "$(nproc)" +bundle update +bundle clean +``` + +As an alternative to the `--jobs "$(nproc)` parameter, you can set an +environment variable: + +```sh +BUNDLE_JOBS="$(nproc)" +``` + +### Note for OS X users + +`nproc` isn't a valid command under OS x. As an alternative, you can do: + +```sh +--jobs "$(sysctl -n hw.ncpu)" +``` + +## The test matrix + +### Syntax and style + +The test suite will run [Puppet Lint](http://puppet-lint.com/) and +[Puppet Syntax](https://github.com/gds-operations/puppet-syntax) to +check various syntax and style things. You can run these locally with: + +```sh +bundle exec rake lint +bundle exec rake validate +``` + +It will also run some [Rubocop](http://batsov.com/rubocop/) tests +against it. You can run those locally ahead of time with: + +```sh +bundle exec rake rubocop +``` + +### Running the unit tests + +The unit test suite covers most of the code, as mentioned above please +add tests if you're adding new functionality. If you've not used +[rspec-puppet](http://rspec-puppet.com/) before then feel free to ask +about how best to test your new feature. + +To run the linter, the syntax checker and the unit tests: + +```sh +bundle exec rake test +``` + +To run your all the unit tests + +```sh +bundle exec rake spec +``` + +To run a specific spec test set the `SPEC` variable: + +```sh +bundle exec rake spec SPEC=spec/foo_spec.rb +``` + +#### Unit tests in docker + +Some people don't want to run the dependencies locally or don't want to install +ruby. We ship a Dockerfile that enables you to run all unit tests and linting. +You only need to run: + +```sh +docker build . +``` + +Please ensure that a docker daemon is running and that your user has the +permission to talk to it. You can specify a remote docker host by setting the +`DOCKER_HOST` environment variable. it will copy the content of the module into +the docker image. So it will not work if a Gemfile.lock exists. + +### Integration tests + +The unit tests just check the code runs, not that it does exactly what +we want on a real machine. For that we're using +[beaker](https://github.com/puppetlabs/beaker). + +This fires up a new virtual machine (using vagrant) and runs a series of +simple tests against it after applying the module. You can run this +with: + +```sh +BEAKER_PUPPET_COLLECTION=puppet7 BEAKER_setfile=debian11-64 bundle exec rake beaker +``` + +You can replace the string `debian11` with any common operating system. +The following strings are known to work: + +* ubuntu2004 +* ubuntu2204 +* debian11 +* centos7 +* centos8 +* centos9 +* almalinux8 +* almalinux9 +* fedora36 + +For more information and tips & tricks, see [voxpupuli-acceptance's documentation](https://github.com/voxpupuli/voxpupuli-acceptance#running-tests). + +The source of this file is in our [modulesync_config](https://github.com/voxpupuli/modulesync_config/blob/master/moduleroot/.github/CONTRIBUTING.md.erb) +repository. diff --git a/.github/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..7899de8 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,3 @@ +--- +skip-changelog: + - head-branch: ['^release-*', 'release'] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2974af3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,21 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: CI + +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/basic.yml@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..55324aa --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,22 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: Release + +on: + push: + tags: + - '*' + +jobs: + release: + name: Release + uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v2 + 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 2767022..adea1b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,27 +1,25 @@ -.git/ -.*.sw[op] -.metadata -.yardoc -.yardwarns -*.iml -/.bundle/ -/.idea/ -/.vagrant/ -/coverage/ -/bin/ -/doc/ -/Gemfile.local -/Gemfile.lock -/junit/ -/log/ +# 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/ -/tmp/ -/vendor/ -/convert_report.txt -/update_report.txt -.DS_Store -.project -.envrc -/inventory.yaml +/.vagrant/ +/.bundle/ +/.ruby-version +/coverage/ +/log/ +/.idea/ +/.dependencies/ +/.librarian/ +/Puppetfile.lock +*.iml +.*.sw? +/.yardoc/ +/Guardfile +bolt-debug.log +.rerun.json diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 4319435..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- -# yamllint disable rule:line-length rule:truthy -stages: - - syntax - - unit - -cache: - paths: - - vendor/bundle - -before_script: - - bundle -v - - rm Gemfile.lock || true - - gem update --system $RUBYGEMS_VERSION - - gem --version - - bundle -v - - bundle install --without system_tests --path vendor/bundle --jobs $(nproc) - -syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop-Ruby 2.5.3-Puppet ~> 6: - stage: syntax - image: ruby:2.5.3 - script: - - bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop - variables: - PUPPET_GEM_VERSION: '~> 6' - -parallel_spec-Ruby 2.5.3-Puppet ~> 6: - stage: unit - image: ruby:2.5.3 - script: - - bundle exec rake parallel_spec - variables: - PUPPET_GEM_VERSION: '~> 6' - -parallel_spec-Ruby 2.4.5-Puppet ~> 5: - stage: unit - image: ruby:2.4.5 - script: - - bundle exec rake parallel_spec - variables: - PUPPET_GEM_VERSION: '~> 5' diff --git a/.msync.yml b/.msync.yml new file mode 100644 index 0000000..3607168 --- /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.0.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 e6215cd..0000000 --- a/.pdkignore +++ /dev/null @@ -1,42 +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 -/appveyor.yml -/.fixtures.yml -/Gemfile -/.gitattributes -/.gitignore -/.gitlab-ci.yml -/.pdkignore -/Rakefile -/rakelib/ -/.rspec -/.rubocop.yml -/.travis.yml -/.yardopts -/spec/ -/.vscode/ diff --git a/.pmtignore b/.pmtignore new file mode 100644 index 0000000..10b9830 --- /dev/null +++ b/.pmtignore @@ -0,0 +1,38 @@ +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +/docs/ +/pkg/ +/Gemfile +/Gemfile.lock +/Gemfile.local +/vendor/ +/.vendor/ +/spec/ +/Rakefile +/.vagrant/ +/.bundle/ +/.ruby-version +/coverage/ +/log/ +/.idea/ +/.dependencies/ +/.github/ +/.librarian/ +/Puppetfile.lock +*.iml +/.editorconfig +/.fixtures.yml +/.gitignore +/.msync.yml +/.overcommit.yml +/.pmtignore +/.rspec +/.rspec_parallel +/.rubocop.yml +/.sync.yml +.*.sw? +/.yardoc/ +/.yardopts +/Dockerfile +/HISTORY.md diff --git a/.puppet-lint.rc b/.puppet-lint.rc index cc96ece..dd8272c 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1 +1,3 @@ ---relative +--fail-on-warnings +--no-parameter_documentation-check +--no-parameter_types-check diff --git a/.rspec b/.rspec 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 117ab19..53ac189 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,134 +1,6 @@ --- -# yamllint disable rule:line-length rule:truthy rule:indentation -require: -- rubocop-rspec -- rubocop-i18n -AllCops: - DisplayCopNames: true - TargetRubyVersion: '2.1' - Include: - - "./**/*.rb" - Exclude: - - bin/* - - ".vendor/**/*" - - "**/Gemfile" - - "**/Rakefile" - - pkg/**/* - - spec/fixtures/**/* - - vendor/**/* - - "**/Puppetfile" - - "**/Vagrantfile" - - "**/Guardfile" -Metrics/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. - Exclude: - - spec/acceptance/**/*.rb -RSpec/HookArgument: - Description: Prefer explicit :each argument, matching existing module's style - EnforcedStyle: each -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/TrailingCommaInLiteral: - 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 -Style/CollectionMethods: - Enabled: true -Style/MethodCalledOnDoEndBlock: - Enabled: true -Style/StringMethods: - Enabled: true -GetText/DecorateFunctionMessage: - Enabled: false -GetText/DecorateStringFormattingUsingInterpolation: - Enabled: false -GetText/DecorateStringFormattingUsingPercent: - Enabled: false -Layout/EndOfLine: - Enabled: false -Layout/IndentHeredoc: - Enabled: false -Metrics/AbcSize: - Enabled: false -Metrics/BlockLength: - 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 -RSpec/DescribeClass: - Enabled: false -RSpec/ExampleLength: - Enabled: false -RSpec/MessageExpectation: - Enabled: false -RSpec/MultipleExpectations: - Enabled: false -RSpec/NestedGroups: - Enabled: false -Style/AsciiComments: - Enabled: false -Style/IfUnlessModifier: - Enabled: false -Style/SymbolProc: - Enabled: false +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +inherit_gem: + voxpupuli-test: rubocop.yml diff --git a/.sync.yml b/.sync.yml index 3cfe349..f060012 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,22 +1,8 @@ --- -# yamllint disable rule:line-length -.travis.yml: - addons: - apt: - sources: - - augeas - packages: - - libaugeas-dev - user: camptocamp - secure: "GYBg84VC7Mx8BhAJ/56VjPU8tctatVVafGjuM9rJVmvJpbHkTz+XORHkvdVxCCkAkiq0/NZjwWpbxkQGMz0MxnXT5V/H90+h6YRHnWIEEqlW+5dR76uKZ9mO65cqk+l8UA+GUr5ZWKTS0fEJzjNR8aFM56DaM1u+SWIfjBXfE0k=" - branches: - - master - - /^\d/ - deploy_to_forge: - enabled: true - tag_regex: "^\\d" - Gemfile: - required: - ':development': + optional: + ':test': - gem: ruby-augeas +.github/workflows/ci.yml: + with: + additional_packages: libaugeas-dev augeas-tools diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 51aaaff..0000000 --- a/.travis.yml +++ /dev/null @@ -1,62 +0,0 @@ ---- -# yamllint disable rule:line-length rule:truthy -dist: xenial -language: ruby -cache: bundler -addons: - apt: - sources: - - augeas - packages: - - libaugeas-dev -before_install: - - bundle -v - - rm -f Gemfile.lock - - gem update --system $RUBYGEMS_VERSION - - gem --version - - bundle -v -script: - - 'bundle exec rake $CHECK' -bundler_args: --without system_tests -rvm: - - 2.5.3 -stages: - - static - - spec - - acceptance - - - if: tag =~ ^\d - name: deploy -matrix: - fast_finish: true - include: - - - env: CHECK="check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint" - stage: static - - - env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec - rvm: 2.4.5 - stage: spec - - - env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec - rvm: 2.5.3 - stage: spec - - - env: DEPLOY_TO_FORGE=yes - stage: deploy -branches: - only: - - master - - /^v\d/ - - /^\d/ -notifications: - email: false -deploy: - provider: puppetforge - user: camptocamp - password: - secure: "GYBg84VC7Mx8BhAJ/56VjPU8tctatVVafGjuM9rJVmvJpbHkTz+XORHkvdVxCCkAkiq0/NZjwWpbxkQGMz0MxnXT5V/H90+h6YRHnWIEEqlW+5dR76uKZ9mO65cqk+l8UA+GUr5ZWKTS0fEJzjNR8aFM56DaM1u+SWIfjBXfE0k=" - on: - tags: true - all_branches: true - condition: "$DEPLOY_TO_FORGE = yes" diff --git a/.yardopts b/.yardopts deleted file mode 100644 index 29c933b..0000000 --- a/.yardopts +++ /dev/null @@ -1 +0,0 @@ ---markup markdown diff --git a/Gemfile b/Gemfile index 8469a0d..07a9196 100644 --- a/Gemfile +++ b/Gemfile @@ -1,73 +1,16 @@ -source ENV['GEM_SOURCE'] || 'https://rubygems.org' - -def location_for(place_or_version, fake_version = nil) - git_url_regex = %r{\A(?(https?|git)[:@][^#]*)(#(?.*))?} - file_url_regex = %r{\Afile:\/\/(?.*)} - - if place_or_version && (git_url = place_or_version.match(git_url_regex)) - [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact - elsif place_or_version && (file_url = place_or_version.match(file_url_regex)) - ['>= 0', { path: File.expand_path(file_url[:path]), require: false }] - else - [place_or_version, { require: false }] - end -end +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments -minor_version = ruby_version_segments[0..1].join('.') +source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :development do - gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') - gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') - gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') - gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') - gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-posix-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby] - gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby] - gem "puppet-module-win-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-win-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "ruby-augeas", 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 - -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] + gem 'ruby-augeas', :require => false end -gems.each do |gem_name, gem_params| - gem gem_name, *gem_params -end +gem 'rake', :require => false +gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test] -# Evaluate Gemfile.local and ~/.gemfile if they exist -extra_gemfiles = [ - "#{__FILE__}.local", - File.join(Dir.home, '.gemfile'), -] +puppetversion = ENV['PUPPET_GEM_VERSION'] || '~> 7.24' +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 395df54..3e9d90d 100644 --- a/Rakefile +++ b/Rakefile @@ -1,86 +1,44 @@ -require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? -require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet-syntax/tasks/puppet-syntax' -require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? -require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any? -require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any? - -def changelog_user - return unless Rake.application.top_level_tasks.include? "changelog" - returnVal = nil || JSON.load(File.read('metadata.json'))['author'] - raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil? - puts "GitHubChangelogGenerator user:#{returnVal}" - returnVal -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 Bundler.rubygems.find_name('github_changelog_generator').any? - GitHubChangelogGenerator::RakeTask.new :changelog do |config| - raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil? - config.user = "#{changelog_user}" - config.project = "#{changelog_project}" - config.future_release = "#{changelog_future_release}" - config.exclude_labels = ['maintenance'] - config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)." - config.add_pr_wo_labels = true - config.issues = false - config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM" - config.configure_sections = { - "Changed" => { - "prefix" => "### Changed", - "labels" => ["backwards-incompatible"], - }, - "Added" => { - "prefix" => "### Added", - "labels" => ["feature", "enhancement"], - }, - "Fixed" => { - "prefix" => "### Fixed", - "labels" => ["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 <= Gem::Version.new('2.2.2')" -EOM + GCGConfig.user = 'voxpupuli' + GCGConfig.project = 'puppet-augeas' +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/appveyor.yml b/appveyor.yml deleted file mode 100644 index a74fc01..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,57 +0,0 @@ ---- -# yamllint disable rule:line-length rule:truthy -version: 1.1.x.{build} -branches: - only: - - master - - release -skip_commits: - message: /^\(?doc\)?.*/ -clone_depth: 10 -init: - - SET - - 'mkdir C:\ProgramData\PuppetLabs\code && exit 0' - - 'mkdir C:\ProgramData\PuppetLabs\facter && exit 0' - - 'mkdir C:\ProgramData\PuppetLabs\hiera && exit 0' - - 'mkdir C:\ProgramData\PuppetLabs\puppet\var && exit 0' -environment: - matrix: - - - RUBY_VERSION: 24-x64 - CHECK: syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop - - - PUPPET_GEM_VERSION: ~> 5.0 - RUBY_VERSION: 24 - CHECK: parallel_spec - - - PUPPET_GEM_VERSION: ~> 5.0 - RUBY_VERSION: 24-x64 - CHECK: parallel_spec - - - PUPPET_GEM_VERSION: ~> 6.0 - RUBY_VERSION: 25 - CHECK: parallel_spec - - - PUPPET_GEM_VERSION: ~> 6.0 - RUBY_VERSION: 25-x64 - CHECK: parallel_spec -matrix: - fast_finish: true -install: - - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH% - - bundle install --jobs 4 --retry 2 --without system_tests - - type Gemfile.lock -build: off -test_script: - - bundle exec puppet -V - - ruby -v - - gem -v - - bundle -v - - bundle exec rake %CHECK% -notifications: - - provider: Email - to: - - nobody@nowhere.com - on_build_success: false - on_build_failure: false - on_build_status_changed: false diff --git a/spec/acceptance/nodesets/centos-7.yml b/spec/acceptance/nodesets/centos-7.yml deleted file mode 100644 index f646634..0000000 --- a/spec/acceptance/nodesets/centos-7.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -HOSTS: - centos-7-x64: - default_apply_opts: - order: random - strict_variables: - 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 crontabs tar wget iproute' -CONFIG: - type: aio - log_level: debug diff --git a/spec/default_facts.yml b/spec/default_facts.yml deleted file mode 100644 index f777abf..0000000 --- a/spec/default_facts.yml +++ /dev/null @@ -1,8 +0,0 @@ -# Use default_module_facts.yml for module specific facts. -# -# Facts specified here will override the values provided by rspec-puppet-facts. ---- -ipaddress: "172.16.254.254" -ipaddress6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" -is_pe: false -macaddress: "AA:AA:AA:AA:AA:AA" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index feb5720..58c9b66 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,54 +1,24 @@ -require 'puppetlabs_spec_helper/module_spec_helper' -require 'rspec-puppet-facts' +# frozen_string_literal: true -require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb')) +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -include RspecPuppetFacts +# 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__)) -default_facts = { - puppetversion: Puppet.version, - facterversion: Facter.version, -} - -default_fact_files = [ - File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')), - File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')), -] - -default_fact_files.each do |f| - next unless File.exist?(f) && File.readable?(f) && File.size?(f) - - begin - default_facts.merge!(YAML.safe_load(File.read(f), [], [], true)) - rescue => e - RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" - end -end - -# read default_facts and merge them over what is provided by facterdb -default_facts.each do |fact, value| - add_custom_fact fact, value -end +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 - end - c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] - c.after(:suite) do - 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 } From bbb20ecda6c0d4329f460b9809965552e8098668 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 21 Jun 2024 10:25:23 +0200 Subject: [PATCH 02/15] modulesync 9.0.0 --- .github/workflows/ci.yml | 2 ++ Gemfile | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2974af3..f66457d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,3 +19,5 @@ jobs: puppet: name: Puppet uses: voxpupuli/gha-puppet/.github/workflows/basic.yml@v2 + with: + additional_packages: 'libaugeas-dev augeas-tools' diff --git a/Gemfile b/Gemfile index 07a9196..9f3d068 100644 --- a/Gemfile +++ b/Gemfile @@ -3,8 +3,25 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' +group :test do + gem 'voxpupuli-test', '~> 8.0', :require => false + gem 'coveralls', :require => false + gem 'simplecov-console', :require => false + gem 'puppet_metadata', '~> 4.0', :require => false + gem 'ruby-augeas', :require => false +end + group :development do - gem 'ruby-augeas', :require => false + gem 'guard-rake', :require => false + gem 'overcommit', '>= 0.39.1', :require => false +end + +group :system_tests do + gem 'voxpupuli-acceptance', '~> 3.0', :require => false +end + +group :release do + gem 'voxpupuli-release', '~> 3.0', :require => false end gem 'rake', :require => false From 58ac28e364c45501688f738eb2351e2072fcd3c4 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 21 Jun 2024 11:09:38 +0200 Subject: [PATCH 03/15] Fix legacy facts --- manifests/lens.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/lens.pp b/manifests/lens.pp index 0e835d7..f6d88c7 100644 --- a/manifests/lens.pp +++ b/manifests/lens.pp @@ -58,7 +58,7 @@ mode => '0644', } - if (!$stock_since or versioncmp(String($facts['augeasversion']), $stock_since) < 0) { + if (!$stock_since or versioncmp(String($facts['augeas']['version']), $stock_since) < 0) { assert_type(Pattern[/^\/.*/], $augeas::lens_dir) $lens_name = "${name}.aug" From b32c7e1380c4752bafa85e75606af3262bea3288 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Tue, 9 Jul 2024 14:43:21 +0200 Subject: [PATCH 04/15] modulesync 9.1.0 --- .github/CONTRIBUTING.md | 12 ++++++++-- .github/labeler.yml | 3 +++ .github/release.yml | 42 +++++++++++++++++++++++++++++++++++ .github/workflows/labeler.yml | 17 ++++++++++++++ .github/workflows/release.yml | 7 ++++++ .msync.yml | 2 +- .puppet-lint.rc | 3 +++ Gemfile | 2 +- 8 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 .github/release.yml create mode 100644 .github/workflows/labeler.yml diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 8809327..daceb64 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -245,15 +245,23 @@ with: BEAKER_PUPPET_COLLECTION=puppet7 BEAKER_setfile=debian11-64 bundle exec rake beaker ``` +or + +```sh +BEAKER_PUPPET_COLLECTION=none BEAKER_setfile=archlinux-64 bundle exec rake beaker +``` + +This latter example will use the distribution's own version of Puppet. + You can replace the string `debian11` with any common operating system. The following strings are known to work: * ubuntu2004 * ubuntu2204 * debian11 -* centos7 -* centos8 +* debian12 * centos9 +* archlinux * almalinux8 * almalinux9 * fedora36 diff --git a/.github/labeler.yml b/.github/labeler.yml index 7899de8..f2d08d6 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,3 +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/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 0000000..66127cd --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,17 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: "Pull Request Labeler" + +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/release.yml b/.github/workflows/release.yml index 55324aa..93b33c2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,3 +20,10 @@ jobs: # https://docs.github.com/en/actions/security-guides/encrypted-secrets username: ${{ secrets.PUPPET_FORGE_USERNAME }} api_key: ${{ secrets.PUPPET_FORGE_API_KEY }} + + create-github-release: + name: Create GitHub Release + runs-on: ubuntu-latest + steps: + - name: Create GitHub release + uses: voxpupuli/gha-create-a-github-release@v1 diff --git a/.msync.yml b/.msync.yml index 3607168..95e8c97 100644 --- a/.msync.yml +++ b/.msync.yml @@ -2,4 +2,4 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -modulesync_config_version: '9.0.0' +modulesync_config_version: '9.1.0' diff --git a/.puppet-lint.rc b/.puppet-lint.rc index dd8272c..05d28a2 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1,3 +1,6 @@ +# 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/Gemfile b/Gemfile index 9f3d068..662b3b0 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :test do - gem 'voxpupuli-test', '~> 8.0', :require => false + gem 'voxpupuli-test', '~> 9.0', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false gem 'puppet_metadata', '~> 4.0', :require => false From 8aafed88ea7cd0465b8a85eb4b0359e779f03c53 Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Tue, 9 Jul 2024 11:05:54 -0700 Subject: [PATCH 05/15] CHANGELOG.md: trim trailing whitespace --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd036d1..f453325 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ - Remove pe requirements - Use cwd to make commands shorter (GH #63) - Assert types (GH #64) -- Fix beaker version to 3.13 +- Fix beaker version to 3.13 - Fix stdlib dependency (GH #72) ## 2017-03-31 - Release 1.6.1 From 664075d8575d0f3a3dfd52dd18630ecd4e8e63d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Mon, 5 Aug 2024 22:57:34 +0200 Subject: [PATCH 06/15] Auto-correct rubocop offenses These corrections are always safe: bundle exec rubocop -a --- lib/puppet/functions/augeas.rb | 4 +- spec/classes/augeas_spec.rb | 76 +++++++++++++++++++------------- spec/defines/augeas_lens_spec.rb | 11 ++--- spec/functions/augeas_spec.rb | 14 +++--- spec/spec_helper_local.rb | 4 +- 5 files changed, 62 insertions(+), 47 deletions(-) diff --git a/lib/puppet/functions/augeas.rb b/lib/puppet/functions/augeas.rb index 66b2d03..62dcc4c 100644 --- a/lib/puppet/functions/augeas.rb +++ b/lib/puppet/functions/augeas.rb @@ -31,9 +31,7 @@ end def apply_changes(content, lens, changes) - unless Puppet.features.augeas? - raise Puppet::ParseError, 'augeas(): this function requires the augeas feature. See http://projects.puppetlabs.com/projects/puppet/wiki/Puppet_Augeas#Pre-requisites for how to activate it.' - end + raise Puppet::ParseError, 'augeas(): this function requires the augeas feature. See http://projects.puppetlabs.com/projects/puppet/wiki/Puppet_Augeas#Pre-requisites for how to activate it.' unless Puppet.features.augeas? require 'augeas' aug = Augeas.open(nil, nil, Augeas::NO_MODL_AUTOLOAD) diff --git a/spec/classes/augeas_spec.rb b/spec/classes/augeas_spec.rb index aadf7c9..fadfdeb 100644 --- a/spec/classes/augeas_spec.rb +++ b/spec/classes/augeas_spec.rb @@ -14,11 +14,11 @@ end end - if Puppet.version >= '4.0.0' and facts[:rubysitedir] =~ /\/opt\/puppetlabs\/puppet/ - lens_dir = '/opt/puppetlabs/puppet/share/augeas/lenses' - else - lens_dir = '/usr/share/augeas/lenses' - end + lens_dir = if Puppet.version >= '4.0.0' and facts[:rubysitedir] =~ %r{/opt/puppetlabs/puppet} + '/opt/puppetlabs/puppet/share/augeas/lenses' + else + '/usr/share/augeas/lenses' + end on_supported_os.each do |os, facts| context "on #{os}" do @@ -32,19 +32,22 @@ when 'Debian' it { is_expected.to contain_package('libaugeas0').with( - ensure: 'present', + ensure: 'present' ) } + it { is_expected.to contain_package('augeas-tools').with( - ensure: 'present', + ensure: 'present' ) } + it { is_expected.to contain_package('augeas-lenses').with( - ensure: 'present', + ensure: 'present' ) } + case facts[:lsbdistcodename] when 'squeeze', 'lucid', 'precise' let(:facts) do @@ -55,7 +58,7 @@ it { is_expected.to contain_package('ruby-augeas').with( ensure: 'present', - name: 'libaugeas-ruby1.8', + name: 'libaugeas-ruby1.8' ) } else @@ -67,25 +70,27 @@ it { is_expected.to contain_package('ruby-augeas').with( ensure: 'present', - name: 'libaugeas-ruby1.9.1', + name: 'libaugeas-ruby1.9.1' ) } end when 'RedHat' it { is_expected.to contain_package('augeas').with( - ensure: 'present', + ensure: 'present' ) } + it { is_expected.to contain_package('augeas-libs').with( - ensure: 'present', + ensure: 'present' ) } + it { is_expected.to contain_package('ruby-augeas').with( ensure: 'present', - name: 'ruby-augeas', + name: 'ruby-augeas' ) } end @@ -96,20 +101,22 @@ purge: 'true', force: 'true', recurse: 'true', - recurselimit: 1, + recurselimit: 1 ) } + it { is_expected.to contain_file("#{lens_dir}/dist").with( ensure: 'directory', - purge: 'false', + purge: 'false' ) } + it { is_expected.to contain_file("#{lens_dir}/tests").with( ensure: 'directory', purge: 'true', - force: 'true', + force: 'true' ).without(:recurse) } end @@ -127,19 +134,22 @@ when 'Debian' it { is_expected.to contain_package('libaugeas0').with( - ensure: '1.2.3', + ensure: '1.2.3' ) } + it { is_expected.to contain_package('augeas-tools').with( - ensure: '1.2.3', + ensure: '1.2.3' ) } + it { is_expected.to contain_package('augeas-lenses').with( - ensure: '1.2.3', + ensure: '1.2.3' ) } + case facts[:lsbdistcodename] when 'squeeze', 'lucid', 'precise' let(:facts) do @@ -150,7 +160,7 @@ it { is_expected.to contain_package('ruby-augeas').with( ensure: '3.2.1', - name: 'libaugeas-ruby1.8', + name: 'libaugeas-ruby1.8' ) } else @@ -162,25 +172,27 @@ it { is_expected.to contain_package('ruby-augeas').with( ensure: '3.2.1', - name: 'libaugeas-ruby1.9.1', + name: 'libaugeas-ruby1.9.1' ) } end when 'RedHat' it { is_expected.to contain_package('augeas').with( - ensure: '1.2.3', + ensure: '1.2.3' ) } + it { is_expected.to contain_package('augeas-libs').with( - ensure: '1.2.3', + ensure: '1.2.3' ) } + it { is_expected.to contain_package('ruby-augeas').with( ensure: '3.2.1', - name: 'ruby-augeas', + name: 'ruby-augeas' ) } end @@ -200,20 +212,22 @@ purge: 'true', force: 'true', recurse: 'true', - recurselimit: 1, + recurselimit: 1 ) } + it { is_expected.to contain_file('/opt/augeas/lenses/dist').with( ensure: 'directory', - purge: 'false', + purge: 'false' ) } + it { is_expected.to contain_file('/opt/augeas/lenses/tests').with( ensure: 'directory', purge: 'true', - force: 'true', + force: 'true' ).without(:recurse) } end @@ -235,20 +249,22 @@ ensure: 'directory', force: 'true', recurse: 'true', - recurselimit: 1, + recurselimit: 1 ) } + it { is_expected.to contain_file("#{pe_lens_dir}/dist").with( ensure: 'directory', - purge: 'false', + purge: 'false' ) } + it { is_expected.to contain_file("#{pe_lens_dir}/tests").with( ensure: 'directory', force: 'true', - purge: 'true', + purge: 'true' ).without(:recurse) } end diff --git a/spec/defines/augeas_lens_spec.rb b/spec/defines/augeas_lens_spec.rb index dc8c4bb..e8be3ab 100644 --- a/spec/defines/augeas_lens_spec.rb +++ b/spec/defines/augeas_lens_spec.rb @@ -3,11 +3,11 @@ describe 'augeas::lens' do let(:title) { 'foo' } - if Puppet.version >= '4.0.0' and facts[:rubysitedir] =~ /\/opt\/puppetlabs\/puppet/ - lens_dir = '/opt/puppetlabs/puppet/share/augeas/lenses' - else - lens_dir = '/usr/share/augeas/lenses' - end + lens_dir = if Puppet.version >= '4.0.0' and facts[:rubysitedir] =~ %r{/opt/puppetlabs/puppet} + '/opt/puppetlabs/puppet/share/augeas/lenses' + else + '/usr/share/augeas/lenses' + end context 'when declaring augeas class first' do on_supported_os.each do |os, facts| @@ -84,6 +84,7 @@ it do is_expected.not_to contain_file("#{lens_dir}/foo.aug") end + it do is_expected.not_to contain_exec('Typecheck lens foo') end diff --git a/spec/functions/augeas_spec.rb b/spec/functions/augeas_spec.rb index 28bf4a4..b0aee2d 100644 --- a/spec/functions/augeas_spec.rb +++ b/spec/functions/augeas_spec.rb @@ -11,7 +11,7 @@ end context 'when passing wrong arguments' do - before :each do + before do Puppet.features.stubs(:augeas?).returns(true) end @@ -53,15 +53,15 @@ context 'when applying valid changes' do it 'removes the 3rd option' do - is_expected.to run - .with_params("proc /proc proc nodev,noexec,nosuid 0 0\n", 'Fstab.lns', ['rm ./1/opt[3]']) - .and_return("proc /proc proc nodev,noexec 0 0\n") + is_expected.to run. + with_params("proc /proc proc nodev,noexec,nosuid 0 0\n", 'Fstab.lns', ['rm ./1/opt[3]']). + and_return("proc /proc proc nodev,noexec 0 0\n") end it 'sets a 4th option' do - is_expected.to run - .with_params("proc /proc proc nodev,noexec,nosuid 0 0\n", 'Fstab.lns', ['ins opt after ./1/opt[last()]', 'set ./1/opt[last()] nofoo']) - .and_return("proc /proc proc nodev,noexec,nosuid,nofoo 0 0\n") + is_expected.to run. + with_params("proc /proc proc nodev,noexec,nosuid 0 0\n", 'Fstab.lns', ['ins opt after ./1/opt[last()]', 'set ./1/opt[last()] nofoo']). + and_return("proc /proc proc nodev,noexec,nosuid,nofoo 0 0\n") end end diff --git a/spec/spec_helper_local.rb b/spec/spec_helper_local.rb index 8ab47fb..9dfc6ad 100644 --- a/spec/spec_helper_local.rb +++ b/spec/spec_helper_local.rb @@ -4,7 +4,7 @@ RSpec.configure do |config| config.mock_with :rspec - config.before :each do + config.before do # Ensure that we don't accidentally cache facts and environment between # test cases. This requires each example group to explicitly load the # facts being exercised with something like @@ -15,7 +15,7 @@ RSpec::Mocks.setup end - config.after :each do + config.after do RSpec::Mocks.verify RSpec::Mocks.teardown end From 4b53d7750d39f65e126dfa49452eddd7451b5d1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Mon, 5 Aug 2024 22:58:54 +0200 Subject: [PATCH 07/15] Auto-correct more rubocop offenses These ones are sometimes not safe bundle exec rubocop -A --- lib/puppet/functions/augeas.rb | 2 ++ spec/classes/augeas_spec.rb | 4 +++- spec/defines/augeas_lens_spec.rb | 4 +++- spec/functions/augeas_spec.rb | 4 +++- spec/spec_helper_local.rb | 2 ++ 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/puppet/functions/augeas.rb b/lib/puppet/functions/augeas.rb index 62dcc4c..6e0fa1c 100644 --- a/lib/puppet/functions/augeas.rb +++ b/lib/puppet/functions/augeas.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # @summary # Modifies a string using Augeas. # diff --git a/spec/classes/augeas_spec.rb b/spec/classes/augeas_spec.rb index fadfdeb..8d7ee07 100644 --- a/spec/classes/augeas_spec.rb +++ b/spec/classes/augeas_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'augeas' do @@ -14,7 +16,7 @@ end end - lens_dir = if Puppet.version >= '4.0.0' and facts[:rubysitedir] =~ %r{/opt/puppetlabs/puppet} + lens_dir = if (Puppet.version >= '4.0.0') && facts[:rubysitedir] =~ (%r{/opt/puppetlabs/puppet}) '/opt/puppetlabs/puppet/share/augeas/lenses' else '/usr/share/augeas/lenses' diff --git a/spec/defines/augeas_lens_spec.rb b/spec/defines/augeas_lens_spec.rb index e8be3ab..76e4d0c 100644 --- a/spec/defines/augeas_lens_spec.rb +++ b/spec/defines/augeas_lens_spec.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'augeas::lens' do let(:title) { 'foo' } - lens_dir = if Puppet.version >= '4.0.0' and facts[:rubysitedir] =~ %r{/opt/puppetlabs/puppet} + lens_dir = if (Puppet.version >= '4.0.0') && facts[:rubysitedir] =~ (%r{/opt/puppetlabs/puppet}) '/opt/puppetlabs/puppet/share/augeas/lenses' else '/usr/share/augeas/lenses' diff --git a/spec/functions/augeas_spec.rb b/spec/functions/augeas_spec.rb index b0aee2d..e1c6609 100644 --- a/spec/functions/augeas_spec.rb +++ b/spec/functions/augeas_spec.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'augeas' do let(:aug) { Augeas.open(nil, nil, Augeas::NO_MODL_AUTOLOAD) } - it { is_expected.not_to eq(nil) } + it { is_expected.not_to be_nil } it 'fails if the augeas feature is not present' do Puppet.features.expects(:augeas?).returns(false) diff --git a/spec/spec_helper_local.rb b/spec/spec_helper_local.rb index 9dfc6ad..2afb76f 100644 --- a/spec/spec_helper_local.rb +++ b/spec/spec_helper_local.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # HACK: to enable all the expect syntax (like allow_any_instance_of) in rspec-puppet examples RSpec::Mocks::Syntax.enable_expect(RSpec::Puppet::ManifestMatchers) From 241a9f4ac8afe51fb9ea8f64f6ea3191c8973f7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Mon, 5 Aug 2024 23:36:36 +0200 Subject: [PATCH 08/15] Fix last rubocop offenses and fix CI --- spec/classes/augeas_spec.rb | 52 ++++++++++++++++++++------------ spec/defines/augeas_lens_spec.rb | 24 +++++++++------ spec/functions/augeas_spec.rb | 17 +++++++---- spec/spec_helper_local.rb | 24 --------------- 4 files changed, 58 insertions(+), 59 deletions(-) delete mode 100644 spec/spec_helper_local.rb diff --git a/spec/classes/augeas_spec.rb b/spec/classes/augeas_spec.rb index 8d7ee07..0c39736 100644 --- a/spec/classes/augeas_spec.rb +++ b/spec/classes/augeas_spec.rb @@ -3,6 +3,14 @@ require 'spec_helper' describe 'augeas' do + let(:lens_dir) do + if (Puppet.version >= '4.0.0') && facts[:rubysitedir] =~ (%r{/opt/puppetlabs/puppet}) + '/opt/puppetlabs/puppet/share/augeas/lenses' + else + '/usr/share/augeas/lenses' + end + end + context 'when on an unsupported Operating System' do let(:facts) do { @@ -16,12 +24,6 @@ end end - lens_dir = if (Puppet.version >= '4.0.0') && facts[:rubysitedir] =~ (%r{/opt/puppetlabs/puppet}) - '/opt/puppetlabs/puppet/share/augeas/lenses' - else - '/usr/share/augeas/lenses' - end - on_supported_os.each do |os, facts| context "on #{os}" do let(:facts) do @@ -53,8 +55,10 @@ case facts[:lsbdistcodename] when 'squeeze', 'lucid', 'precise' let(:facts) do - super().merge(ruby: { version: '1.8.7' }) - super().merge(rubyversion: '1.8.7') + facts.merge({ + ruby: { version: '1.8.7' }, + rubyversion: '1.8.7' + }) end it { @@ -65,8 +69,10 @@ } else let(:facts) do - super().merge(ruby: { version: '1.9.3' }) - super().merge(rubyversion: '1.9.3') + facts.merge({ + ruby: { version: '1.9.3' }, + rubyversion: '1.9.3' + }) end it { @@ -155,8 +161,10 @@ case facts[:lsbdistcodename] when 'squeeze', 'lucid', 'precise' let(:facts) do - super().merge(ruby: { version: '1.8.7' }) - super().merge(rubyversion: '1.8.7') + facts.merge({ + ruby: { version: '1.8.7' }, + rubyversion: '1.8.7' + }) end it { @@ -167,8 +175,10 @@ } else let(:facts) do - super().merge(ruby: { version: '1.9.3' }) - super().merge(rubyversion: '1.9.3') + facts.merge({ + ruby: { version: '1.9.3' }, + rubyversion: '1.9.3' + }) end it { @@ -239,12 +249,14 @@ facts.merge(is_pe: true) end - pe_lens_dir = if Puppet::Util::Package.versioncmp(Puppet.version, '4.0.0') >= 0 - # the enterprise lens dir is the same in 4 - lens_dir - else - '/opt/puppet/share/augeas/lenses' - end + let(:pe_lens_dir) do + if Puppet::Util::Package.versioncmp(Puppet.version, '4.0.0') >= 0 + # the enterprise lens dir is the same in 4 + lens_dir + else + '/opt/puppet/share/augeas/lenses' + end + end it { is_expected.to contain_file(pe_lens_dir).with( diff --git a/spec/defines/augeas_lens_spec.rb b/spec/defines/augeas_lens_spec.rb index 76e4d0c..c40de02 100644 --- a/spec/defines/augeas_lens_spec.rb +++ b/spec/defines/augeas_lens_spec.rb @@ -5,11 +5,13 @@ describe 'augeas::lens' do let(:title) { 'foo' } - lens_dir = if (Puppet.version >= '4.0.0') && facts[:rubysitedir] =~ (%r{/opt/puppetlabs/puppet}) - '/opt/puppetlabs/puppet/share/augeas/lenses' - else - '/usr/share/augeas/lenses' - end + let(:lens_dir) do + if (Puppet.version >= '4.0.0') && facts[:rubysitedir] =~ (%r{/opt/puppetlabs/puppet}) + '/opt/puppetlabs/puppet/share/augeas/lenses' + else + '/usr/share/augeas/lenses' + end + end context 'when declaring augeas class first' do on_supported_os.each do |os, facts| @@ -62,8 +64,10 @@ end let(:facts) do - super().merge(augeas: { version: '1.0.0' }) - super().merge(augeasversion: '1.0.0') + facts.merge({ + augeas: { version: '1.0.0' }, + augeasversion: '1.0.0' + }) end it { is_expected.to contain_file("#{lens_dir}/foo.aug") } @@ -79,8 +83,10 @@ end let(:facts) do - super().merge(augeas: { version: '1.3.0' }) - super().merge(augeasversion: '1.3.0') + facts.merge({ + augeas: { version: '1.3.0' }, + augeasversion: '1.3.0' + }) end it do diff --git a/spec/functions/augeas_spec.rb b/spec/functions/augeas_spec.rb index e1c6609..537fda5 100644 --- a/spec/functions/augeas_spec.rb +++ b/spec/functions/augeas_spec.rb @@ -8,13 +8,14 @@ it { is_expected.not_to be_nil } it 'fails if the augeas feature is not present' do - Puppet.features.expects(:augeas?).returns(false) + allow(Puppet.features).to receive(:augeas?).and_return(false) is_expected.to run.with_params('', 'Foo.lns', []).and_raise_error(Puppet::ParseError, %r{requires the augeas feature}) + expect(Puppet.features).to have_received(:augeas?) end context 'when passing wrong arguments' do before do - Puppet.features.stubs(:augeas?).returns(true) + allow(Puppet.features).to receive(:augeas?).and_return(true) end it 'raises a ParseError if there are no arguments' do @@ -69,15 +70,19 @@ context 'when using old libs' do it 'does not work with Augeas prior to 1.0.0' do - expect(Augeas).to receive(:open).and_return(aug) - expect(aug).to receive(:get).with('/augeas/version').and_return('0.10.0') + allow(Augeas).to receive(:open).and_return(aug) + allow(aug).to receive(:get).with('/augeas/version').and_return('0.10.0') is_expected.to run.with_params("\n", 'Fstab.lns', []).and_raise_error(Puppet::ParseError, %r{requires Augeas 1\.0\.0}) + expect(Augeas).to have_received(:open) + expect(aug).to have_received(:get).with('/augeas/version') end it 'does not work with ruby-augeas prior to 0.5.0' do - expect(Augeas).to receive(:open).and_return(aug) - expect(aug).to receive(:methods).and_return([]) + allow(Augeas).to receive(:open).and_return(aug) + allow(aug).to receive(:methods).and_return([]) is_expected.to run.with_params("\n", 'Fstab.lns', []).and_raise_error(Puppet::ParseError, %r{requires ruby-augeas 0\.5\.0}) + expect(Augeas).to have_received(:open) + expect(aug).to have_received(:methods) end end end diff --git a/spec/spec_helper_local.rb b/spec/spec_helper_local.rb deleted file mode 100644 index 2afb76f..0000000 --- a/spec/spec_helper_local.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -# HACK: to enable all the expect syntax (like allow_any_instance_of) in rspec-puppet examples -RSpec::Mocks::Syntax.enable_expect(RSpec::Puppet::ManifestMatchers) - -RSpec.configure do |config| - config.mock_with :rspec - - config.before do - # Ensure that we don't accidentally cache facts and environment between - # test cases. This requires each example group to explicitly load the - # facts being exercised with something like - # Facter.collection.loader.load(:ipaddress) - Facter.clear - Facter.clear_messages - - RSpec::Mocks.setup - end - - config.after do - RSpec::Mocks.verify - RSpec::Mocks.teardown - end -end From acb175b0df4cbc8a7ad6ff19fa77ff570528d232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Mon, 5 Aug 2024 23:41:50 +0200 Subject: [PATCH 09/15] Add support for Puppet 7 & 8 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 35f771c..4a92c14 100644 --- a/metadata.json +++ b/metadata.json @@ -57,7 +57,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 4.10.0 < 7.0.0" + "version_requirement": ">= 4.10.0 < 9.0.0" } ], "description": "Augeas Module for Puppet", From fd7b9028004e80b310ba14caa662fd37442a0cb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Wed, 7 Aug 2024 07:04:50 +0200 Subject: [PATCH 10/15] Add support for current Operating Systems The list of supported Operating Systems is outdated. Update it and add some basic acceptance tests to ensure the code is valid. --- .github/workflows/ci.yml | 2 +- .sync.yml | 2 ++ metadata.json | 15 +++++++++++---- spec/acceptance/init_spec.rb | 16 ++++++++++++++++ .../nodesets/centos-5-x86_64-docker.yml | 16 ---------------- spec/acceptance/nodesets/centos-5.yml | 17 ----------------- .../nodesets/centos-6-x86_64-docker.yml | 16 ---------------- .../nodesets/centos-6-x86_64-openstack.yml | 15 --------------- .../nodesets/centos-6-x86_64-vagrant.yml | 12 ------------ spec/acceptance/nodesets/centos-6.yml | 18 ------------------ .../nodesets/centos-7-x86_64-docker.yml | 16 ---------------- .../nodesets/centos-7-x86_64-openstack.yml | 15 --------------- .../nodesets/centos-7-x86_64-vagrant.yml | 12 ------------ .../nodesets/debian-6-x86_64-docker.yml | 16 ---------------- .../nodesets/debian-6-x86_64-openstack.yml | 15 --------------- .../nodesets/debian-6-x86_64-vagrant.yml | 12 ------------ spec/acceptance/nodesets/debian-6.yml | 16 ---------------- .../nodesets/debian-7-x86_64-docker.yml | 16 ---------------- .../nodesets/debian-7-x86_64-openstack.yml | 15 --------------- .../nodesets/debian-7-x86_64-vagrant.yml | 12 ------------ spec/acceptance/nodesets/debian-7.yml | 16 ---------------- .../nodesets/debian-8-x86_64-docker.yml | 16 ---------------- .../nodesets/debian-8-x86_64-openstack.yml | 15 --------------- .../nodesets/debian-8-x86_64-vagrant.yml | 12 ------------ spec/acceptance/nodesets/debian-8.yml | 17 ----------------- .../nodesets/ubuntu-10.04-x86_64-docker.yml | 15 --------------- .../nodesets/ubuntu-12.04-x86_64-docker.yml | 16 ---------------- .../ubuntu-12.04-x86_64-openstack.yml | 15 --------------- spec/acceptance/nodesets/ubuntu-12.04.yml | 17 ----------------- .../nodesets/ubuntu-14.04-x86_64-docker.yml | 16 ---------------- .../ubuntu-14.04-x86_64-openstack.yml | 15 --------------- .../nodesets/ubuntu-14.04-x86_64-vagrant.yml | 12 ------------ spec/acceptance/nodesets/ubuntu-14.04.yml | 19 ------------------- .../nodesets/ubuntu-14.10-x86_64-docker.yml | 16 ---------------- .../ubuntu-14.10-x86_64-openstack.yml | 15 --------------- spec/acceptance/nodesets/ubuntu-14.10.yml | 19 ------------------- .../nodesets/ubuntu-15.04-x86_64-docker.yml | 16 ---------------- .../ubuntu-15.04-x86_64-openstack.yml | 15 --------------- spec/acceptance/nodesets/ubuntu-15.04.yml | 17 ----------------- spec/acceptance/nodesets/ubuntu-15.10.yml | 17 ----------------- spec/acceptance/nodesets/ubuntu-16.04.yml | 17 ----------------- spec/spec_helper_acceptance.rb | 10 ++++++++++ 42 files changed, 40 insertions(+), 577 deletions(-) create mode 100644 spec/acceptance/init_spec.rb delete mode 100644 spec/acceptance/nodesets/centos-5-x86_64-docker.yml delete mode 100644 spec/acceptance/nodesets/centos-5.yml delete mode 100644 spec/acceptance/nodesets/centos-6-x86_64-docker.yml delete mode 100644 spec/acceptance/nodesets/centos-6-x86_64-openstack.yml delete mode 100644 spec/acceptance/nodesets/centos-6-x86_64-vagrant.yml delete mode 100644 spec/acceptance/nodesets/centos-6.yml delete mode 100644 spec/acceptance/nodesets/centos-7-x86_64-docker.yml delete mode 100644 spec/acceptance/nodesets/centos-7-x86_64-openstack.yml delete mode 100644 spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml delete mode 100644 spec/acceptance/nodesets/debian-6-x86_64-docker.yml delete mode 100644 spec/acceptance/nodesets/debian-6-x86_64-openstack.yml delete mode 100644 spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml delete mode 100644 spec/acceptance/nodesets/debian-6.yml delete mode 100644 spec/acceptance/nodesets/debian-7-x86_64-docker.yml delete mode 100644 spec/acceptance/nodesets/debian-7-x86_64-openstack.yml delete mode 100644 spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml delete mode 100644 spec/acceptance/nodesets/debian-7.yml delete mode 100644 spec/acceptance/nodesets/debian-8-x86_64-docker.yml delete mode 100644 spec/acceptance/nodesets/debian-8-x86_64-openstack.yml delete mode 100644 spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml delete mode 100644 spec/acceptance/nodesets/debian-8.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-10.04-x86_64-docker.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-12.04-x86_64-docker.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-12.04-x86_64-openstack.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-12.04.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-14.04-x86_64-docker.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-14.04-x86_64-openstack.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-14.04.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-14.10-x86_64-docker.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-14.10-x86_64-openstack.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-14.10.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-15.04-x86_64-docker.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-15.04-x86_64-openstack.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-15.04.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-15.10.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-16.04.yml create mode 100644 spec/spec_helper_acceptance.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f66457d..d758d05 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,6 @@ concurrency: jobs: puppet: name: Puppet - uses: voxpupuli/gha-puppet/.github/workflows/basic.yml@v2 + uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v2 with: additional_packages: 'libaugeas-dev augeas-tools' diff --git a/.sync.yml b/.sync.yml index f060012..26f1bd8 100644 --- a/.sync.yml +++ b/.sync.yml @@ -6,3 +6,5 @@ Gemfile: .github/workflows/ci.yml: with: additional_packages: libaugeas-dev augeas-tools +spec/spec_helper_acceptance.rb: + unmanaged: false diff --git a/metadata.json b/metadata.json index 4a92c14..d456f6a 100644 --- a/metadata.json +++ b/metadata.json @@ -18,7 +18,9 @@ "operatingsystem": "Debian", "operatingsystemrelease": [ "6", - "7" + "7", + "10", + "11" ] }, { @@ -26,14 +28,17 @@ "operatingsystemrelease": [ "10.04", "12.04", - "14.04" + "14.04", + "20.04", + "22.04" ] }, { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", - "6" + "6", + "9" ] }, { @@ -50,7 +55,9 @@ "operatingsystem": "FreeBSD", "operatingsystemrelease": [ "11", - "12" + "12", + "13", + "14" ] } ], diff --git a/spec/acceptance/init_spec.rb b/spec/acceptance/init_spec.rb new file mode 100644 index 0000000..23401a6 --- /dev/null +++ b/spec/acceptance/init_spec.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require 'spec_helper_acceptance' + +describe 'augeas class' do + context 'with default parameters' do + it_behaves_like 'an idempotent resource' do + let(:manifest) do + <<~PUPPET + class { 'augeas': + } + PUPPET + end + end + end +end diff --git a/spec/acceptance/nodesets/centos-5-x86_64-docker.yml b/spec/acceptance/nodesets/centos-5-x86_64-docker.yml deleted file mode 100644 index 05cf774..0000000 --- a/spec/acceptance/nodesets/centos-5-x86_64-docker.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -HOSTS: - centos-5-x64: - default_apply_opts: - order: random - strict_variables: - platform: el-5-x86_64 - hypervisor: docker - image: centos:5 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'yum install -y crontabs tar wget' -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/centos-5.yml b/spec/acceptance/nodesets/centos-5.yml deleted file mode 100644 index e07adfd..0000000 --- a/spec/acceptance/nodesets/centos-5.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -HOSTS: - centos-5-x64: - default_apply_opts: - order: random - strict_variables: - platform: el-5-x86_64 - hypervisor: docker - image: tianon/centos:5.10 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'yum install -y crontabs tar wget which' - - 'sed -i -e "/mingetty/d" /etc/inittab' -CONFIG: - type: aio - log_level: debug diff --git a/spec/acceptance/nodesets/centos-6-x86_64-docker.yml b/spec/acceptance/nodesets/centos-6-x86_64-docker.yml deleted file mode 100644 index 1cbeacf..0000000 --- a/spec/acceptance/nodesets/centos-6-x86_64-docker.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -HOSTS: - centos-6-x64: - default_apply_opts: - order: random - strict_variables: - platform: el-6-x86_64 - hypervisor: docker - image: centos:6 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'yum install -y crontabs tar wget' -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/centos-6-x86_64-openstack.yml b/spec/acceptance/nodesets/centos-6-x86_64-openstack.yml deleted file mode 100644 index 39016e9..0000000 --- a/spec/acceptance/nodesets/centos-6-x86_64-openstack.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -HOSTS: - centos-6-x64: - default_apply_opts: - order: random - strict_variables: - platform: el-6-x86_64 - hypervisor: openstack - flavor: m1.small - image: centos-6-latest - user: root -CONFIG: - type: foss - log_level: debug - openstack_network: default diff --git a/spec/acceptance/nodesets/centos-6-x86_64-vagrant.yml b/spec/acceptance/nodesets/centos-6-x86_64-vagrant.yml deleted file mode 100644 index 82af376..0000000 --- a/spec/acceptance/nodesets/centos-6-x86_64-vagrant.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -HOSTS: - centos-6-x64: - default_apply_opts: - order: random - strict_variables: - platform: el-6-x86_64 - hypervisor: vagrant - box: camptocamp/centos-6-x86_64 -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/centos-6.yml b/spec/acceptance/nodesets/centos-6.yml deleted file mode 100644 index 5cfd6fc..0000000 --- a/spec/acceptance/nodesets/centos-6.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- -HOSTS: - centos-6-x64: - default_apply_opts: - order: random - strict_variables: - platform: el-6-x86_64 - hypervisor: docker - image: centos:6 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'rm -rf /var/run/network/*' - - 'yum install -y crontabs tar wget' - - 'rm /etc/init/tty.conf' -CONFIG: - type: aio - log_level: debug diff --git a/spec/acceptance/nodesets/centos-7-x86_64-docker.yml b/spec/acceptance/nodesets/centos-7-x86_64-docker.yml deleted file mode 100644 index 329bf9e..0000000 --- a/spec/acceptance/nodesets/centos-7-x86_64-docker.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -HOSTS: - centos-7-x64: - default_apply_opts: - order: random - strict_variables: - 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 crontabs tar wget' -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml b/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml deleted file mode 100644 index 5f3d7e8..0000000 --- a/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -HOSTS: - centos-7-x64: - default_apply_opts: - order: random - strict_variables: - platform: el-7-x86_64 - hypervisor: openstack - flavor: m1.small - image: centos-7-latest - user: centos -CONFIG: - type: foss - log_level: debug - openstack_network: default diff --git a/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml b/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml deleted file mode 100644 index 2064466..0000000 --- a/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -HOSTS: - centos-7-x64: - default_apply_opts: - order: random - strict_variables: - platform: el-7-x86_64 - hypervisor: vagrant - box: camptocamp/centos-7-x86_64 -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/debian-6-x86_64-docker.yml b/spec/acceptance/nodesets/debian-6-x86_64-docker.yml deleted file mode 100644 index b15ce0b..0000000 --- a/spec/acceptance/nodesets/debian-6-x86_64-docker.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -HOSTS: - debian-6-x64: - default_apply_opts: - order: random - strict_variables: - platform: debian-6-amd64 - hypervisor: docker - image: debian:6 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get install -y wget' -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/debian-6-x86_64-openstack.yml b/spec/acceptance/nodesets/debian-6-x86_64-openstack.yml deleted file mode 100644 index e14e0dc..0000000 --- a/spec/acceptance/nodesets/debian-6-x86_64-openstack.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -HOSTS: - debian-6-x64: - default_apply_opts: - order: random - strict_variables: - platform: debian-6-amd64 - hypervisor: openstack - flavor: m1.small - image: debian-6-latest - user: debian -CONFIG: - type: foss - log_level: debug - openstack_network: default diff --git a/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml b/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml deleted file mode 100644 index c20e216..0000000 --- a/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -HOSTS: - debian-6-x64: - default_apply_opts: - order: random - strict_variables: - platform: debian-6-amd64 - hypervisor: vagrant - box: puppetlabs/debian-6.0.10-64-nocm -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/debian-6.yml b/spec/acceptance/nodesets/debian-6.yml deleted file mode 100644 index 9204ee4..0000000 --- a/spec/acceptance/nodesets/debian-6.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -HOSTS: - debian-6-x64: - default_apply_opts: - order: random - strict_variables: - platform: debian-6-amd64 - hypervisor: docker - image: debian/eol:squeeze - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get install -y cron locales-all net-tools wget' -CONFIG: - type: aio - log_level: debug diff --git a/spec/acceptance/nodesets/debian-7-x86_64-docker.yml b/spec/acceptance/nodesets/debian-7-x86_64-docker.yml deleted file mode 100644 index 63b9cdc..0000000 --- a/spec/acceptance/nodesets/debian-7-x86_64-docker.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -HOSTS: - debian-7-x64: - default_apply_opts: - order: random - strict_variables: - platform: debian-7-amd64 - hypervisor: docker - image: debian:7 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get install -y cron wget' -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml b/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml deleted file mode 100644 index c1ce94f..0000000 --- a/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -HOSTS: - debian-7-x64: - default_apply_opts: - order: random - strict_variables: - platform: debian-7-amd64 - hypervisor: openstack - flavor: m1.small - image: debian-7-latest - user: debian -CONFIG: - type: foss - log_level: debug - openstack_network: default diff --git a/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml b/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml deleted file mode 100644 index 1097155..0000000 --- a/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -HOSTS: - debian-7-x64: - default_apply_opts: - order: random - strict_variables: - platform: debian-7-amd64 - hypervisor: vagrant - box: camptocamp/debian-7-amd64 -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/debian-7.yml b/spec/acceptance/nodesets/debian-7.yml deleted file mode 100644 index 90cc5cf..0000000 --- a/spec/acceptance/nodesets/debian-7.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -HOSTS: - debian-7-x64: - default_apply_opts: - order: random - strict_variables: - platform: debian-7-amd64 - hypervisor: docker - image: debian:7 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get install -y cron locales-all net-tools wget' -CONFIG: - type: aio - log_level: debug diff --git a/spec/acceptance/nodesets/debian-8-x86_64-docker.yml b/spec/acceptance/nodesets/debian-8-x86_64-docker.yml deleted file mode 100644 index ca322f2..0000000 --- a/spec/acceptance/nodesets/debian-8-x86_64-docker.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -HOSTS: - debian-8-x64: - default_apply_opts: - order: random - strict_variables: - platform: debian-8-amd64 - hypervisor: docker - image: debian:8 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get install -y cron wget' -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml b/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml deleted file mode 100644 index ba88c8e..0000000 --- a/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -HOSTS: - debian-8-x64: - default_apply_opts: - order: random - strict_variables: - platform: debian-8-amd64 - hypervisor: openstack - flavor: m1.small - image: debian-8-latest - user: debian -CONFIG: - type: foss - log_level: debug - openstack_network: default diff --git a/spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml b/spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml deleted file mode 100644 index 7dcf7cd..0000000 --- a/spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -HOSTS: - debian-8-x64: - default_apply_opts: - order: random - strict_variables: - platform: debian-8-amd64 - hypervisor: vagrant - box: camptocamp/debian-8-amd64 -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/debian-8.yml b/spec/acceptance/nodesets/debian-8.yml deleted file mode 100644 index e6b7701..0000000 --- a/spec/acceptance/nodesets/debian-8.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -HOSTS: - debian-8-x64: - default_apply_opts: - order: random - strict_variables: - platform: debian-8-amd64 - hypervisor: docker - image: debian:8 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get install -y cron locales-all net-tools wget' - - 'rm -f /usr/sbin/policy-rc.d' -CONFIG: - type: aio - log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-10.04-x86_64-docker.yml b/spec/acceptance/nodesets/ubuntu-10.04-x86_64-docker.yml deleted file mode 100644 index 93bb624..0000000 --- a/spec/acceptance/nodesets/ubuntu-10.04-x86_64-docker.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -# yamllint disable rule:line-length -HOSTS: - ubuntu-1004-x64: - default_apply_opts: - order: random - strict_variables: - platform: ubuntu-10.04-amd64 - hypervisor: docker - image: ubuntu:10.04 - # This stops the image from being deleted on completion, speeding up the process. - docker_preserve_image: true -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-12.04-x86_64-docker.yml b/spec/acceptance/nodesets/ubuntu-12.04-x86_64-docker.yml deleted file mode 100644 index 80aeb07..0000000 --- a/spec/acceptance/nodesets/ubuntu-12.04-x86_64-docker.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -HOSTS: - ubuntu-1204-x64: - default_apply_opts: - order: random - strict_variables: - platform: ubuntu-12.04-amd64 - hypervisor: docker - image: ubuntu:12.04 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get install -y wget' -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-12.04-x86_64-openstack.yml b/spec/acceptance/nodesets/ubuntu-12.04-x86_64-openstack.yml deleted file mode 100644 index cfe88c3..0000000 --- a/spec/acceptance/nodesets/ubuntu-12.04-x86_64-openstack.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -HOSTS: - ubuntu-1204-x64: - default_apply_opts: - order: random - strict_variables: - platform: ubuntu-12.04-amd64 - hypervisor: openstack - flavor: m1.small - image: ubuntu-1204-latest - user: ubuntu -CONFIG: - type: foss - log_level: debug - openstack_network: default diff --git a/spec/acceptance/nodesets/ubuntu-12.04.yml b/spec/acceptance/nodesets/ubuntu-12.04.yml deleted file mode 100644 index 13e0d81..0000000 --- a/spec/acceptance/nodesets/ubuntu-12.04.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -HOSTS: - ubuntu-1204-x64: - default_apply_opts: - order: random - strict_variables: - platform: ubuntu-12.04-amd64 - hypervisor: docker - image: ubuntu:12.04 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get install -y net-tools wget' - - 'locale-gen en_US.UTF-8' -CONFIG: - type: aio - log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-14.04-x86_64-docker.yml b/spec/acceptance/nodesets/ubuntu-14.04-x86_64-docker.yml deleted file mode 100644 index cd0c0ed..0000000 --- a/spec/acceptance/nodesets/ubuntu-14.04-x86_64-docker.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -HOSTS: - ubuntu-1404-x64: - default_apply_opts: - order: random - strict_variables: - platform: ubuntu-14.04-amd64 - hypervisor: docker - image: ubuntu:14.04 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get install -y wget' -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-14.04-x86_64-openstack.yml b/spec/acceptance/nodesets/ubuntu-14.04-x86_64-openstack.yml deleted file mode 100644 index 760a4b9..0000000 --- a/spec/acceptance/nodesets/ubuntu-14.04-x86_64-openstack.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -HOSTS: - ubuntu-1404-x64: - default_apply_opts: - order: random - strict_variables: - platform: ubuntu-14.04-amd64 - hypervisor: openstack - flavor: m1.small - image: ubuntu-1404-latest - user: ubuntu -CONFIG: - type: foss - log_level: debug - openstack_network: default diff --git a/spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml b/spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml deleted file mode 100644 index 2ae40c5..0000000 --- a/spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -HOSTS: - ubuntu-1404-x64: - default_apply_opts: - order: random - strict_variables: - platform: ubuntu-14.04-amd64 - hypervisor: vagrant - box: puppetlabs/ubuntu-14.04-64-nocm -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-14.04.yml b/spec/acceptance/nodesets/ubuntu-14.04.yml deleted file mode 100644 index ca6fd49..0000000 --- a/spec/acceptance/nodesets/ubuntu-14.04.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -HOSTS: - ubuntu-1404-x64: - default_apply_opts: - order: random - strict_variables: - platform: ubuntu-14.04-amd64 - hypervisor: docker - image: ubuntu:14.04 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'rm /usr/sbin/policy-rc.d' - - 'rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl' - - 'apt-get install -y net-tools wget' - - 'locale-gen en_US.UTF-8' -CONFIG: - type: aio - log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-14.10-x86_64-docker.yml b/spec/acceptance/nodesets/ubuntu-14.10-x86_64-docker.yml deleted file mode 100644 index f0fe17e..0000000 --- a/spec/acceptance/nodesets/ubuntu-14.10-x86_64-docker.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -HOSTS: - ubuntu-1410-x64: - default_apply_opts: - order: random - strict_variables: - platform: ubuntu-14.10-amd64 - hypervisor: docker - image: ubuntu:14.10 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get install -y wget' -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-14.10-x86_64-openstack.yml b/spec/acceptance/nodesets/ubuntu-14.10-x86_64-openstack.yml deleted file mode 100644 index aa3a54f..0000000 --- a/spec/acceptance/nodesets/ubuntu-14.10-x86_64-openstack.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -HOSTS: - ubuntu-1410-x64: - default_apply_opts: - order: random - strict_variables: - platform: ubuntu-14.10-amd64 - hypervisor: openstack - flavor: m1.small - image: ubuntu-1410-latest - user: ubuntu -CONFIG: - type: foss - log_level: debug - openstack_network: default diff --git a/spec/acceptance/nodesets/ubuntu-14.10.yml b/spec/acceptance/nodesets/ubuntu-14.10.yml deleted file mode 100644 index c253489..0000000 --- a/spec/acceptance/nodesets/ubuntu-14.10.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -HOSTS: - ubuntu-1410-x64: - default_apply_opts: - order: random - strict_variables: - platform: ubuntu-14.10-amd64 - hypervisor: docker - image: ubuntu:14.10 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'rm /usr/sbin/policy-rc.d' - - 'rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl' - - 'apt-get install -y net-tools wget' - - 'locale-gen en_US.UTF-8' -CONFIG: - type: aio - log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-15.04-x86_64-docker.yml b/spec/acceptance/nodesets/ubuntu-15.04-x86_64-docker.yml deleted file mode 100644 index 50a4f6e..0000000 --- a/spec/acceptance/nodesets/ubuntu-15.04-x86_64-docker.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -HOSTS: - ubuntu-1504-x64: - default_apply_opts: - order: random - strict_variables: - platform: ubuntu-15.04-amd64 - hypervisor: docker - image: ubuntu:15.04 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get install -y wget' -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-15.04-x86_64-openstack.yml b/spec/acceptance/nodesets/ubuntu-15.04-x86_64-openstack.yml deleted file mode 100644 index 40fd518..0000000 --- a/spec/acceptance/nodesets/ubuntu-15.04-x86_64-openstack.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -HOSTS: - ubuntu-1504-x64: - default_apply_opts: - order: random - strict_variables: - platform: ubuntu-15.04-amd64 - hypervisor: openstack - flavor: m1.small - image: ubuntu-1504-latest - user: ubuntu -CONFIG: - type: foss - log_level: debug - openstack_network: default diff --git a/spec/acceptance/nodesets/ubuntu-15.04.yml b/spec/acceptance/nodesets/ubuntu-15.04.yml deleted file mode 100644 index 5e20aa5..0000000 --- a/spec/acceptance/nodesets/ubuntu-15.04.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -HOSTS: - ubuntu-1504-x64: - default_apply_opts: - order: random - strict_variables: - platform: ubuntu-15.04-amd64 - hypervisor: docker - image: ubuntu:15.04 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get install -y net-tools wget' - - 'locale-gen en_US.UTF-8' -CONFIG: - type: aio - log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-15.10.yml b/spec/acceptance/nodesets/ubuntu-15.10.yml deleted file mode 100644 index 7551cdd..0000000 --- a/spec/acceptance/nodesets/ubuntu-15.10.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -HOSTS: - ubuntu-1510-x64: - default_apply_opts: - order: random - strict_variables: - platform: ubuntu-15.10-amd64 - hypervisor: docker - image: ubuntu:15.10 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get install -y net-tools wget' - - 'locale-gen en_US.UTF-8' -CONFIG: - type: aio - log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-16.04.yml b/spec/acceptance/nodesets/ubuntu-16.04.yml deleted file mode 100644 index 73fbdff..0000000 --- a/spec/acceptance/nodesets/ubuntu-16.04.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -HOSTS: - ubuntu-1604-x64: - default_apply_opts: - order: random - strict_variables: - platform: ubuntu-16.04-amd64 - hypervisor: docker - image: ubuntu:16.04 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get install -y net-tools wget' - - 'locale-gen en_US.UTF-8' -CONFIG: - type: aio - log_level: debug diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb new file mode 100644 index 0000000..2681792 --- /dev/null +++ b/spec/spec_helper_acceptance.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +require 'voxpupuli/acceptance/spec_helper_acceptance' + +configure_beaker(modules: :metadata) + +Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f } From fd682e23e3cba82bb7d3c0100868b1ee4fe30644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Wed, 7 Aug 2024 07:34:14 +0200 Subject: [PATCH 11/15] Prefer structured facts to legacy ones --- manifests/params.pp | 2 +- spec/classes/augeas_spec.rb | 2 +- spec/defines/augeas_lens_spec.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index a7e6ff7..5a88308 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -52,7 +52,7 @@ if (versioncmp($facts['puppetversion'], '4.0.0') >= 0) and ($facts['ruby']['sitedir'] =~ /\/opt\/puppetlabs\/puppet/) { $lens_dir = '/opt/puppetlabs/puppet/share/augeas/lenses' - } elsif ('$is_pe' in $facts and str2bool("${facts['is_pe']}")) { # lint:ignore:only_variable_string + } elsif ('is_pe' in $facts and str2bool("${facts['is_pe']}")) { # lint:ignore:only_variable_string # puppet enterpise has a different lens location $lens_dir = '/opt/puppet/share/augeas/lenses' } else { diff --git a/spec/classes/augeas_spec.rb b/spec/classes/augeas_spec.rb index 0c39736..8128d0a 100644 --- a/spec/classes/augeas_spec.rb +++ b/spec/classes/augeas_spec.rb @@ -4,7 +4,7 @@ describe 'augeas' do let(:lens_dir) do - if (Puppet.version >= '4.0.0') && facts[:rubysitedir] =~ (%r{/opt/puppetlabs/puppet}) + if (Puppet.version >= '4.0.0') && facts[:ruby]['sitedir'] =~ (%r{/opt/puppetlabs/puppet}) '/opt/puppetlabs/puppet/share/augeas/lenses' else '/usr/share/augeas/lenses' diff --git a/spec/defines/augeas_lens_spec.rb b/spec/defines/augeas_lens_spec.rb index c40de02..5ce6629 100644 --- a/spec/defines/augeas_lens_spec.rb +++ b/spec/defines/augeas_lens_spec.rb @@ -6,7 +6,7 @@ let(:title) { 'foo' } let(:lens_dir) do - if (Puppet.version >= '4.0.0') && facts[:rubysitedir] =~ (%r{/opt/puppetlabs/puppet}) + if (Puppet.version >= '4.0.0') && facts[:ruby]['sitedir'] =~ (%r{/opt/puppetlabs/puppet}) '/opt/puppetlabs/puppet/share/augeas/lenses' else '/usr/share/augeas/lenses' From ec800535f6ab8b641763a9fea898413e06be70d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Wed, 7 Aug 2024 07:37:12 +0200 Subject: [PATCH 12/15] Add missing dependency for str2bool --- metadata.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index d456f6a..7759e7e 100644 --- a/metadata.json +++ b/metadata.json @@ -10,7 +10,11 @@ "dependencies": [ { "name": "puppetlabs/augeas_core", - "version_requirement": ">=1.0.0 <2.0.0" + "version_requirement": ">= 1.0.0 < 2.0.0" + }, + { + "name": "puppetlabs/stdlib", + "version_requirement": ">= 2.3.0 < 10.0.0" } ], "operatingsystem_support": [ From c68d69c1ef2c6c34826b352f513dfa674d450476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Wed, 7 Aug 2024 08:22:58 +0200 Subject: [PATCH 13/15] Rework the way lens_dir is retrieved While AIO Puppet has a well-known path to augeas lenses, non-AIO Puppet use a sysstem path that is OS-dependant. Rework the way this path is retrieved so that we can extand this easily using Hiera. --- .fixtures.yml | 2 +- data/common.yaml | 4 ++++ data/os/Archlinux.yaml | 2 ++ data/os/FreeBSD.yaml | 2 ++ functions/lens_dir.pp | 14 ++++++++++++++ manifests/files.pp | 2 +- manifests/init.pp | 5 ++++- manifests/lens.pp | 12 ++++++------ manifests/params.pp | 9 --------- metadata.json | 2 +- spec/classes/augeas_spec.rb | 13 ++++++++++--- spec/defines/augeas_lens_spec.rb | 13 ++++++++++--- 12 files changed, 55 insertions(+), 25 deletions(-) create mode 100644 data/common.yaml create mode 100644 data/os/Archlinux.yaml create mode 100644 functions/lens_dir.pp diff --git a/.fixtures.yml b/.fixtures.yml index 38f04dc..77b77c5 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -5,4 +5,4 @@ fixtures: forge_modules: augeas_core: "puppetlabs/augeas_core" -# stdlib: "puppetlabs/stdlib" + stdlib: "puppetlabs/stdlib" diff --git a/data/common.yaml b/data/common.yaml new file mode 100644 index 0000000..e232924 --- /dev/null +++ b/data/common.yaml @@ -0,0 +1,4 @@ +--- +augeas::aio_lens_dir: /opt/puppetlabs/puppet/share/augeas/lenses +augeas::pe_lens_dir: /opt/puppet/share/augeas/lenses +augeas::system_lens_dir: /usr/share/augeas/lenses diff --git a/data/os/Archlinux.yaml b/data/os/Archlinux.yaml new file mode 100644 index 0000000..00dcc09 --- /dev/null +++ b/data/os/Archlinux.yaml @@ -0,0 +1,2 @@ +--- +augeas::pe_lens_dir: /usr/share/augeas/lenses diff --git a/data/os/FreeBSD.yaml b/data/os/FreeBSD.yaml index b0c5b5e..3c6cd57 100644 --- a/data/os/FreeBSD.yaml +++ b/data/os/FreeBSD.yaml @@ -1,2 +1,4 @@ --- augeas::files_group: "wheel" +augeas::pe_lens_dir: /usr/local/share/augeas/lenses +augeas::system_lens_dir: /usr/local/share/augeas/lenses diff --git a/functions/lens_dir.pp b/functions/lens_dir.pp new file mode 100644 index 0000000..aa89ba2 --- /dev/null +++ b/functions/lens_dir.pp @@ -0,0 +1,14 @@ +# @summary function to return augeas lens directory +# +# @return [String] +function augeas::lens_dir() >> String { + if $augeas::lens_dir { + $augeas::lens_dir + } elsif versioncmp($facts['puppetversion'], '4.0.0') >= 0 and 'aio_agent_version' in $facts { + $augeas::aio_lens_dir + } elsif 'is_pe' in $facts and $facts['is_pe'] { + $augeas::pe_lens_dir + } else { + $augeas::system_lens_dir + } +} diff --git a/manifests/files.pp b/manifests/files.pp index d2cfb23..05a08de 100644 --- a/manifests/files.pp +++ b/manifests/files.pp @@ -5,7 +5,7 @@ class augeas::files { include augeas - $lens_dir = $augeas::lens_dir + $lens_dir = augeas::lens_dir() # ensure no file not managed by puppet ends up in there. file { $lens_dir: diff --git a/manifests/init.pp b/manifests/init.pp index a819469..8dfd77b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -9,12 +9,15 @@ # ['lens_dir'] - the lens directory to use # ['purge'] - whether to purge lens directories class augeas ( + Stdlib::Absolutepath $aio_lens_dir, + Stdlib::Absolutepath $pe_lens_dir, + Stdlib::Absolutepath $system_lens_dir, String $files_owner = 'root', String $files_group = 'root', $version = present, $ruby_package = $augeas::params::ruby_pkg, $ruby_version = present, - $lens_dir = $augeas::params::lens_dir, + Optional[Stdlib::Absolutepath] $lens_dir = undef, $purge = true, ) inherits augeas::params { if versioncmp($facts['puppetversion'], '4.0.0') >= 0 { diff --git a/manifests/lens.pp b/manifests/lens.pp index f6d88c7..604ac63 100644 --- a/manifests/lens.pp +++ b/manifests/lens.pp @@ -58,13 +58,13 @@ mode => '0644', } - if (!$stock_since or versioncmp(String($facts['augeas']['version']), $stock_since) < 0) { - assert_type(Pattern[/^\/.*/], $augeas::lens_dir) + $lens_dir = augeas::lens_dir() + if (!$stock_since or versioncmp(String($facts['augeas']['version']), $stock_since) < 0) { $lens_name = "${name}.aug" - $lens_dest = "${augeas::lens_dir}/${lens_name}" + $lens_dest = "${lens_dir}/${lens_name}" $test_name = "tests/test_${name}.aug" - $test_dest = "${augeas::lens_dir}/${test_name}" + $test_dest = "${lens_dir}/${test_name}" # lint:ignore:source_without_rights file { $lens_dest: @@ -76,7 +76,7 @@ exec { "Typecheck lens ${name}": command => "augparse -I . ${lens_name} || (rm -f ${lens_name} && exit 1)", - cwd => $augeas::lens_dir, + cwd => $lens_dir, path => "/opt/puppetlabs/puppet/bin:${facts['path']}", refreshonly => true, subscribe => File[$lens_dest], @@ -94,7 +94,7 @@ exec { "Test lens ${name}": command => "augparse -I . ${test_name} || (rm -f ${lens_name} && rm -f ${test_name}.aug && exit 1)", - cwd => $augeas::lens_dir, + cwd => $lens_dir, path => "/opt/puppetlabs/puppet/bin:${facts['path']}", refreshonly => true, subscribe => File[$lens_dest, $test_dest], diff --git a/manifests/params.pp b/manifests/params.pp index 5a88308..4fb1f4a 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -49,13 +49,4 @@ default: { fail("Unsupported OS family: ${facts['os']['family']}") } } - - if (versioncmp($facts['puppetversion'], '4.0.0') >= 0) and ($facts['ruby']['sitedir'] =~ /\/opt\/puppetlabs\/puppet/) { - $lens_dir = '/opt/puppetlabs/puppet/share/augeas/lenses' - } elsif ('is_pe' in $facts and str2bool("${facts['is_pe']}")) { # lint:ignore:only_variable_string - # puppet enterpise has a different lens location - $lens_dir = '/opt/puppet/share/augeas/lenses' - } else { - $lens_dir = '/usr/share/augeas/lenses' - } } diff --git a/metadata.json b/metadata.json index 7759e7e..e039628 100644 --- a/metadata.json +++ b/metadata.json @@ -14,7 +14,7 @@ }, { "name": "puppetlabs/stdlib", - "version_requirement": ">= 2.3.0 < 10.0.0" + "version_requirement": ">= 4.13.0 < 10.0.0" } ], "operatingsystem_support": [ diff --git a/spec/classes/augeas_spec.rb b/spec/classes/augeas_spec.rb index 8128d0a..e8f1175 100644 --- a/spec/classes/augeas_spec.rb +++ b/spec/classes/augeas_spec.rb @@ -4,10 +4,17 @@ describe 'augeas' do let(:lens_dir) do - if (Puppet.version >= '4.0.0') && facts[:ruby]['sitedir'] =~ (%r{/opt/puppetlabs/puppet}) - '/opt/puppetlabs/puppet/share/augeas/lenses' - else + case facts[:os]['family'] + when 'FreeBSD' + '/usr/local/share/augeas/lenses' + when 'Archlinux' '/usr/share/augeas/lenses' + else + if (Puppet.version >= '4.0.0') && facts[:ruby]['sitedir'] =~ (%r{/opt/puppetlabs/puppet}) + '/opt/puppetlabs/puppet/share/augeas/lenses' + else + '/usr/share/augeas/lenses' + end end end diff --git a/spec/defines/augeas_lens_spec.rb b/spec/defines/augeas_lens_spec.rb index 5ce6629..38532bd 100644 --- a/spec/defines/augeas_lens_spec.rb +++ b/spec/defines/augeas_lens_spec.rb @@ -6,10 +6,17 @@ let(:title) { 'foo' } let(:lens_dir) do - if (Puppet.version >= '4.0.0') && facts[:ruby]['sitedir'] =~ (%r{/opt/puppetlabs/puppet}) - '/opt/puppetlabs/puppet/share/augeas/lenses' - else + case facts[:os]['family'] + when 'FreeBSD' + '/usr/local/share/augeas/lenses' + when 'Archlinux' '/usr/share/augeas/lenses' + else + if (Puppet.version >= '4.0.0') && facts[:ruby]['sitedir'] =~ (%r{/opt/puppetlabs/puppet}) + '/opt/puppetlabs/puppet/share/augeas/lenses' + else + '/usr/share/augeas/lenses' + end end end From f6974ed953fef63dfad74f6e0be3723266176867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Tue, 20 Aug 2024 14:08:47 +0200 Subject: [PATCH 14/15] Drop support for EOL Puppet Puppet 7 and Puppet 8 are the currently supported versions of Puppet. Older versions have reached EOL and are not used in CI, so do not pretend the module work with them as it is now untested. --- manifests/init.pp | 18 +-- manifests/packages.pp | 14 --- manifests/params.pp | 52 --------- metadata.json | 2 +- spec/classes/augeas_spec.rb | 184 +------------------------------ spec/defines/augeas_lens_spec.rb | 2 +- 6 files changed, 8 insertions(+), 264 deletions(-) delete mode 100644 manifests/packages.pp delete mode 100644 manifests/params.pp diff --git a/manifests/init.pp b/manifests/init.pp index 8dfd77b..033fa02 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -3,9 +3,6 @@ # Install and configure Augeas # # Parameters: -# ['version'] - the desired version of Augeas -# ['ruby_package'] - the desired package name of the Ruby bindings for Augeas -# ['ruby_version'] - the desired version of the Ruby bindings for Augeas # ['lens_dir'] - the lens directory to use # ['purge'] - whether to purge lens directories class augeas ( @@ -14,19 +11,8 @@ Stdlib::Absolutepath $system_lens_dir, String $files_owner = 'root', String $files_group = 'root', - $version = present, - $ruby_package = $augeas::params::ruby_pkg, - $ruby_version = present, Optional[Stdlib::Absolutepath] $lens_dir = undef, $purge = true, -) inherits augeas::params { - if versioncmp($facts['puppetversion'], '4.0.0') >= 0 { - contain 'augeas::files' - } else { - contain 'augeas::packages' - contain 'augeas::files' - Class['augeas::packages'] -> Class['augeas::files'] - - Package['ruby-augeas', $augeas::params::augeas_pkgs] -> Augeas <| |> # lint:ignore:spaceship_operator_without_tag - } +) { + contain 'augeas::files' } diff --git a/manifests/packages.pp b/manifests/packages.pp deleted file mode 100644 index 1cc50ef..0000000 --- a/manifests/packages.pp +++ /dev/null @@ -1,14 +0,0 @@ -# Class: augeas::packages -# -# Sets up packages for Augeas -# -class augeas::packages { - package { $augeas::params::augeas_pkgs: - ensure => $augeas::version, - } - - package { 'ruby-augeas': - ensure => $augeas::ruby_version, - name => $augeas::ruby_package, - } -} diff --git a/manifests/params.pp b/manifests/params.pp deleted file mode 100644 index 4fb1f4a..0000000 --- a/manifests/params.pp +++ /dev/null @@ -1,52 +0,0 @@ -# Class: augeas::params -# -# Default parameters for the Augeas module -# -class augeas::params { - case $facts['os']['family'] { - 'RedHat': { - $ruby_pkg = $facts['os']['name'] ? { - # Amazon Linux AMI (2014.09 and 2015.03) uses ruby 2.0 - 'Amazon' => 'ruby20-augeas', - default => 'ruby-augeas' - } - $augeas_pkgs = ['augeas', 'augeas-libs'] - } - - 'Suse': { - # RPM Sources: https://build.opensuse.org/project/show/systemsmanagement:puppet - if versioncmp($facts['ruby']['version'], '2.1.2') >= 0 { - # SLES 12 / openSUSE - $ruby_pkg = 'ruby2.1-rubygem-ruby-augeas' - } else { - # SLES 11 SP3 - $ruby_pkg = 'ruby1.8-rubygem-ruby-augeas' - } - $augeas_pkgs = ['augeas', 'augeas-lenses', 'libaugeas0'] - } - - 'Debian': { - if versioncmp($facts['ruby']['version'], '2.1.0') >= 0 { - $ruby_pkg = 'ruby-augeas' - } - elsif versioncmp($facts['ruby']['version'], '1.9.1') >= 0 { - $ruby_pkg = 'libaugeas-ruby1.9.1' - } else { - $ruby_pkg = 'libaugeas-ruby1.8' - } - $augeas_pkgs = ['augeas-lenses', 'libaugeas0', 'augeas-tools'] - } - - 'Archlinux': { - $ruby_pkg = 'ruby-augeas' - $augeas_pkgs = ['augeas'] - } - - 'FreeBSD': { - $ruby_pkg = 'rubygem-ruby-augeas' - $augeas_pkgs = ['augeas'] - } - - default: { fail("Unsupported OS family: ${facts['os']['family']}") } - } -} diff --git a/metadata.json b/metadata.json index e039628..395ad58 100644 --- a/metadata.json +++ b/metadata.json @@ -68,7 +68,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 4.10.0 < 9.0.0" + "version_requirement": ">= 7.0.0 < 9.0.0" } ], "description": "Augeas Module for Puppet", diff --git a/spec/classes/augeas_spec.rb b/spec/classes/augeas_spec.rb index e8f1175..f31d6b3 100644 --- a/spec/classes/augeas_spec.rb +++ b/spec/classes/augeas_spec.rb @@ -10,7 +10,7 @@ when 'Archlinux' '/usr/share/augeas/lenses' else - if (Puppet.version >= '4.0.0') && facts[:ruby]['sitedir'] =~ (%r{/opt/puppetlabs/puppet}) + if facts[:ruby]['sitedir'] =~ %r{/opt/puppetlabs/puppet} '/opt/puppetlabs/puppet/share/augeas/lenses' else '/usr/share/augeas/lenses' @@ -18,19 +18,6 @@ end end - context 'when on an unsupported Operating System' do - let(:facts) do - { - osfamily: 'MS-DOS', - os: { family: 'MS-DOS' }, - } - end - - it 'fails' do - expect { is_expected.to compile }.to raise_error(%r{Unsupported OS family}) - end - end - on_supported_os.each do |os, facts| context "on #{os}" do let(:facts) do @@ -38,78 +25,6 @@ end context 'without params' do - if Puppet.version < '4.0.0' - case facts[:osfamily] - when 'Debian' - it { - is_expected.to contain_package('libaugeas0').with( - ensure: 'present' - ) - } - - it { - is_expected.to contain_package('augeas-tools').with( - ensure: 'present' - ) - } - - it { - is_expected.to contain_package('augeas-lenses').with( - ensure: 'present' - ) - } - - case facts[:lsbdistcodename] - when 'squeeze', 'lucid', 'precise' - let(:facts) do - facts.merge({ - ruby: { version: '1.8.7' }, - rubyversion: '1.8.7' - }) - end - - it { - is_expected.to contain_package('ruby-augeas').with( - ensure: 'present', - name: 'libaugeas-ruby1.8' - ) - } - else - let(:facts) do - facts.merge({ - ruby: { version: '1.9.3' }, - rubyversion: '1.9.3' - }) - end - - it { - is_expected.to contain_package('ruby-augeas').with( - ensure: 'present', - name: 'libaugeas-ruby1.9.1' - ) - } - end - when 'RedHat' - it { - is_expected.to contain_package('augeas').with( - ensure: 'present' - ) - } - - it { - is_expected.to contain_package('augeas-libs').with( - ensure: 'present' - ) - } - - it { - is_expected.to contain_package('ruby-augeas').with( - ensure: 'present', - name: 'ruby-augeas' - ) - } - end - end it { is_expected.to contain_file(lens_dir).with( ensure: 'directory', @@ -136,88 +51,6 @@ } end - context 'when versions are specified' do - let(:params) do - { - version: '1.2.3', - ruby_version: '3.2.1', - } - end - - if Puppet.version < '4.0.0' - case facts[:osfamily] - when 'Debian' - it { - is_expected.to contain_package('libaugeas0').with( - ensure: '1.2.3' - ) - } - - it { - is_expected.to contain_package('augeas-tools').with( - ensure: '1.2.3' - ) - } - - it { - is_expected.to contain_package('augeas-lenses').with( - ensure: '1.2.3' - ) - } - - case facts[:lsbdistcodename] - when 'squeeze', 'lucid', 'precise' - let(:facts) do - facts.merge({ - ruby: { version: '1.8.7' }, - rubyversion: '1.8.7' - }) - end - - it { - is_expected.to contain_package('ruby-augeas').with( - ensure: '3.2.1', - name: 'libaugeas-ruby1.8' - ) - } - else - let(:facts) do - facts.merge({ - ruby: { version: '1.9.3' }, - rubyversion: '1.9.3' - }) - end - - it { - is_expected.to contain_package('ruby-augeas').with( - ensure: '3.2.1', - name: 'libaugeas-ruby1.9.1' - ) - } - end - when 'RedHat' - it { - is_expected.to contain_package('augeas').with( - ensure: '1.2.3' - ) - } - - it { - is_expected.to contain_package('augeas-libs').with( - ensure: '1.2.3' - ) - } - - it { - is_expected.to contain_package('ruby-augeas').with( - ensure: '3.2.1', - name: 'ruby-augeas' - ) - } - end - end - end - context 'with a non standard lens_dir' do let(:params) do { @@ -256,17 +89,8 @@ facts.merge(is_pe: true) end - let(:pe_lens_dir) do - if Puppet::Util::Package.versioncmp(Puppet.version, '4.0.0') >= 0 - # the enterprise lens dir is the same in 4 - lens_dir - else - '/opt/puppet/share/augeas/lenses' - end - end - it { - is_expected.to contain_file(pe_lens_dir).with( + is_expected.to contain_file(lens_dir).with( ensure: 'directory', force: 'true', recurse: 'true', @@ -275,14 +99,14 @@ } it { - is_expected.to contain_file("#{pe_lens_dir}/dist").with( + is_expected.to contain_file("#{lens_dir}/dist").with( ensure: 'directory', purge: 'false' ) } it { - is_expected.to contain_file("#{pe_lens_dir}/tests").with( + is_expected.to contain_file("#{lens_dir}/tests").with( ensure: 'directory', force: 'true', purge: 'true' diff --git a/spec/defines/augeas_lens_spec.rb b/spec/defines/augeas_lens_spec.rb index 38532bd..bc0efe0 100644 --- a/spec/defines/augeas_lens_spec.rb +++ b/spec/defines/augeas_lens_spec.rb @@ -12,7 +12,7 @@ when 'Archlinux' '/usr/share/augeas/lenses' else - if (Puppet.version >= '4.0.0') && facts[:ruby]['sitedir'] =~ (%r{/opt/puppetlabs/puppet}) + if facts[:ruby]['sitedir'] =~ %r{/opt/puppetlabs/puppet} '/opt/puppetlabs/puppet/share/augeas/lenses' else '/usr/share/augeas/lenses' From 8d147695cc18c562a760f3bcb42467527081d44a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Tue, 20 Aug 2024 14:21:09 +0200 Subject: [PATCH 15/15] Add missing data type --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 033fa02..1555158 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -12,7 +12,7 @@ String $files_owner = 'root', String $files_group = 'root', Optional[Stdlib::Absolutepath] $lens_dir = undef, - $purge = true, + Boolean $purge = true, ) { contain 'augeas::files' }