From 932f8b05966e0cf08dca35e2ff49a7c0f1d8e596 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 2 Dec 2021 13:48:21 +0100 Subject: [PATCH 01/15] modulesync 5.1.0 --- .editorconfig | 15 ++ .github/CONTRIBUTING.md | 252 +++++++++++++++++++++++++++++++ .github/ISSUE_TEMPLATE.md | 26 ++++ .github/PULL_REQUEST_TEMPLATE.md | 20 +++ .github/SECURITY.md | 3 + .github/workflows/ci.yml | 66 ++++++++ .github/workflows/release.yml | 34 +++++ .gitignore | 49 +++--- .msync.yml | 5 + .overcommit.yml | 65 ++++++++ .pmtignore | 37 +++++ .puppet-lint.rc | 3 + .rspec | 5 + .rspec_parallel | 4 + .rubocop.yml | 6 + .travis.yml | 36 ----- Dockerfile | 24 +++ Gemfile | 76 ++++------ Rakefile | 92 ++++++++--- spec/spec_helper.rb | 58 ++----- 20 files changed, 694 insertions(+), 182 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/SECURITY.md create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml create mode 100644 .msync.yml create mode 100644 .overcommit.yml create mode 100644 .pmtignore create mode 100644 .puppet-lint.rc create mode 100644 .rspec create mode 100644 .rspec_parallel create mode 100644 .rubocop.yml delete mode 100644 .travis.yml create mode 100644 Dockerfile 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..048d2b5 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,252 @@ +# 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_VERSION="~> 5.5.6" +``` + +You can install all needed gems for spec tests into the modules directory by +running: + +```sh +bundle install --path .vendor/ --without development system_tests release --jobs "$(nproc)" +``` + +If you also want to run acceptance tests: + +```sh +bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)" +``` + +Our all in one solution if you don't know if you need to install or update gems: + +```sh +bundle install --path .vendor/ --with system_tests --without development release --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_setfile=debian10-x64 bundle exec rake beaker +``` + +You can replace the string `debian10` with any common operating system. +The following strings are known to work: + +* ubuntu1604 +* ubuntu1804 +* ubuntu2004 +* debian9 +* debian10 +* centos7 +* centos8 + +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/SECURITY.md b/.github/SECURITY.md new file mode 100644 index 0000000..cacadf2 --- /dev/null +++ b/.github/SECURITY.md @@ -0,0 +1,3 @@ +# Vox Pupuli Security Policy + +Our vulnerabilities reporting process is at https://voxpupuli.org/security/ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c5dad05 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,66 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: CI + +on: pull_request + +concurrency: + group: ${{ github.head_ref }} + cancel-in-progress: true + +jobs: + setup_matrix: + name: 'Setup Test Matrix' + runs-on: ubuntu-latest + timeout-minutes: 40 + outputs: + puppet_unit_test_matrix: ${{ steps.get-outputs.outputs.puppet_unit_test_matrix }} + github_action_test_matrix: ${{ steps.get-outputs.outputs.github_action_test_matrix }} + env: + BUNDLE_WITHOUT: development:system_tests:release + steps: + - uses: actions/checkout@v2 + - name: Setup ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.0' + bundler-cache: true + - name: Run static validations + run: bundle exec rake validate lint check + - name: Run rake rubocop + run: bundle exec rake rubocop + - name: Setup Test Matrix + id: get-outputs + run: bundle exec metadata2gha --use-fqdn --pidfile-workaround false + + unit: + needs: setup_matrix + runs-on: ubuntu-latest + timeout-minutes: 40 + strategy: + fail-fast: false + matrix: + include: ${{fromJson(needs.setup_matrix.outputs.puppet_unit_test_matrix)}} + env: + BUNDLE_WITHOUT: development:system_tests:release + PUPPET_VERSION: "~> ${{ matrix.puppet }}.0" + name: Puppet ${{ matrix.puppet }} (Ruby ${{ matrix.ruby }}) + steps: + - uses: actions/checkout@v2 + - name: Setup ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - name: Run tests + run: bundle exec rake parallel_spec + + tests: + needs: + - unit + runs-on: ubuntu-latest + name: Test suite + steps: + - run: echo Test suite completed diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..664ba69 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: Release + +on: + push: + tags: + - '*' + +env: + BUNDLE_WITHOUT: development:test:system_tests + +jobs: + deploy: + name: 'deploy to forge' + runs-on: ubuntu-latest + if: github.repository_owner == 'voxpupuli' + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '2.7' + bundler-cache: true + - name: Build and Deploy + env: + # Configure secrets here: + # https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets + BLACKSMITH_FORGE_USERNAME: '${{ secrets.PUPPET_FORGE_USERNAME }}' + BLACKSMITH_FORGE_API_KEY: '${{ secrets.PUPPET_FORGE_API_KEY }}' + run: bundle exec rake module:push diff --git a/.gitignore b/.gitignore index 94145ab..9b95224 100644 --- a/.gitignore +++ b/.gitignore @@ -1,32 +1,23 @@ -pkg -coverage +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +pkg/ +Gemfile.lock +Gemfile.local +vendor/ +.vendor/ +spec/fixtures/manifests/ +spec/fixtures/modules/ +.vagrant/ .bundle/ +.ruby-version +coverage/ +log/ +.idea/ +.dependencies/ .librarian/ -.tmp/ -modules/ -_site/ -spec/fixtures/manifests -spec/fixtures/modules -yardoc/ +Puppetfile.lock +*.iml +.*.sw? .yardoc/ - -## Ruby -.rvmrc* -.rbenv* -.ruby-* - -## MAC OS -.DS_Store - -## TEXTMATE -*.tmproj -tmtags - -## EMACS -*~ -\#* -.\#* - -## VIM -*.swp -tags +Guardfile diff --git a/.msync.yml b/.msync.yml new file mode 100644 index 0000000..a83abd9 --- /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: '5.1.0' diff --git a/.overcommit.yml b/.overcommit.yml new file mode 100644 index 0000000..d367ada --- /dev/null +++ b/.overcommit.yml @@ -0,0 +1,65 @@ +# 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'] + PuppetLint: + enabled: true + description: 'Runs puppet-lint on modified files only' + command: ['bundle', 'exec', 'puppet-lint'] + 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/.pmtignore b/.pmtignore new file mode 100644 index 0000000..65f5051 --- /dev/null +++ b/.pmtignore @@ -0,0 +1,37 @@ +# 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 diff --git a/.puppet-lint.rc b/.puppet-lint.rc new file mode 100644 index 0000000..dd8272c --- /dev/null +++ b/.puppet-lint.rc @@ -0,0 +1,3 @@ +--fail-on-warnings +--no-parameter_documentation-check +--no-parameter_types-check diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..f634583 --- /dev/null +++ b/.rspec @@ -0,0 +1,5 @@ +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +--format documentation +--color diff --git a/.rspec_parallel b/.rspec_parallel new file mode 100644 index 0000000..a9a84f8 --- /dev/null +++ b/.rspec_parallel @@ -0,0 +1,4 @@ +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +--format progress diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..53ac189 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,6 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +inherit_gem: + voxpupuli-test: rubocop.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a06e9a0..0000000 --- a/.travis.yml +++ /dev/null @@ -1,36 +0,0 @@ -language: ruby -sudo: required -rvm: - - 2.4.4 -notifications: - email: - - raphael.pinson@camptocamp.com -env: -# base env - # Test latest Puppet 5 version - - PUPPET=5.5 RUBY_AUGEAS=0.5 FORGE_PUBLISH=true - # Test latest Puppet version - - PUPPET=6 RUBY_AUGEAS=0.5 - - -matrix: - fast_finish: true - -install: - - "travis_retry ./.travis.sh" -script: - - AUGEAS_LENS_LIB=lib/augeas/lenses:augeas/lenses bundle exec rake - # Do not include the augeas/ directory in the deployed module - - rm -rf augeas/ -deploy: - provider: puppetforge - user: herculesteam - password: - secure: "RLs24P20I18PvFHgYbOieTGUEwJzhbQFF4fWgpJSf7iM2Q0bxhNQnUdzDXfLMfRwQ/lQGZSQ6eZ5sr/MdzI/qIT13zHM/B+Fv+ZszE/nNZzVTpjhI6vStQrUAZlD76Tx/QJN5bvu0QjFjGyK9DY26FVHqWcYvDHg0L2sQ269uFU=" - on: - tags: true - # all_branches is required to use tags - all_branches: true - # Only publish if our main Ruby target builds - rvm: 2.4.4 - condition: "$FORGE_PUBLISH = true" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e3cf307 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +# MANAGED BY MODULESYNC +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +FROM ruby:2.7 + +WORKDIR /opt/puppet + +# https://github.com/puppetlabs/puppet/blob/06ad255754a38f22fb3a22c7c4f1e2ce453d01cb/lib/puppet/provider/service/runit.rb#L39 +RUN mkdir -p /etc/sv + +ARG PUPPET_VERSION="~> 6.0" +ARG PARALLEL_TEST_PROCESSORS=4 + +# Cache gems +COPY Gemfile . +RUN bundle install --without system_tests development release --path=${BUNDLE_PATH:-vendor/bundle} + +COPY . . + +RUN bundle install +RUN bundle exec rake release_checks + +# Container should not saved +RUN exit 1 diff --git a/Gemfile b/Gemfile index 7c75c8b..b6dcf45 100644 --- a/Gemfile +++ b/Gemfile @@ -1,50 +1,34 @@ -source 'https://rubygems.org' +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -if ENV.key?('PUPPET') - puppetversion = "~> #{ENV['PUPPET']}" -else - puppetversion = ['>= 2.7'] +source ENV['GEM_SOURCE'] || "https://rubygems.org" + +group :test do + gem 'voxpupuli-test', '~> 5.0', :require => false + gem 'coveralls', :require => false + gem 'simplecov-console', :require => false + gem 'puppet_metadata', '~> 1.0', :require => false +end + +group :development do + gem 'guard-rake', :require => false + gem 'overcommit', '>= 0.39.1', :require => false end -gem 'puppet', puppetversion - -if ENV.key?('RUBY_AUGEAS') - if ENV['RUBY_AUGEAS'] == '0.3.0' - # pre-0.4.1 versions aren't available on rubygems - rbaugversion = {:git => 'git://github.com/domcleal/ruby-augeas.git', :branch => '0.3.0-gem'} - else - rbaugversion = "~> #{ENV['RUBY_AUGEAS']}" - end -else - rbaugversion = ['~> 0.3'] + +group :system_tests do + gem 'voxpupuli-acceptance', '~> 1.0', :require => false end -gem 'ruby-augeas', rbaugversion - -group :development, :unit_tests do - gem 'rake', ' < 11.0', :require => false if RUBY_VERSION =~ /^1\.8/ - gem 'rspec', '< 3.2', :require => false if RUBY_VERSION =~ /^1\.8/ - gem 'json', '< 2.0', :require => false if RUBY_VERSION =~ /^1\.[89]/ - gem 'json_pure', '< 2.0', :require => false if RUBY_VERSION =~ /^1\.[89]/ - gem 'rspec-puppet', :require => false - gem 'puppetlabs_spec_helper', :require => false - gem 'metadata-json-lint', :require => false - gem 'puppet-lint', :require => false - gem 'puppet-lint-unquoted_string-check', :require => false - gem 'puppet-lint-empty_string-check', :require => false - gem 'puppet-lint-spaceship_operator_without_tag-check', :require => false - gem 'puppet-lint-variable_contains_upcase', :require => false - gem 'puppet-lint-absolute_classname-check', :require => false - gem 'puppet-lint-undef_in_function-check', :require => false - gem 'puppet-lint-leading_zero-check', :require => false - gem 'puppet-lint-trailing_comma-check', :require => false - gem 'puppet-lint-file_ensure-check', :require => false - gem 'puppet-lint-version_comparison-check', :require => false - gem 'rspec-puppet-facts', :require => false - - gem 'coveralls', :require => false unless RUBY_VERSION =~ /^1\.8/ - gem 'simplecov', '~> 0.7.0', :require => false - gem 'yard', :require => false - gem 'redcarpet', '~> 2.0', :require => false - - # mime-types-data requires Ruby version >= 2.0 - gem 'mime-types', '2.6.2' if RUBY_VERSION =~ /^1\.9/ + +group :release do + gem 'github_changelog_generator', '>= 1.16.1', :require => false if RUBY_VERSION >= '2.5' + gem 'voxpupuli-release', '>= 1.2.0', :require => false + gem 'puppet-strings', '>= 2.2', :require => false end + +gem 'rake', :require => false +gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test] + +puppetversion = ENV['PUPPET_VERSION'] || '>= 6.0' +gem 'puppet', puppetversion, :require => false, :groups => [:test] + +# vim: syntax=ruby diff --git a/Rakefile b/Rakefile index 8490143..f92f051 100644 --- a/Rakefile +++ b/Rakefile @@ -1,30 +1,72 @@ -require 'rubygems' -require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet-syntax/tasks/puppet-syntax' -require 'puppet-lint/tasks/puppet-lint' -require 'yard' - -exclude_paths = [ - "pkg/**/*", - "vendor/**/*", - "spec/**/*", -] - -task :default => [:spec, :yard, :syntax, :lint] - -desc "Run acceptance tests" -RSpec::Core::RakeTask.new(:acceptance) do |t| - t.pattern = 'spec/acceptance' +# 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 end -YARD::Rake::YardocTask.new do |t| - t.options = [] +# load optional tasks for acceptance +# only available if gem group releases is installed +begin + require 'voxpupuli/acceptance/rake' +rescue LoadError end -# Disable puppet-lint checks -PuppetLint.configuration.send("disable_80chars") -PuppetLint.configuration.send("disable_class_inherits_from_params_class") +# load optional tasks for releases +# only available if gem group releases is installed +begin + require 'voxpupuli/release/rake_tasks' +rescue LoadError +end -# Ignore files outside this module -PuppetLint.configuration.ignore_paths = exclude_paths -PuppetSyntax.exclude_paths = exclude_paths +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 + +desc 'Generate REFERENCE.md' +task :reference, [:debug, :backtrace] do |t, args| + patterns = '' + Rake::Task['strings:generate:reference'].invoke(patterns, args[:debug], args[:backtrace]) +end + +begin + require 'github_changelog_generator/task' + require 'puppet_blacksmith' + GitHubChangelogGenerator::RakeTask.new :changelog do |config| + metadata = Blacksmith::Modulefile.new + config.future_release = "v#{metadata.version}" if metadata.version =~ /^\d+\.\d+.\d+$/ + config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module." + config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog} + config.user = 'voxpupuli' + config.project = metadata.metadata['name'] + end + + # Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715 + require 'rbconfig' + if RbConfig::CONFIG['host_os'] =~ /linux/ + task :changelog do + puts 'Fixing line endings...' + changelog_file = File.join(__dir__, 'CHANGELOG.md') + changelog_txt = File.read(changelog_file) + new_contents = changelog_txt.gsub(%r{\r\n}, "\n") + File.open(changelog_file, "w") {|file| file.puts new_contents } + end + end + +rescue LoadError +end +# vim: syntax=ruby diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b5aa0c4..4d617f3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,51 +1,17 @@ -require 'pathname' -dir = Pathname.new(__FILE__).parent -$LOAD_PATH.unshift(dir, File.join(dir, 'fixtures/modules/augeasproviders_core/spec/lib'), File.join(dir, '..', 'lib')) +# frozen_string_literal: true -require 'rubygems' +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -require 'simplecov' -unless RUBY_VERSION =~ /^1\.8/ - require 'coveralls' - SimpleCov.formatter = Coveralls::SimpleCov::Formatter -end -SimpleCov.start do - add_group "Puppet Types", "/lib/puppet/type/" - add_group "Puppet Providers", "/lib/puppet/provider/" - - add_filter "/spec/fixtures/" - add_filter "/spec/unit/" - add_filter "/spec/support/" -end +# puppetlabs_spec_helper will set up coverage if the env variable is set. +# We want to do this if lib exists and it hasn't been explicitly set. +ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../lib', __dir__)) -require 'puppetlabs_spec_helper/module_spec_helper' -require 'augeas_spec' +require 'voxpupuli/test/spec_helper' -Puppet[:modulepath] = File.join(dir, 'fixtures', 'modules') - -# There's no real need to make this version dependent, but it helps find -# regressions in Puppet -# -# 1. Workaround for issue #16277 where default settings aren't initialised from -# a spec and so the libdir is never initialised (3.0.x) -# 2. Workaround for 2.7.20 that now only loads types for the current node -# environment (#13858) so Puppet[:modulepath] seems to get ignored -# 3. Workaround for 3.5 where context hasn't been configured yet, -# ticket https://tickets.puppetlabs.com/browse/MODULES-823 -# -ver = Gem::Version.new(Puppet.version.split('-').first) -if ver >= Gem::Version.new("2.7.20") - puts "augeasproviders: setting $LOAD_PATH to work around broken type autoloading" - Puppet.initialize_settings - $LOAD_PATH.unshift( - dir, - File.join(dir, 'fixtures/modules/augeasproviders_core/spec/lib'), - File.join(dir, 'fixtures/modules/augeasproviders_core/lib') - ) - - - $LOAD_PATH.unshift(File.join(dir, '..', 'lib')) +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 - -# Load all shared contexts and shared examples -Dir["#{dir}/support/**/*.rb"].sort.each {|f| require f} From fcc01ac7ade0a16f799b8454d94ab703f4452315 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 2 Dec 2021 13:55:45 +0100 Subject: [PATCH 02/15] delete .sync.yml --- .sync.yml | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .sync.yml diff --git a/.sync.yml b/.sync.yml deleted file mode 100644 index 9a785e7..0000000 --- a/.sync.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -.travis.yml: - forge_password: "RLs24P20I18PvFHgYbOieTGUEwJzhbQFF4fWgpJSf7iM2Q0bxhNQnUdzDXfLMfRwQ/lQGZSQ6eZ5sr/MdzI/qIT13zHM/B+Fv+ZszE/nNZzVTpjhI6vStQrUAZlD76Tx/QJN5bvu0QjFjGyK9DY26FVHqWcYvDHg0L2sQ269uFU=" From 1e0f063fbe015b7f2188afa8f2477e8be38bc930 Mon Sep 17 00:00:00 2001 From: Trevor Vaughan Date: Sun, 14 Aug 2022 18:27:56 -0400 Subject: [PATCH 03/15] Update from voxpupuli modulesync_config --- .github/CONTRIBUTING.md | 7 ++--- .github/workflows/ci.yml | 58 +++-------------------------------- .github/workflows/release.yml | 32 ++++++------------- .msync.yml | 2 +- Dockerfile | 2 +- Gemfile | 6 ++-- spec/spec_helper.rb | 2 ++ 7 files changed, 24 insertions(+), 85 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 048d2b5..8b466cf 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -124,7 +124,7 @@ If you have Ruby 2.x or want a specific version of Puppet, you must set an environment variable such as: ```sh -export PUPPET_VERSION="~> 5.5.6" +export PUPPET_GEM_VERSION="~> 6.1.0" ``` You can install all needed gems for spec tests into the modules directory by @@ -232,17 +232,16 @@ simple tests against it after applying the module. You can run this with: ```sh -BEAKER_setfile=debian10-x64 bundle exec rake beaker +BEAKER_setfile=debian11-64 bundle exec rake beaker ``` You can replace the string `debian10` with any common operating system. The following strings are known to work: -* ubuntu1604 * ubuntu1804 * ubuntu2004 -* debian9 * debian10 +* debian11 * centos7 * centos8 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5dad05..49981e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,60 +7,10 @@ name: CI on: pull_request concurrency: - group: ${{ github.head_ref }} + group: ${{ github.ref_name }} cancel-in-progress: true jobs: - setup_matrix: - name: 'Setup Test Matrix' - runs-on: ubuntu-latest - timeout-minutes: 40 - outputs: - puppet_unit_test_matrix: ${{ steps.get-outputs.outputs.puppet_unit_test_matrix }} - github_action_test_matrix: ${{ steps.get-outputs.outputs.github_action_test_matrix }} - env: - BUNDLE_WITHOUT: development:system_tests:release - steps: - - uses: actions/checkout@v2 - - name: Setup ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '3.0' - bundler-cache: true - - name: Run static validations - run: bundle exec rake validate lint check - - name: Run rake rubocop - run: bundle exec rake rubocop - - name: Setup Test Matrix - id: get-outputs - run: bundle exec metadata2gha --use-fqdn --pidfile-workaround false - - unit: - needs: setup_matrix - runs-on: ubuntu-latest - timeout-minutes: 40 - strategy: - fail-fast: false - matrix: - include: ${{fromJson(needs.setup_matrix.outputs.puppet_unit_test_matrix)}} - env: - BUNDLE_WITHOUT: development:system_tests:release - PUPPET_VERSION: "~> ${{ matrix.puppet }}.0" - name: Puppet ${{ matrix.puppet }} (Ruby ${{ matrix.ruby }}) - steps: - - uses: actions/checkout@v2 - - name: Setup ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby }} - bundler-cache: true - - name: Run tests - run: bundle exec rake parallel_spec - - tests: - needs: - - unit - runs-on: ubuntu-latest - name: Test suite - steps: - - run: echo Test suite completed + puppet: + name: Puppet + uses: voxpupuli/gha-puppet/.github/workflows/basic.yml@v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 664ba69..15f1721 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,26 +9,14 @@ on: tags: - '*' -env: - BUNDLE_WITHOUT: development:test:system_tests - jobs: - deploy: - name: 'deploy to forge' - runs-on: ubuntu-latest - if: github.repository_owner == 'voxpupuli' - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '2.7' - bundler-cache: true - - name: Build and Deploy - env: - # Configure secrets here: - # https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets - BLACKSMITH_FORGE_USERNAME: '${{ secrets.PUPPET_FORGE_USERNAME }}' - BLACKSMITH_FORGE_API_KEY: '${{ secrets.PUPPET_FORGE_API_KEY }}' - run: bundle exec rake module:push + release: + name: Release + uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v1 + 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/.msync.yml b/.msync.yml index a83abd9..0235385 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: '5.1.0' +modulesync_config_version: '5.3.0' diff --git a/Dockerfile b/Dockerfile index e3cf307..8dd82d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ WORKDIR /opt/puppet # https://github.com/puppetlabs/puppet/blob/06ad255754a38f22fb3a22c7c4f1e2ce453d01cb/lib/puppet/provider/service/runit.rb#L39 RUN mkdir -p /etc/sv -ARG PUPPET_VERSION="~> 6.0" +ARG PUPPET_GEM_VERSION="~> 6.0" ARG PARALLEL_TEST_PROCESSORS=4 # Cache gems diff --git a/Gemfile b/Gemfile index b6dcf45..07209b7 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,10 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -source ENV['GEM_SOURCE'] || "https://rubygems.org" +source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :test do - gem 'voxpupuli-test', '~> 5.0', :require => false + gem 'voxpupuli-test', '~> 5.4', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false gem 'puppet_metadata', '~> 1.0', :require => false @@ -28,7 +28,7 @@ end gem 'rake', :require => false gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test] -puppetversion = ENV['PUPPET_VERSION'] || '>= 6.0' +puppetversion = ENV['PUPPET_GEM_VERSION'] || '>= 6.0' gem 'puppet', puppetversion, :require => false, :groups => [:test] # vim: syntax=ruby diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4d617f3..6515b7b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -9,6 +9,8 @@ require 'voxpupuli/test/spec_helper' +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| From edeb3a469109f303aa44ac598dfbe9c68f25f88f Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 2 Oct 2022 14:36:32 +0200 Subject: [PATCH 04/15] modulesync 5.3.0 --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index f92f051..b657190 100644 --- a/Rakefile +++ b/Rakefile @@ -52,7 +52,7 @@ begin config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module." config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog} config.user = 'voxpupuli' - config.project = metadata.metadata['name'] + config.project = 'puppet-augeasproviders_syslog' end # Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715 From f0eb3bf2655513b0780940a8a89dec9b4815011a Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Tue, 20 Dec 2022 14:38:51 +0100 Subject: [PATCH 05/15] modulesync 5.4.0 --- .msync.yml | 2 +- Gemfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.msync.yml b/.msync.yml index 0235385..f3156d1 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: '5.3.0' +modulesync_config_version: '5.4.0' diff --git a/Gemfile b/Gemfile index 07209b7..b3827ba 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ group :test do gem 'voxpupuli-test', '~> 5.4', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false - gem 'puppet_metadata', '~> 1.0', :require => false + gem 'puppet_metadata', '~> 2.0', :require => false end group :development do From 2f3e5d6e6cd6ccf5e7cd1242f7d4f22606e21b1a Mon Sep 17 00:00:00 2001 From: Massimiliano Adamo Date: Sat, 15 Apr 2023 09:51:35 +0200 Subject: [PATCH 06/15] modulesync 5.5.0 --- .github/SECURITY.md | 3 --- .gitignore | 36 ++++++++++++------------- .msync.yml | 2 +- .pmtignore | 64 ++++++++++++++++++++++----------------------- Gemfile | 3 +-- Rakefile | 36 +++---------------------- 6 files changed, 56 insertions(+), 88 deletions(-) delete mode 100644 .github/SECURITY.md diff --git a/.github/SECURITY.md b/.github/SECURITY.md deleted file mode 100644 index cacadf2..0000000 --- a/.github/SECURITY.md +++ /dev/null @@ -1,3 +0,0 @@ -# Vox Pupuli Security Policy - -Our vulnerabilities reporting process is at https://voxpupuli.org/security/ diff --git a/.gitignore b/.gitignore index 9b95224..84fd904 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,23 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -pkg/ -Gemfile.lock -Gemfile.local -vendor/ -.vendor/ -spec/fixtures/manifests/ -spec/fixtures/modules/ -.vagrant/ -.bundle/ -.ruby-version -coverage/ -log/ -.idea/ -.dependencies/ -.librarian/ -Puppetfile.lock +/pkg/ +/Gemfile.lock +/Gemfile.local +/vendor/ +/.vendor/ +/spec/fixtures/manifests/ +/spec/fixtures/modules/ +/.vagrant/ +/.bundle/ +/.ruby-version +/coverage/ +/log/ +/.idea/ +/.dependencies/ +/.librarian/ +/Puppetfile.lock *.iml .*.sw? -.yardoc/ -Guardfile +/.yardoc/ +/Guardfile diff --git a/.msync.yml b/.msync.yml index f3156d1..a4b0069 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: '5.4.0' +modulesync_config_version: '5.5.0' diff --git a/.pmtignore b/.pmtignore index 65f5051..58a0408 100644 --- a/.pmtignore +++ b/.pmtignore @@ -1,37 +1,37 @@ # 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 +/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 +/.editorconfig +/.fixtures.yml +/.gitignore +/.msync.yml +/.overcommit.yml +/.pmtignore +/.rspec +/.rspec_parallel +/.rubocop.yml +/.sync.yml .*.sw? -.yardoc/ -.yardopts -Dockerfile +/.yardoc/ +/.yardopts +/Dockerfile diff --git a/Gemfile b/Gemfile index b3827ba..15313c3 100644 --- a/Gemfile +++ b/Gemfile @@ -21,8 +21,7 @@ end group :release do gem 'github_changelog_generator', '>= 1.16.1', :require => false if RUBY_VERSION >= '2.5' - gem 'voxpupuli-release', '>= 1.2.0', :require => false - gem 'puppet-strings', '>= 2.2', :require => false + gem 'voxpupuli-release', '~> 2.0', :require => false end gem 'rake', :require => false diff --git a/Rakefile b/Rakefile index b657190..7f90745 100644 --- a/Rakefile +++ b/Rakefile @@ -24,6 +24,10 @@ end begin require 'voxpupuli/release/rake_tasks' rescue LoadError + # voxpupuli-release not present +else + GCGConfig.user = 'voxpupuli' + GCGConfig.project = 'puppet-augeasproviders_syslog' end desc "Run main 'test' task and report merged results to coveralls" @@ -37,36 +41,4 @@ task test_with_coveralls: [:test] do end end -desc 'Generate REFERENCE.md' -task :reference, [:debug, :backtrace] do |t, args| - patterns = '' - Rake::Task['strings:generate:reference'].invoke(patterns, args[:debug], args[:backtrace]) -end - -begin - require 'github_changelog_generator/task' - require 'puppet_blacksmith' - GitHubChangelogGenerator::RakeTask.new :changelog do |config| - metadata = Blacksmith::Modulefile.new - config.future_release = "v#{metadata.version}" if metadata.version =~ /^\d+\.\d+.\d+$/ - config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module." - config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog} - config.user = 'voxpupuli' - config.project = 'puppet-augeasproviders_syslog' - end - - # Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715 - require 'rbconfig' - if RbConfig::CONFIG['host_os'] =~ /linux/ - task :changelog do - puts 'Fixing line endings...' - changelog_file = File.join(__dir__, 'CHANGELOG.md') - changelog_txt = File.read(changelog_file) - new_contents = changelog_txt.gsub(%r{\r\n}, "\n") - File.open(changelog_file, "w") {|file| file.puts new_contents } - end - end - -rescue LoadError -end # vim: syntax=ruby From f233f53b4208e0efc7680d5612246c1d3253c68b Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 10 May 2023 09:30:15 +0200 Subject: [PATCH 07/15] rubocop: regenerate todo file --- .rubocop.yml | 2 + .rubocop_todo.yml | 238 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 240 insertions(+) create mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml index 53ac189..ea22bff 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,6 @@ --- +inherit_from: .rubocop_todo.yml + # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..9ae3b2a --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,238 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2023-05-10 07:30:04 UTC using RuboCop version 1.22.3. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth. +# SupportedStyles: case, end +Layout/CaseIndentation: + Exclude: + - 'lib/puppet/provider/rsyslog_filter/augeas.rb' + - 'lib/puppet/provider/syslog/augeas.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Layout/EmptyLineAfterGuardClause: + Exclude: + - 'lib/puppet/provider/rsyslog_filter/augeas.rb' + - 'lib/puppet/provider/syslog/augeas.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/EmptyLineAfterMagicComment: + Exclude: + - 'lib/puppet/provider/rsyslog_filter/augeas.rb' + - 'lib/puppet/provider/syslog/augeas.rb' + +# Offense count: 32 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses +Layout/FirstArgumentIndentation: + Exclude: + - 'spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb' + - 'spec/unit/puppet/provider/syslog/augeas_spec.rb' + - 'spec/unit/puppet/provider/syslog/rsyslog_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_braces +Layout/FirstHashElementIndentation: + Exclude: + - 'spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb' + +# Offense count: 9 +# Cop supports --auto-correct. +# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/HashAlignment: + Exclude: + - 'spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb' + +# Offense count: 99 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. +# SupportedStylesForExponentOperator: space, no_space +Layout/SpaceAroundOperators: + Exclude: + - 'spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb' + - 'spec/unit/puppet/provider/syslog/augeas_spec.rb' + - 'spec/unit/puppet/provider/syslog/rsyslog_spec.rb' + +# Offense count: 24 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideHashLiteralBraces: + EnforcedStyle: no_space + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AllowInHeredoc. +Layout/TrailingWhitespace: + Exclude: + - 'lib/puppet/provider/syslog/augeas.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Lint/ScriptPermission: + Exclude: + - 'spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb' + - 'spec/unit/puppet/provider/syslog/augeas_spec.rb' + - 'spec/unit/puppet/provider/syslog/rsyslog_spec.rb' + +# Offense count: 27 +# Cop supports --auto-correct. +# Configuration parameters: CustomTransform, IgnoredWords. +RSpec/ExampleWording: + Exclude: + - 'spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb' + - 'spec/unit/puppet/provider/syslog/augeas_spec.rb' + - 'spec/unit/puppet/provider/syslog/rsyslog_spec.rb' + +# Offense count: 18 +# Configuration parameters: AssignmentOnly. +RSpec/InstanceVariable: + Exclude: + - 'spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb' + - 'spec/unit/puppet/provider/syslog/augeas_spec.rb' + - 'spec/unit/puppet/provider/syslog/rsyslog_spec.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, conditionals +Style/AndOr: + Exclude: + - 'lib/puppet/provider/rsyslog_filter/augeas.rb' + - 'lib/puppet/provider/syslog/augeas.rb' + +# Offense count: 5 +# Configuration parameters: AllowedChars. +# AllowedChars: © +Style/AsciiComments: + Exclude: + - 'lib/puppet/provider/rsyslog_filter/augeas.rb' + - 'lib/puppet/provider/syslog/augeas.rb' + - 'lib/puppet/provider/syslog/rsyslog.rb' + - 'lib/puppet/type/rsyslog_filter.rb' + - 'lib/puppet/type/syslog.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. +# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces +# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object +# FunctionalMethods: let, let!, subject, watch +# IgnoredMethods: lambda, proc, it +Style/BlockDelimiters: + Exclude: + - 'spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb' + - 'spec/unit/puppet/provider/syslog/augeas_spec.rb' + - 'spec/unit/puppet/provider/syslog/rsyslog_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/CaseLikeIf: + Exclude: + - 'spec/unit/puppet/provider/syslog/augeas_spec.rb' + - 'spec/unit/puppet/provider/syslog/rsyslog_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. +# SupportedStyles: assign_to_condition, assign_inside_condition +Style/ConditionalAssignment: + Exclude: + - 'lib/puppet/provider/rsyslog_filter/augeas.rb' + - 'lib/puppet/provider/syslog/augeas.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/Encoding: + Exclude: + - 'lib/puppet/provider/rsyslog_filter/augeas.rb' + - 'lib/puppet/provider/syslog/augeas.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Exclude: + - 'lib/puppet/provider/rsyslog_filter/augeas.rb' + - 'lib/puppet/provider/syslog/augeas.rb' + - 'lib/puppet/provider/syslog/rsyslog.rb' + - 'lib/puppet/type/rsyslog_filter.rb' + - 'lib/puppet/type/syslog.rb' + - 'spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb' + - 'spec/unit/puppet/provider/syslog/augeas_spec.rb' + - 'spec/unit/puppet/provider/syslog/rsyslog_spec.rb' + +# Offense count: 438 +# Cop supports --auto-correct. +# Configuration parameters: UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +Style/HashSyntax: + EnforcedStyle: hash_rockets + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AllowIfModifier. +Style/IfInsideElse: + Exclude: + - 'lib/puppet/provider/rsyslog_filter/augeas.rb' + - 'lib/puppet/provider/syslog/augeas.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/IfUnlessModifier: + Exclude: + - 'lib/puppet/provider/syslog/augeas.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/RedundantInterpolation: + Exclude: + - 'lib/puppet/provider/rsyslog_filter/augeas.rb' + - 'lib/puppet/provider/syslog/augeas.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: only_raise, only_fail, semantic +Style/SignalException: + Exclude: + - 'lib/puppet/type/syslog.rb' + +# Offense count: 475 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Exclude: + - 'lib/puppet/provider/rsyslog_filter/augeas.rb' + - 'lib/puppet/provider/syslog/augeas.rb' + - 'lib/puppet/provider/syslog/rsyslog.rb' + - 'lib/puppet/type/rsyslog_filter.rb' + - 'lib/puppet/type/syslog.rb' + - 'spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb' + - 'spec/unit/puppet/provider/syslog/augeas_spec.rb' + - 'spec/unit/puppet/provider/syslog/rsyslog_spec.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInArguments: + Exclude: + - 'spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb' From 565b3b38ccce12050e551ef77c2d9e13bcb663bb Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 12 May 2023 10:57:59 +0200 Subject: [PATCH 08/15] modulesync 6.0.0 --- .github/workflows/ci.yml | 6 +++++- .msync.yml | 2 +- .rubocop.yml | 3 +-- .sync.yml | 15 +++++++++++++++ Gemfile | 14 ++++++++------ spec/spec_helper.rb | 6 ++++++ 6 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 .sync.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 49981e3..29aa991 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,4 +13,8 @@ concurrency: jobs: puppet: name: Puppet - uses: voxpupuli/gha-puppet/.github/workflows/basic.yml@v1 + uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v1 + with: + pidfile_workaround: 'false' + additional_packages: 'libaugeas-dev augeas-tools' + rubocop: false diff --git a/.msync.yml b/.msync.yml index a4b0069..b929160 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: '5.5.0' +modulesync_config_version: '6.0.0' diff --git a/.rubocop.yml b/.rubocop.yml index ea22bff..fded90c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,8 +1,7 @@ --- -inherit_from: .rubocop_todo.yml - # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ +inherit_from: .rubocop_todo.yml inherit_gem: voxpupuli-test: rubocop.yml diff --git a/.sync.yml b/.sync.yml new file mode 100644 index 0000000..20846fc --- /dev/null +++ b/.sync.yml @@ -0,0 +1,15 @@ +--- +.github/workflows/ci.yml: + additional_packages: libaugeas-dev augeas-tools + rubocop: false +Gemfile: + optional: + ':test': + - gem: ruby-augeas +spec/spec_helper.rb: + spec_overrides: + - "require 'augeas_spec'" + - "# augeasproviders: setting $LOAD_PATH to work around broken type autoloading" + - "$LOAD_PATH.unshift(File.join(__dir__, 'fixtures/modules/augeasproviders_core/lib'))" +spec/spec_helper_acceptance.rb: + unmanaged: false diff --git a/Gemfile b/Gemfile index 15313c3..411fa26 100644 --- a/Gemfile +++ b/Gemfile @@ -4,10 +4,11 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :test do - gem 'voxpupuli-test', '~> 5.4', :require => false + gem 'voxpupuli-test', '~> 6.0', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false - gem 'puppet_metadata', '~> 2.0', :require => false + gem 'puppet_metadata', '~> 3.0', :require => false + gem 'ruby-augeas', :require => false end group :development do @@ -16,18 +17,19 @@ group :development do end group :system_tests do - gem 'voxpupuli-acceptance', '~> 1.0', :require => false + gem 'voxpupuli-acceptance', '~> 2.0', :require => false end group :release do - gem 'github_changelog_generator', '>= 1.16.1', :require => false if RUBY_VERSION >= '2.5' - gem 'voxpupuli-release', '~> 2.0', :require => false + gem 'github_changelog_generator', '>= 1.16.1', :require => false + gem 'voxpupuli-release', '~> 3.0', :require => false + gem 'faraday-retry', '~> 2.1', :require => false end gem 'rake', :require => false gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test] -puppetversion = ENV['PUPPET_GEM_VERSION'] || '>= 6.0' +puppetversion = ENV['PUPPET_GEM_VERSION'] || '~> 7.24' gem 'puppet', puppetversion, :require => false, :groups => [:test] # vim: syntax=ruby diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6515b7b..d6e9512 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -17,3 +17,9 @@ add_custom_fact name.to_sym, value end end + +require 'augeas_spec' + +# augeasproviders: setting $LOAD_PATH to work around broken type autoloading + +$LOAD_PATH.unshift(File.join(__dir__, 'fixtures/modules/augeasproviders_core/lib')) From 59de6229a20e6336858be0c68566bec6b315bff8 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 12 May 2023 13:00:56 +0200 Subject: [PATCH 09/15] cleanup .fixtures.yml --- .fixtures.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index 43345f8..7908bbc 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,6 +1,4 @@ +--- fixtures: repositories: - "augeasproviders_core": - repo: "git://github.com/hercules-team/augeasproviders_core.git" - symlinks: - augeasproviders_syslog: "#{source_dir}" + "augeasproviders_core": "https://github.com/voxpupuli/puppet-augeasproviders_core.git" From 689213928d1e680e2688a76489a0e6c7e2149549 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 17 Aug 2023 14:34:50 +0200 Subject: [PATCH 10/15] modulesync 7.0.0 --- .github/CONTRIBUTING.md | 11 +++++++---- .github/workflows/ci.yml | 3 +-- .msync.yml | 2 +- Gemfile | 2 +- spec/spec_helper.rb | 1 + spec/spec_helper_acceptance.rb | 10 ++++++++++ 6 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 spec/spec_helper_acceptance.rb diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 8b466cf..6aaa603 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -232,18 +232,21 @@ simple tests against it after applying the module. You can run this with: ```sh -BEAKER_setfile=debian11-64 bundle exec rake beaker +BEAKER_PUPPET_COLLECTION=puppet7 BEAKER_setfile=debian11-64 bundle exec rake beaker ``` -You can replace the string `debian10` with any common operating system. +You can replace the string `debian11` with any common operating system. The following strings are known to work: -* ubuntu1804 * ubuntu2004 -* debian10 +* 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). diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 29aa991..5b18ef3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,8 +13,7 @@ concurrency: jobs: puppet: name: Puppet - uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v1 + uses: voxpupuli/gha-puppet/.github/workflows/basic.yml@v1 with: - pidfile_workaround: 'false' additional_packages: 'libaugeas-dev augeas-tools' rubocop: false diff --git a/.msync.yml b/.msync.yml index b929160..dd3e957 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: '6.0.0' +modulesync_config_version: '7.0.0' diff --git a/Gemfile b/Gemfile index 411fa26..7221ee1 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :test do - gem 'voxpupuli-test', '~> 6.0', :require => false + gem 'voxpupuli-test', '~> 7.0', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false gem 'puppet_metadata', '~> 3.0', :require => false diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d6e9512..d34b248 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -23,3 +23,4 @@ # augeasproviders: setting $LOAD_PATH to work around broken type autoloading $LOAD_PATH.unshift(File.join(__dir__, 'fixtures/modules/augeasproviders_core/lib')) +Dir['./spec/support/spec/**/*.rb'].sort.each { |f| require f } 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 02668dd30d3abc5561aa7dd63e76adfdd195b10e Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 17 Aug 2023 23:59:43 +0200 Subject: [PATCH 11/15] rubocop: autofix --- .rubocop.yml | 3 +- .rubocop_todo.yml | 184 +------- lib/puppet/provider/rsyslog_filter/augeas.rb | 59 ++- lib/puppet/provider/syslog/augeas.rb | 73 ++-- lib/puppet/provider/syslog/rsyslog.rb | 6 +- lib/puppet/type/rsyslog_filter.rb | 20 +- lib/puppet/type/syslog.rb | 28 +- .../provider/rsyslog_filter/augeas_spec.rb | 234 +++++----- .../puppet/provider/syslog/augeas_spec.rb | 394 ++++++++--------- .../puppet/provider/syslog/rsyslog_spec.rb | 398 +++++++++--------- 10 files changed, 615 insertions(+), 784 deletions(-) mode change 100644 => 100755 spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb mode change 100644 => 100755 spec/unit/puppet/provider/syslog/augeas_spec.rb mode change 100644 => 100755 spec/unit/puppet/provider/syslog/rsyslog_spec.rb diff --git a/.rubocop.yml b/.rubocop.yml index fded90c..ea22bff 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,7 +1,8 @@ --- +inherit_from: .rubocop_todo.yml + # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -inherit_from: .rubocop_todo.yml inherit_gem: voxpupuli-test: rubocop.yml diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9ae3b2a..350708f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,99 +1,21 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2023-05-10 07:30:04 UTC using RuboCop version 1.22.3. +# on 2023-08-17 21:31:39 UTC using RuboCop version 1.50.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth. -# SupportedStyles: case, end -Layout/CaseIndentation: - Exclude: - - 'lib/puppet/provider/rsyslog_filter/augeas.rb' - - 'lib/puppet/provider/syslog/augeas.rb' - -# Offense count: 4 -# Cop supports --auto-correct. -Layout/EmptyLineAfterGuardClause: - Exclude: - - 'lib/puppet/provider/rsyslog_filter/augeas.rb' - - 'lib/puppet/provider/syslog/augeas.rb' - # Offense count: 2 -# Cop supports --auto-correct. -Layout/EmptyLineAfterMagicComment: +# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches. +Lint/DuplicateBranch: Exclude: - 'lib/puppet/provider/rsyslog_filter/augeas.rb' - 'lib/puppet/provider/syslog/augeas.rb' -# Offense count: 32 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses -Layout/FirstArgumentIndentation: - Exclude: - - 'spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb' - - 'spec/unit/puppet/provider/syslog/augeas_spec.rb' - - 'spec/unit/puppet/provider/syslog/rsyslog_spec.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_braces -Layout/FirstHashElementIndentation: - Exclude: - - 'spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb' - -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. -# SupportedHashRocketStyles: key, separator, table -# SupportedColonStyles: key, separator, table -# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit -Layout/HashAlignment: - Exclude: - - 'spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb' - -# Offense count: 99 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. -# SupportedStylesForExponentOperator: space, no_space -Layout/SpaceAroundOperators: - Exclude: - - 'spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb' - - 'spec/unit/puppet/provider/syslog/augeas_spec.rb' - - 'spec/unit/puppet/provider/syslog/rsyslog_spec.rb' - -# Offense count: 24 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideHashLiteralBraces: - EnforcedStyle: no_space - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: AllowInHeredoc. -Layout/TrailingWhitespace: - Exclude: - - 'lib/puppet/provider/syslog/augeas.rb' - -# Offense count: 3 -# Cop supports --auto-correct. -Lint/ScriptPermission: - Exclude: - - 'spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb' - - 'spec/unit/puppet/provider/syslog/augeas_spec.rb' - - 'spec/unit/puppet/provider/syslog/rsyslog_spec.rb' - -# Offense count: 27 -# Cop supports --auto-correct. -# Configuration parameters: CustomTransform, IgnoredWords. -RSpec/ExampleWording: +# Offense count: 18 +# This cop supports unsafe autocorrection (--autocorrect-all). +RSpec/BeEq: Exclude: - 'spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb' - 'spec/unit/puppet/provider/syslog/augeas_spec.rb' @@ -108,7 +30,7 @@ RSpec/InstanceVariable: - 'spec/unit/puppet/provider/syslog/rsyslog_spec.rb' # Offense count: 3 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, conditionals Style/AndOr: @@ -127,44 +49,8 @@ Style/AsciiComments: - 'lib/puppet/type/rsyslog_filter.rb' - 'lib/puppet/type/syslog.rb' -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. -# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces -# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object -# FunctionalMethods: let, let!, subject, watch -# IgnoredMethods: lambda, proc, it -Style/BlockDelimiters: - Exclude: - - 'spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb' - - 'spec/unit/puppet/provider/syslog/augeas_spec.rb' - - 'spec/unit/puppet/provider/syslog/rsyslog_spec.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -Style/CaseLikeIf: - Exclude: - - 'spec/unit/puppet/provider/syslog/augeas_spec.rb' - - 'spec/unit/puppet/provider/syslog/rsyslog_spec.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. -# SupportedStyles: assign_to_condition, assign_inside_condition -Style/ConditionalAssignment: - Exclude: - - 'lib/puppet/provider/rsyslog_filter/augeas.rb' - - 'lib/puppet/provider/syslog/augeas.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -Style/Encoding: - Exclude: - - 'lib/puppet/provider/rsyslog_filter/augeas.rb' - - 'lib/puppet/provider/syslog/augeas.rb' - # Offense count: 8 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never Style/FrozenStringLiteralComment: @@ -178,61 +64,9 @@ Style/FrozenStringLiteralComment: - 'spec/unit/puppet/provider/syslog/augeas_spec.rb' - 'spec/unit/puppet/provider/syslog/rsyslog_spec.rb' -# Offense count: 438 -# Cop supports --auto-correct. -# Configuration parameters: UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. -# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys -Style/HashSyntax: - EnforcedStyle: hash_rockets - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: AllowIfModifier. -Style/IfInsideElse: - Exclude: - - 'lib/puppet/provider/rsyslog_filter/augeas.rb' - - 'lib/puppet/provider/syslog/augeas.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Style/IfUnlessModifier: - Exclude: - - 'lib/puppet/provider/syslog/augeas.rb' - # Offense count: 2 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). Style/RedundantInterpolation: Exclude: - 'lib/puppet/provider/rsyslog_filter/augeas.rb' - 'lib/puppet/provider/syslog/augeas.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: only_raise, only_fail, semantic -Style/SignalException: - Exclude: - - 'lib/puppet/type/syslog.rb' - -# Offense count: 475 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. -# SupportedStyles: single_quotes, double_quotes -Style/StringLiterals: - Exclude: - - 'lib/puppet/provider/rsyslog_filter/augeas.rb' - - 'lib/puppet/provider/syslog/augeas.rb' - - 'lib/puppet/provider/syslog/rsyslog.rb' - - 'lib/puppet/type/rsyslog_filter.rb' - - 'lib/puppet/type/syslog.rb' - - 'spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb' - - 'spec/unit/puppet/provider/syslog/augeas_spec.rb' - - 'spec/unit/puppet/provider/syslog/rsyslog_spec.rb' - -# Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleForMultiline. -# SupportedStylesForMultiline: comma, consistent_comma, no_comma -Style/TrailingCommaInArguments: - Exclude: - - 'spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb' diff --git a/lib/puppet/provider/rsyslog_filter/augeas.rb b/lib/puppet/provider/rsyslog_filter/augeas.rb index f47cf9a..4faef90 100644 --- a/lib/puppet/provider/rsyslog_filter/augeas.rb +++ b/lib/puppet/provider/rsyslog_filter/augeas.rb @@ -1,12 +1,12 @@ -# coding: utf-8 # Alternative Augeas-based providers for Puppet # # Copyright (c) 2019 Raphaël Pinson # Licensed under the Apache License, Version 2.0 -raise("Missing augeasproviders_core dependency") if Puppet::Type.type(:augeasprovider).nil? -Puppet::Type.type(:rsyslog_filter).provide(:augeas, :parent => Puppet::Type.type(:augeasprovider).provider(:default)) do - desc "Uses Augeas API to update an rsyslog.conf filter entry" +raise('Missing augeasproviders_core dependency') if Puppet::Type.type(:augeasprovider).nil? + +Puppet::Type.type(:rsyslog_filter).provide(:augeas, parent: Puppet::Type.type(:augeasprovider).provider(:default)) do + desc 'Uses Augeas API to update an rsyslog.conf filter entry' default_file { '/etc/rsyslog.conf' } @@ -18,7 +18,7 @@ end end - confine :feature => :augeas + confine feature: :augeas resource_path do |resource| property = resource[:property] @@ -31,24 +31,23 @@ def protocol_supported return @protocol_supported unless @protocol_supported.nil? - if Puppet::Util::Package.versioncmp(aug_version, '1.2.0') >= 0 - @protocol_supported = :stock - else - if parsed_as?("*.* @syslog.far.away:123\n", 'entry/action/protocol') - @protocol_supported = :stock - elsif parsed_as?("*.* @@syslog.far.away:123\n", 'entry/action/protocol') - @protocol_supported = :el7 - else - @protocol_supported = false - end - end + + @protocol_supported = if Puppet::Util::Package.versioncmp(aug_version, '1.2.0') >= 0 + :stock + elsif parsed_as?("*.* @syslog.far.away:123\n", 'entry/action/protocol') + :stock + elsif parsed_as?("*.* @@syslog.far.away:123\n", 'entry/action/protocol') + :el7 + else + false + end end def self.instances augopen do |aug| resources = [] - aug.match("$target/filter").each do |apath| + aug.match('$target/filter').each do |apath| property = aug.get("#{apath}/property") operation = aug.get("#{apath}/operation") value = aug.get("#{apath}/value") @@ -57,14 +56,14 @@ def self.instances action_protocol = aug.get("#{apath}/action/protocol") action = aug.get("#{apath}/action/#{action_type}") name = "#{property} #{operation} #{value}" - name += action_protocol if action_type == "hostname" + name += action_protocol if action_type == 'hostname' name += "#{action}" - entry = {:ensure => :present, :name => name, - :property => property, :operation => operation, :value => value, - :action_type => action_type, - :action_port => action_port, - :action_protocol => action_protocol, - :action => action} + entry = { ensure: :present, name: name, + property: property, operation: operation, value: value, + action_type: action_type, + action_port: action_port, + action_protocol: action_protocol, + action: action } resources << new(entry) end @@ -89,12 +88,12 @@ def create aug.set('$resource/value', value) if action_protocol case protocol_supported - when :stock - aug.set('$resource/action/protocol', action_protocol) - when :el7 - aug.set('$resource/action/protocol', action_protocol) if action_protocol == '@@' - else - raise(Puppet::Error, 'Protocol is not supported in this lens') + when :stock + aug.set('$resource/action/protocol', action_protocol) + when :el7 + aug.set('$resource/action/protocol', action_protocol) if action_protocol == '@@' + else + raise(Puppet::Error, 'Protocol is not supported in this lens') end end aug.set("$resource/action/#{action_type}", action) diff --git a/lib/puppet/provider/syslog/augeas.rb b/lib/puppet/provider/syslog/augeas.rb index 33e9d20..53995df 100644 --- a/lib/puppet/provider/syslog/augeas.rb +++ b/lib/puppet/provider/syslog/augeas.rb @@ -1,12 +1,12 @@ -# coding: utf-8 # Alternative Augeas-based providers for Puppet # # Copyright (c) 2012 Raphaël Pinson # Licensed under the Apache License, Version 2.0 -raise("Missing augeasproviders_core dependency") if Puppet::Type.type(:augeasprovider).nil? -Puppet::Type.type(:syslog).provide(:augeas, :parent => Puppet::Type.type(:augeasprovider).provider(:default)) do - desc "Uses Augeas API to update a syslog.conf entry" +raise('Missing augeasproviders_core dependency') if Puppet::Type.type(:augeasprovider).nil? + +Puppet::Type.type(:syslog).provide(:augeas, parent: Puppet::Type.type(:augeasprovider).provider(:default)) do + desc 'Uses Augeas API to update a syslog.conf entry' default_file { '/etc/syslog.conf' } @@ -18,7 +18,7 @@ end end - confine :feature => :augeas + confine feature: :augeas resource_path do |resource| entry_path(resource) @@ -26,17 +26,16 @@ def protocol_supported return @protocol_supported unless @protocol_supported.nil? - if Puppet::Util::Package.versioncmp(aug_version, '1.2.0') >= 0 - @protocol_supported = :stock - else - if parsed_as?("*.* @syslog.far.away:123\n", 'entry/action/protocol') - @protocol_supported = :stock - elsif parsed_as?("*.* @@syslog.far.away:123\n", 'entry/action/protocol') - @protocol_supported = :el7 - else - @protocol_supported = false - end - end + + @protocol_supported = if Puppet::Util::Package.versioncmp(aug_version, '1.2.0') >= 0 + :stock + elsif parsed_as?("*.* @syslog.far.away:123\n", 'entry/action/protocol') + :stock + elsif parsed_as?("*.* @@syslog.far.away:123\n", 'entry/action/protocol') + :el7 + else + false + end end # We need to define an entry_path method @@ -55,10 +54,10 @@ def self.instances augopen do |aug| resources = [] - aug.match("$target/entry").each do |apath| + aug.match('$target/entry').each do |apath| aug.match("#{apath}/selector").each do |snode| aug.match("#{snode}/facility").each do |fnode| - facility = aug.get(fnode) + facility = aug.get(fnode) level = aug.get("#{snode}/level") no_sync = aug.match("#{apath}/action/no_sync").empty? ? :false : :true action_type_node = aug.match("#{apath}/action/*[label() != 'no_sync']") @@ -67,16 +66,16 @@ def self.instances action_protocol = aug.get("#{apath}/action/protocol") action = aug.get("#{apath}/action/#{action_type}") name = "#{facility}.#{level} " - name += "-" if no_sync == :true - name += action_protocol if action_type == "hostname" + name += '-' if no_sync == :true + name += action_protocol if action_type == 'hostname' name += "#{action}" - entry = {:ensure => :present, :name => name, - :facility => facility, :level => level, - :no_sync => no_sync, - :action_type => action_type, - :action_port => action_port, - :action_protocol => action_protocol, - :action => action} + entry = { ensure: :present, name: name, + facility: facility, level: level, + no_sync: no_sync, + action_type: action_type, + action_port: action_port, + action_protocol: action_protocol, + action: action } resources << new(entry) end end @@ -86,7 +85,7 @@ def self.instances end end - def create + def create facility = resource[:facility] level = resource[:level] no_sync = resource[:no_sync] @@ -99,17 +98,15 @@ def create aug.defnode('resource', resource_path, nil) aug.set('$resource/selector/facility', facility) aug.set('$resource/selector/level', level) - if no_sync == :true and action_type == 'file' - aug.clear('$resource/action/no_sync') - end + aug.clear('$resource/action/no_sync') if no_sync == :true and action_type == 'file' if action_protocol case protocol_supported - when :stock - aug.set('$resource/action/protocol', action_protocol) - when :el7 - aug.set('$resource/action/protocol', action_protocol) if action_protocol == '@@' - else - raise(Puppet::Error, 'Protocol is not supported in this lens') + when :stock + aug.set('$resource/action/protocol', action_protocol) + when :el7 + aug.set('$resource/action/protocol', action_protocol) if action_protocol == '@@' + else + raise(Puppet::Error, 'Protocol is not supported in this lens') end end aug.set("$resource/action/#{action_type}", action) @@ -132,7 +129,7 @@ def no_sync=(no_sync) if no_sync == :true if aug.match('$resource/action/no_sync').empty? # Insert a no_sync node before the action/file node - aug.insert('$resource/action/file', "no_sync", true) + aug.insert('$resource/action/file', 'no_sync', true) end else # Remove the no_sync tag diff --git a/lib/puppet/provider/syslog/rsyslog.rb b/lib/puppet/provider/syslog/rsyslog.rb index eb4086c..d2fd801 100644 --- a/lib/puppet/provider/syslog/rsyslog.rb +++ b/lib/puppet/provider/syslog/rsyslog.rb @@ -3,8 +3,8 @@ # Copyright (c) 2012 Raphaël Pinson # Licensed under the Apache License, Version 2.0 -Puppet::Type.type(:syslog).provide(:rsyslog, :parent => :augeas) do - desc "Uses Augeas API to update an rsyslog.conf entry" +Puppet::Type.type(:syslog).provide(:rsyslog, parent: :augeas) do + desc 'Uses Augeas API to update an rsyslog.conf entry' default_file { '/etc/rsyslog.conf' } lens { 'Rsyslog.lns' } @@ -13,5 +13,5 @@ entry_path(resource) end - confine :feature => :augeas + confine feature: :augeas end diff --git a/lib/puppet/type/rsyslog_filter.rb b/lib/puppet/type/rsyslog_filter.rb index ac2071b..356875a 100644 --- a/lib/puppet/type/rsyslog_filter.rb +++ b/lib/puppet/type/rsyslog_filter.rb @@ -4,33 +4,33 @@ # Licensed under the Apache License, Version 2.0 Puppet::Type.newtype(:rsyslog_filter) do - @doc = "Manages filters in rsyslog.conf." + @doc = 'Manages filters in rsyslog.conf.' ensurable newparam(:name) do - desc "The name of the resource." + desc 'The name of the resource.' isnamevar end newparam(:property) do - desc "The filter property." + desc 'The filter property.' end newparam(:operation) do - desc "The filter operation." + desc 'The filter operation.' end newparam(:value) do - desc "The filter value." + desc 'The filter value.' end newparam(:action_type) do - desc "The type of action: file, hostname, user or program." + desc 'The type of action: file, hostname, user or program.' end newparam(:action_protocol) do - desc "When action is hostname, the optional protocol." + desc 'When action is hostname, the optional protocol.' newvalues :udp, :tcp, :'@', :'@@' munge do |value| @@ -44,11 +44,11 @@ end newparam(:action_port) do - desc "When action is hostname, the optional port." + desc 'When action is hostname, the optional port.' end newparam(:action) do - desc "The action for the entry." + desc 'The action for the entry.' end newparam(:target) do @@ -57,7 +57,7 @@ end newparam(:lens) do - desc "The augeas lens used to parse the file" + desc 'The augeas lens used to parse the file' end autorequire(:file) do diff --git a/lib/puppet/type/syslog.rb b/lib/puppet/type/syslog.rb index 3d85f37..dd5d316 100644 --- a/lib/puppet/type/syslog.rb +++ b/lib/puppet/type/syslog.rb @@ -4,40 +4,40 @@ # Licensed under the Apache License, Version 2.0 Puppet::Type.newtype(:syslog) do - @doc = "Manages settings in syslog.conf." + @doc = 'Manages settings in syslog.conf.' ensurable def munge_boolean(value) case value - when true, "true", :true + when true, 'true', :true :true - when false, "false", :false + when false, 'false', :false :false else - fail("munge_boolean only takes booleans") + raise('munge_boolean only takes booleans') end end newparam(:name) do - desc "The name of the resource." + desc 'The name of the resource.' isnamevar end newparam(:facility) do - desc "The syslog facility for the selector." + desc 'The syslog facility for the selector.' end newparam(:level) do - desc "The syslog level for the selector." + desc 'The syslog level for the selector.' end newparam(:action_type) do - desc "The type of action: file, hostname, user or program." + desc 'The type of action: file, hostname, user or program.' end newparam(:action_protocol) do - desc "When action is hostname, the optional protocol." + desc 'When action is hostname, the optional protocol.' newvalues :udp, :tcp, :'@', :'@@' munge do |value| @@ -51,15 +51,15 @@ def munge_boolean(value) end newparam(:action_port) do - desc "When action is hostname, the optional port." + desc 'When action is hostname, the optional port.' end newparam(:action) do - desc "The action for the entry." + desc 'The action for the entry.' end - newproperty(:no_sync, :boolean => true) do - desc "Whether to omit syncing the file after every logging, ony when action_type is file." + newproperty(:no_sync, boolean: true) do + desc 'Whether to omit syncing the file after every logging, ony when action_type is file.' newvalue(:true) newvalue(:false) @@ -75,7 +75,7 @@ def munge_boolean(value) end newparam(:lens) do - desc "The augeas lens used to parse the file" + desc 'The augeas lens used to parse the file' end autorequire(:file) do diff --git a/spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb b/spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb old mode 100644 new mode 100755 index 8f750bf..cb4bce4 --- a/spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb +++ b/spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb @@ -6,199 +6,199 @@ describe provider_class do let(:protocol_supported) { subject.protocol_supported } - context "with empty file" do - let(:tmptarget) { aug_fixture("empty") } + context 'with empty file' do + let(:tmptarget) { aug_fixture('empty') } let(:target) { tmptarget.path } - it "should create new entry with file" do + it 'creates new entry with file' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true apply!(Puppet::Type.type(:rsyslog_filter).new( - :name => "my test", - :property => "msg", - :operation => "contains", - :value => "IPTables-Dropped: ", - :action_type => "file", - :action => "/var/log/iptables.log", - :target => target, - :provider => "augeas", - :ensure => "present", - )) - - aug_open(target, "Rsyslog.lns") do |aug| - expect(aug.match("filter").size).to eq(1) - expect(aug.get("filter/value")).to eq("IPTables-Dropped: ") - expect(aug.get("filter/action/file")).to eq("/var/log/iptables.log") + name: 'my test', + property: 'msg', + operation: 'contains', + value: 'IPTables-Dropped: ', + action_type: 'file', + action: '/var/log/iptables.log', + target: target, + provider: 'augeas', + ensure: 'present' + )) + + aug_open(target, 'Rsyslog.lns') do |aug| + expect(aug.match('filter').size).to eq(1) + expect(aug.get('filter/value')).to eq('IPTables-Dropped: ') + expect(aug.get('filter/action/file')).to eq('/var/log/iptables.log') end end - it "should create new entry with protocol/hostname/port" do + it 'creates new entry with protocol/hostname/port' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true apply!(Puppet::Type.type(:rsyslog_filter).new( - :name => "my test", - :property => "msg", - :operation => "contains", - :value => "IPTables-Dropped: ", - :action_type => "hostname", - :action => "logs.local", - :action_protocol => "@@", - :action_port => "514", - :target => target, - :provider => "augeas", - :ensure => "present", - )) - - aug_open(target, "Rsyslog.lns") do |aug| - expect(aug.match("filter").size).to eq(1) - expect(aug.get("filter/value")).to eq("IPTables-Dropped: ") - expect(aug.get("filter/action/hostname")).to eq("logs.local") + name: 'my test', + property: 'msg', + operation: 'contains', + value: 'IPTables-Dropped: ', + action_type: 'hostname', + action: 'logs.local', + action_protocol: '@@', + action_port: '514', + target: target, + provider: 'augeas', + ensure: 'present' + )) + + aug_open(target, 'Rsyslog.lns') do |aug| + expect(aug.match('filter').size).to eq(1) + expect(aug.get('filter/value')).to eq('IPTables-Dropped: ') + expect(aug.get('filter/action/hostname')).to eq('logs.local') end end end - context "with full file" do - let(:tmptarget) { aug_fixture("full") } + context 'with full file' do + let(:tmptarget) { aug_fixture('full') } let(:target) { tmptarget.path } - it "should list instances" do + it 'lists instances' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true provider_class.stubs(:target).returns(target) - inst = provider_class.instances.map { |p| + inst = provider_class.instances.map do |p| { - :name => p.get(:name), - :ensure => p.get(:ensure), - :property => p.get(:property), - :operation => p.get(:operation), - :value => p.get(:value), - :action_type => p.get(:action_type), - :action_protocol => p.get(:action_protocol), - :action_port => p.get(:action_port), - :action => p.get(:action), + name: p.get(:name), + ensure: p.get(:ensure), + property: p.get(:property), + operation: p.get(:operation), + value: p.get(:value), + action_type: p.get(:action_type), + action_protocol: p.get(:action_protocol), + action_port: p.get(:action_port), + action: p.get(:action), } - } + end expect(inst.size).to eq(1) expect(inst[0]).to eq({ - :ensure=>:present, - :name=>"msg contains sshd@@logserver.dev", - :property=>"msg", - :operation=>"contains", - :value=>"sshd", - :action_type=>"hostname", - :action_protocol=>"@@", - :action_port=>"514", - :action=>"logserver.dev", - }) + ensure: :present, + name: 'msg contains sshd@@logserver.dev', + property: 'msg', + operation: 'contains', + value: 'sshd', + action_type: 'hostname', + action_protocol: '@@', + action_port: '514', + action: 'logserver.dev', + }) end - describe "when creating settings" do - it "should create a simple new entry" do + describe 'when creating settings' do + it 'creates a simple new entry' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true apply!(Puppet::Type.type(:rsyslog_filter).new( - :name => "my test", - :property => "msg", - :operation => "contains", - :value => "IPTables-Dropped: ", - :action_type => "file", - :action => "/var/log/iptables.log", - :target => target, - :provider => "augeas", - :ensure => "present", - )) - - aug_open(target, "Rsyslog.lns") do |aug| - expect(aug.get("filter/action/file")).to eq("/var/log/iptables.log") + name: 'my test', + property: 'msg', + operation: 'contains', + value: 'IPTables-Dropped: ', + action_type: 'file', + action: '/var/log/iptables.log', + target: target, + provider: 'augeas', + ensure: 'present' + )) + + aug_open(target, 'Rsyslog.lns') do |aug| + expect(aug.get('filter/action/file')).to eq('/var/log/iptables.log') end end end - describe "when modifying settings" do - it "should use file" do + describe 'when modifying settings' do + it 'uses file' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true apply!(Puppet::Type.type(:rsyslog_filter).new( - :name => "ssh", - :property => "msg", - :operation => "contains", - :value => "sshd", - :action_type => "file", - :action => "/var/log/sshd.log", - :target => target, - :provider => "augeas", - :ensure => "present", - )) - - aug_open(target, "Rsyslog.lns") do |aug| - expect(aug.get("filter/action/file")).to eq("/var/log/sshd.log") + name: 'ssh', + property: 'msg', + operation: 'contains', + value: 'sshd', + action_type: 'file', + action: '/var/log/sshd.log', + target: target, + provider: 'augeas', + ensure: 'present' + )) + + aug_open(target, 'Rsyslog.lns') do |aug| + expect(aug.get('filter/action/file')).to eq('/var/log/sshd.log') end end end - describe "when removing settings" do - it "should remove the entry" do + describe 'when removing settings' do + it 'removes the entry' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true apply!(Puppet::Type.type(:rsyslog_filter).new( - :name => "ssh", - :property => "msg", - :operation => "contains", - :value => "sshd", - :action_type => "file", - :action => "/var/log/sshd.log", - :target => target, - :provider => "augeas", - :ensure => "absent", - )) - - aug_open(target, "Syslog.lns") do |aug| + name: 'ssh', + property: 'msg', + operation: 'contains', + value: 'sshd', + action_type: 'file', + action: '/var/log/sshd.log', + target: target, + provider: 'augeas', + ensure: 'absent' + )) + + aug_open(target, 'Syslog.lns') do |aug| expect(aug.match("entry[selector/facility='mail' and level='*']").size).to eq(0) end end end end - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } + context 'with broken file' do + let(:tmptarget) { aug_fixture('broken') } let(:target) { tmptarget.path } - it "should fail to load" do + it 'fails to load' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true txn = apply(Puppet::Type.type(:rsyslog_filter).new( - :name => "ssh", - :property => "msg", - :operation => "contains", - :value => "sshd", - :action_type => "file", - :action => "/var/log/sshd.log", - :target => target, - :provider => "augeas", - :ensure => "absent", - )) + name: 'ssh', + property: 'msg', + operation: 'contains', + value: 'sshd', + action_type: 'file', + action: '/var/log/sshd.log', + target: target, + provider: 'augeas', + ensure: 'absent' + )) expect(txn.any_failed?).not_to eq(nil) expect(@logs.first.level).to eq(:err) diff --git a/spec/unit/puppet/provider/syslog/augeas_spec.rb b/spec/unit/puppet/provider/syslog/augeas_spec.rb old mode 100644 new mode 100755 index a5673d1..ec1844b --- a/spec/unit/puppet/provider/syslog/augeas_spec.rb +++ b/spec/unit/puppet/provider/syslog/augeas_spec.rb @@ -6,35 +6,35 @@ describe provider_class do let(:protocol_supported) { subject.protocol_supported } - context "with empty file" do - let(:tmptarget) { aug_fixture("empty") } + context 'with empty file' do + let(:tmptarget) { aug_fixture('empty') } let(:target) { tmptarget.path } - it "should create simple new entry" do + it 'creates simple new entry' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true apply!(Puppet::Type.type(:syslog).new( - :name => "my test", - :facility => "local2", - :level => "*", - :action_type => "file", - :action => "/var/log/test.log", - :target => target, - :provider => "augeas", - :ensure => "present" - )) - - aug_open(target, "Syslog.lns") do |aug| - expect(aug.match("entry").size).to eq(1) - expect(aug.get("entry/action/file")).to eq("/var/log/test.log") - expect(aug.match("entry/action/no_sync").size).to eq(0) + name: 'my test', + facility: 'local2', + level: '*', + action_type: 'file', + action: '/var/log/test.log', + target: target, + provider: 'augeas', + ensure: 'present' + )) + + aug_open(target, 'Syslog.lns') do |aug| + expect(aug.match('entry').size).to eq(1) + expect(aug.get('entry/action/file')).to eq('/var/log/test.log') + expect(aug.match('entry/action/no_sync').size).to eq(0) end end - it "should create hostname entry with tcp protocol" do + it 'creates hostname entry with tcp protocol' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true FileTest.stubs(:exist?).returns false @@ -42,41 +42,41 @@ if protocol_supported apply!(Puppet::Type.type(:syslog).new( - :name => "hostname test", - :facility => "*", - :level => "*", - :action_type => "hostname", - :action_protocol => "tcp", - :action => "remote-host", - :target => target, - :provider => "augeas", - :ensure => "present" - )) - - aug_open(target, "Syslog.lns") do |aug| - expect(aug.match("entry").size).to eq(1) - expect(aug.get("entry/action/protocol")).to eq("@@") - expect(aug.match("entry/action/port").size).to eq(0) + name: 'hostname test', + facility: '*', + level: '*', + action_type: 'hostname', + action_protocol: 'tcp', + action: 'remote-host', + target: target, + provider: 'augeas', + ensure: 'present' + )) + + aug_open(target, 'Syslog.lns') do |aug| + expect(aug.match('entry').size).to eq(1) + expect(aug.get('entry/action/protocol')).to eq('@@') + expect(aug.match('entry/action/port').size).to eq(0) end else txn = apply(Puppet::Type.type(:syslog).new( - :name => "hostname test", - :facility => "*", - :level => "*", - :action_type => "hostname", - :action_protocol => "tcp", - :action => "remote-host", - :target => target, - :provider => "augeas", - :ensure => "present" - )) + name: 'hostname test', + facility: '*', + level: '*', + action_type: 'hostname', + action_protocol: 'tcp', + action: 'remote-host', + target: target, + provider: 'augeas', + ensure: 'present' + )) expect(txn.any_failed?).not_to eq(nil) expect(@logs[0].level).to eq(:err) expect(@logs[0].message.include?('Protocol is not supported')).to eq(true) end end - it "should create hostname entry with udp protocol" do + it 'creates hostname entry with udp protocol' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true FileTest.stubs(:exist?).returns false @@ -84,59 +84,59 @@ if protocol_supported == :stock apply!(Puppet::Type.type(:syslog).new( - :name => "hostname test", - :facility => "*", - :level => "*", - :action_type => "hostname", - :action_protocol => "udp", - :action => "remote-host", - :target => target, - :provider => "augeas", - :ensure => "present" - )) - - aug_open(target, "Syslog.lns") do |aug| - expect(aug.match("entry").size).to eq(1) - expect(aug.get("entry/action/protocol")).to eq("@") - expect(aug.match("entry/action/port").size).to eq(0) + name: 'hostname test', + facility: '*', + level: '*', + action_type: 'hostname', + action_protocol: 'udp', + action: 'remote-host', + target: target, + provider: 'augeas', + ensure: 'present' + )) + + aug_open(target, 'Syslog.lns') do |aug| + expect(aug.match('entry').size).to eq(1) + expect(aug.get('entry/action/protocol')).to eq('@') + expect(aug.match('entry/action/port').size).to eq(0) end elsif protocol_supported == :el7 apply!(Puppet::Type.type(:syslog).new( - :name => "hostname test", - :facility => "*", - :level => "*", - :action_type => "hostname", - :action_protocol => "udp", - :action => "remote-host", - :target => target, - :provider => "augeas", - :ensure => "present" - )) - - aug_open(target, "Syslog.lns") do |aug| - expect(aug.match("entry").size).to eq(1) - expect(aug.match("entry/action/protocol").size).to eq(0) - expect(aug.match("entry/action/port").size).to eq(0) + name: 'hostname test', + facility: '*', + level: '*', + action_type: 'hostname', + action_protocol: 'udp', + action: 'remote-host', + target: target, + provider: 'augeas', + ensure: 'present' + )) + + aug_open(target, 'Syslog.lns') do |aug| + expect(aug.match('entry').size).to eq(1) + expect(aug.match('entry/action/protocol').size).to eq(0) + expect(aug.match('entry/action/port').size).to eq(0) end else txn = apply(Puppet::Type.type(:syslog).new( - :name => "hostname test", - :facility => "*", - :level => "*", - :action_type => "hostname", - :action_protocol => "udp", - :action => "remote-host", - :target => target, - :provider => "augeas", - :ensure => "present" - )) + name: 'hostname test', + facility: '*', + level: '*', + action_type: 'hostname', + action_protocol: 'udp', + action: 'remote-host', + target: target, + provider: 'augeas', + ensure: 'present' + )) expect(txn.any_failed?).not_to eq(nil) expect(@logs[0].level).to eq(:err) expect(@logs[0].message.include?('Protocol is not supported')).to eq(true) end end - it "should create hostname entry with port" do + it 'creates hostname entry with port' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true FileTest.stubs(:exist?).returns false @@ -144,36 +144,36 @@ if protocol_supported # port requires protocol apply!(Puppet::Type.type(:syslog).new( - :name => "hostname test", - :facility => "*", - :level => "*", - :action_type => "hostname", - :action_port => "514", - :action_protocol => "tcp", - :action => "remote-host", - :target => target, - :provider => "augeas", - :ensure => "present" - )) - - aug_open(target, "Syslog.lns") do |aug| - expect(aug.match("entry").size).to eq(1) - expect(aug.get("entry/action/protocol")).to eq("@@") - expect(aug.get("entry/action/port")).to eq("514") + name: 'hostname test', + facility: '*', + level: '*', + action_type: 'hostname', + action_port: '514', + action_protocol: 'tcp', + action: 'remote-host', + target: target, + provider: 'augeas', + ensure: 'present' + )) + + aug_open(target, 'Syslog.lns') do |aug| + expect(aug.match('entry').size).to eq(1) + expect(aug.get('entry/action/protocol')).to eq('@@') + expect(aug.get('entry/action/port')).to eq('514') end else txn = apply(Puppet::Type.type(:syslog).new( - :name => "hostname test", - :facility => "*", - :level => "*", - :action_type => "hostname", - :action_port => "514", - :action_protocol => "tcp", - :action => "remote-host", - :target => target, - :provider => "augeas", - :ensure => "present" - )) + name: 'hostname test', + facility: '*', + level: '*', + action_type: 'hostname', + action_port: '514', + action_protocol: 'tcp', + action: 'remote-host', + target: target, + provider: 'augeas', + ensure: 'present' + )) expect(txn.any_failed?).not_to eq(nil) expect(@logs[0].level).to eq(:err) expect(@logs[0].message.include?('Protocol is not supported')).to eq(true) @@ -181,157 +181,157 @@ end end - context "with full file" do - let(:tmptarget) { aug_fixture("full") } + context 'with full file' do + let(:tmptarget) { aug_fixture('full') } let(:target) { tmptarget.path } - it "should list instances" do + it 'lists instances' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true provider_class.stubs(:target).returns(target) - inst = provider_class.instances.map { |p| + inst = provider_class.instances.map do |p| { - :name => p.get(:name), - :ensure => p.get(:ensure), - :facility => p.get(:facility), - :level => p.get(:level), - :no_sync => p.get(:no_sync), - :action_type => p.get(:action_type), - :action_port => p.get(:action_port), - :action_protocol => p.get(:action_protocol), - :action => p.get(:action), + name: p.get(:name), + ensure: p.get(:ensure), + facility: p.get(:facility), + level: p.get(:level), + no_sync: p.get(:no_sync), + action_type: p.get(:action_type), + action_port: p.get(:action_port), + action_protocol: p.get(:action_protocol), + action: p.get(:action), } - } + end expect(inst.size).to eq(10) - expect(inst[0]).to eq({:name=>"*.info /var/log/messages", :ensure=>:present, :facility=>"*", :level=>"info", :no_sync=>:false, :action_type=>"file", :action=>"/var/log/messages", :action_port=>:absent, :action_protocol=>:absent}) - expect(inst[1]).to eq({:name=>"mail.none /var/log/messages", :ensure=>:present, :facility=>"mail", :level=>"none", :no_sync=>:false, :action_type=>"file", :action=>"/var/log/messages", :action_port=>:absent, :action_protocol=>:absent}) - expect(inst[5]).to eq({:name=>"mail.* -/var/log/maillog", :ensure=>:present, :facility=>"mail", :level=>"*", :no_sync=>:true, :action_type=>"file", :action=>"/var/log/maillog", :action_port=>:absent, :action_protocol=>:absent}) - expect(inst[8]).to eq({:name=>"uucp.crit /var/log/spooler", :ensure=>:present, :facility=>"uucp", :level=>"crit", :no_sync=>:false, :action_type=>"file", :action=>"/var/log/spooler", :action_port=>:absent, :action_protocol=>:absent}) - expect(inst[9]).to eq({:name=>"news.crit /var/log/spooler", :ensure=>:present, :facility=>"news", :level=>"crit", :no_sync=>:false, :action_type=>"file", :action=>"/var/log/spooler", :action_port=>:absent, :action_protocol=>:absent}) + expect(inst[0]).to eq({ name: '*.info /var/log/messages', ensure: :present, facility: '*', level: 'info', no_sync: :false, action_type: 'file', action: '/var/log/messages', action_port: :absent, action_protocol: :absent }) + expect(inst[1]).to eq({ name: 'mail.none /var/log/messages', ensure: :present, facility: 'mail', level: 'none', no_sync: :false, action_type: 'file', action: '/var/log/messages', action_port: :absent, action_protocol: :absent }) + expect(inst[5]).to eq({ name: 'mail.* -/var/log/maillog', ensure: :present, facility: 'mail', level: '*', no_sync: :true, action_type: 'file', action: '/var/log/maillog', action_port: :absent, action_protocol: :absent }) + expect(inst[8]).to eq({ name: 'uucp.crit /var/log/spooler', ensure: :present, facility: 'uucp', level: 'crit', no_sync: :false, action_type: 'file', action: '/var/log/spooler', action_port: :absent, action_protocol: :absent }) + expect(inst[9]).to eq({ name: 'news.crit /var/log/spooler', ensure: :present, facility: 'news', level: 'crit', no_sync: :false, action_type: 'file', action: '/var/log/spooler', action_port: :absent, action_protocol: :absent }) end - describe "when creating settings" do - it "should create a simple new entry" do + describe 'when creating settings' do + it 'creates a simple new entry' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true apply!(Puppet::Type.type(:syslog).new( - :name => "my test", - :facility => "local2", - :level => "info", - :action_type => "file", - :action => "/var/log/test.log", - :target => target, - :provider => "augeas", - :ensure => "present" - )) - - aug_open(target, "Syslog.lns") do |aug| - expect(aug.get("entry[selector/facility='local2']/action/file")).to eq("/var/log/test.log") + name: 'my test', + facility: 'local2', + level: 'info', + action_type: 'file', + action: '/var/log/test.log', + target: target, + provider: 'augeas', + ensure: 'present' + )) + + aug_open(target, 'Syslog.lns') do |aug| + expect(aug.get("entry[selector/facility='local2']/action/file")).to eq('/var/log/test.log') expect(aug.match("entry[selector/facility='local2']/action/no_sync").size).to eq(0) end end end - describe "when modifying settings" do - it "should add a no_sync flag" do + describe 'when modifying settings' do + it 'adds a no_sync flag' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true apply!(Puppet::Type.type(:syslog).new( - :name => "cron.*", - :facility => "cron", - :level => "*", - :action_type => "file", - :action => "/var/log/cron", - :target => target, - :no_sync => :true, - :provider => "augeas", - :ensure => "present" - )) - - aug_open(target, "Syslog.lns") do |aug| + name: 'cron.*', + facility: 'cron', + level: '*', + action_type: 'file', + action: '/var/log/cron', + target: target, + no_sync: :true, + provider: 'augeas', + ensure: 'present' + )) + + aug_open(target, 'Syslog.lns') do |aug| expect(aug.match("entry[selector/facility='cron']/action/no_sync").size).to eq(1) end end - it "should remove the no_sync flag" do + it 'removes the no_sync flag' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true apply!(Puppet::Type.type(:syslog).new( - :name => "mail.*", - :facility => "mail", - :level => "*", - :action_type => "file", - :action => "/var/log/maillog", - :target => target, - :no_sync => :false, - :provider => "augeas", - :ensure => "present" - )) - - aug_open(target, "Syslog.lns") do |aug| + name: 'mail.*', + facility: 'mail', + level: '*', + action_type: 'file', + action: '/var/log/maillog', + target: target, + no_sync: :false, + provider: 'augeas', + ensure: 'present' + )) + + aug_open(target, 'Syslog.lns') do |aug| expect(aug.match("entry[selector/facility='mail']/action/no_sync").size).to eq(0) end end end - describe "when removing settings" do - it "should remove the entry" do + describe 'when removing settings' do + it 'removes the entry' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true apply!(Puppet::Type.type(:syslog).new( - :name => "mail.*", - :facility => "mail", - :level => "*", - :action_type => "file", - :action => "/var/log/maillog", - :target => target, - :provider => "augeas", - :ensure => "absent" - )) - - aug_open(target, "Syslog.lns") do |aug| + name: 'mail.*', + facility: 'mail', + level: '*', + action_type: 'file', + action: '/var/log/maillog', + target: target, + provider: 'augeas', + ensure: 'absent' + )) + + aug_open(target, 'Syslog.lns') do |aug| expect(aug.match("entry[selector/facility='mail' and level='*']").size).to eq(0) end end end end - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } + context 'with broken file' do + let(:tmptarget) { aug_fixture('broken') } let(:target) { tmptarget.path } - it "should fail to load" do + it 'fails to load' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true txn = apply(Puppet::Type.type(:syslog).new( - :name => "mail.*", - :facility => "mail", - :level => "*", - :action_type => "file", - :action => "/var/log/maillog", - :target => target, - :provider => "augeas", - :ensure => "present" - )) + name: 'mail.*', + facility: 'mail', + level: '*', + action_type: 'file', + action: '/var/log/maillog', + target: target, + provider: 'augeas', + ensure: 'present' + )) expect(txn.any_failed?).not_to eq(nil) expect(@logs.first.level).to eq(:err) diff --git a/spec/unit/puppet/provider/syslog/rsyslog_spec.rb b/spec/unit/puppet/provider/syslog/rsyslog_spec.rb old mode 100644 new mode 100755 index e4dc8af..61fa9cb --- a/spec/unit/puppet/provider/syslog/rsyslog_spec.rb +++ b/spec/unit/puppet/provider/syslog/rsyslog_spec.rb @@ -8,38 +8,38 @@ def valid_lens? Puppet::Util::Package.versioncmp(Puppet::Type.type(:syslog).provider(:augeas).aug_version, '0.10.0') > 0 end -describe provider_class, :if => valid_lens? do +describe provider_class, if: valid_lens? do let(:protocol_supported) { subject.protocol_supported } - context "with empty file" do - let(:tmptarget) { aug_fixture("empty") } + context 'with empty file' do + let(:tmptarget) { aug_fixture('empty') } let(:target) { tmptarget.path } - it "should create simple new entry" do + it 'creates simple new entry' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true apply!(Puppet::Type.type(:syslog).new( - :name => "my test", - :facility => "local2", - :level => "*", - :action_type => "file", - :action => "/var/log/test.log", - :target => target, - :provider => "rsyslog", - :ensure => "present" - )) - - aug_open(target, "Rsyslog.lns") do |aug| - expect(aug.match("entry").size).to eq(1) - expect(aug.get("entry/action/file")).to eq("/var/log/test.log") - expect(aug.match("entry/action/no_sync").size).to eq(0) + name: 'my test', + facility: 'local2', + level: '*', + action_type: 'file', + action: '/var/log/test.log', + target: target, + provider: 'rsyslog', + ensure: 'present' + )) + + aug_open(target, 'Rsyslog.lns') do |aug| + expect(aug.match('entry').size).to eq(1) + expect(aug.get('entry/action/file')).to eq('/var/log/test.log') + expect(aug.match('entry/action/no_sync').size).to eq(0) end end - it "should create hostname entry with tcp protocol" do + it 'creates hostname entry with tcp protocol' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true FileTest.stubs(:exist?).returns false @@ -47,41 +47,41 @@ def valid_lens? if protocol_supported apply!(Puppet::Type.type(:syslog).new( - :name => "hostname test", - :facility => "*", - :level => "*", - :action_type => "hostname", - :action_protocol => "tcp", - :action => "remote-host", - :target => target, - :provider => "rsyslog", - :ensure => "present" - )) - - aug_open(target, "Rsyslog.lns") do |aug| - expect(aug.match("entry").size).to eq(1) - expect(aug.get("entry/action/protocol")).to eq("@@") - expect(aug.match("entry/action/port").size).to eq(0) + name: 'hostname test', + facility: '*', + level: '*', + action_type: 'hostname', + action_protocol: 'tcp', + action: 'remote-host', + target: target, + provider: 'rsyslog', + ensure: 'present' + )) + + aug_open(target, 'Rsyslog.lns') do |aug| + expect(aug.match('entry').size).to eq(1) + expect(aug.get('entry/action/protocol')).to eq('@@') + expect(aug.match('entry/action/port').size).to eq(0) end else txn = apply(Puppet::Type.type(:syslog).new( - :name => "hostname test", - :facility => "*", - :level => "*", - :action_type => "hostname", - :action_protocol => "tcp", - :action => "remote-host", - :target => target, - :provider => "rsyslog", - :ensure => "present" - )) + name: 'hostname test', + facility: '*', + level: '*', + action_type: 'hostname', + action_protocol: 'tcp', + action: 'remote-host', + target: target, + provider: 'rsyslog', + ensure: 'present' + )) expect(txn.any_failed?).not_to eq(nil) expect(@logs[0].level).to eq(:err) expect(@logs[0].message.include?('Protocol is not supported')).to eq(true) end end - it "should create hostname entry with udp protocol" do + it 'creates hostname entry with udp protocol' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true FileTest.stubs(:exist?).returns false @@ -89,96 +89,96 @@ def valid_lens? if protocol_supported == :stock apply!(Puppet::Type.type(:syslog).new( - :name => "hostname test", - :facility => "*", - :level => "*", - :action_type => "hostname", - :action_protocol => "udp", - :action => "remote-host", - :target => target, - :provider => "rsyslog", - :ensure => "present" - )) - - aug_open(target, "Rsyslog.lns") do |aug| - expect(aug.match("entry").size).to eq(1) - expect(aug.get("entry/action/protocol")).to eq("@") - expect(aug.match("entry/action/port").size).to eq(0) + name: 'hostname test', + facility: '*', + level: '*', + action_type: 'hostname', + action_protocol: 'udp', + action: 'remote-host', + target: target, + provider: 'rsyslog', + ensure: 'present' + )) + + aug_open(target, 'Rsyslog.lns') do |aug| + expect(aug.match('entry').size).to eq(1) + expect(aug.get('entry/action/protocol')).to eq('@') + expect(aug.match('entry/action/port').size).to eq(0) end elsif protocol_supported == :el7 apply!(Puppet::Type.type(:syslog).new( - :name => "hostname test", - :facility => "*", - :level => "*", - :action_type => "hostname", - :action_protocol => "udp", - :action => "remote-host", - :target => target, - :provider => "rsyslog", - :ensure => "present" - )) - - aug_open(target, "Rsyslog.lns") do |aug| - expect(aug.match("entry").size).to eq(1) - expect(aug.match("entry/action/protocol").size).to eq(0) - expect(aug.match("entry/action/port").size).to eq(0) + name: 'hostname test', + facility: '*', + level: '*', + action_type: 'hostname', + action_protocol: 'udp', + action: 'remote-host', + target: target, + provider: 'rsyslog', + ensure: 'present' + )) + + aug_open(target, 'Rsyslog.lns') do |aug| + expect(aug.match('entry').size).to eq(1) + expect(aug.match('entry/action/protocol').size).to eq(0) + expect(aug.match('entry/action/port').size).to eq(0) end else txn = apply(Puppet::Type.type(:syslog).new( - :name => "hostname test", - :facility => "*", - :level => "*", - :action_type => "hostname", - :action_protocol => "udp", - :action => "remote-host", - :target => target, - :provider => "rsyslog", - :ensure => "present" - )) + name: 'hostname test', + facility: '*', + level: '*', + action_type: 'hostname', + action_protocol: 'udp', + action: 'remote-host', + target: target, + provider: 'rsyslog', + ensure: 'present' + )) expect(txn.any_failed?).not_to eq(nil) expect(@logs[0].level).to eq(:err) expect(@logs[0].message.include?('Protocol is not supported')).to eq(true) end end - it "should create hostname entry with port" do + it 'creates hostname entry with port' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - if protocol_supported # port requires protocol + if protocol_supported # port requires protocol apply!(Puppet::Type.type(:syslog).new( - :name => "hostname test", - :facility => "*", - :level => "*", - :action_type => "hostname", - :action_port => "514", - :action_protocol => "tcp", - :action => "remote-host", - :target => target, - :provider => "rsyslog", - :ensure => "present" - )) - - aug_open(target, "Rsyslog.lns") do |aug| - expect(aug.match("entry").size).to eq(1) - expect(aug.get("entry/action/protocol")).to eq("@@") - expect(aug.get("entry/action/port")).to eq("514") + name: 'hostname test', + facility: '*', + level: '*', + action_type: 'hostname', + action_port: '514', + action_protocol: 'tcp', + action: 'remote-host', + target: target, + provider: 'rsyslog', + ensure: 'present' + )) + + aug_open(target, 'Rsyslog.lns') do |aug| + expect(aug.match('entry').size).to eq(1) + expect(aug.get('entry/action/protocol')).to eq('@@') + expect(aug.get('entry/action/port')).to eq('514') end else txn = apply(Puppet::Type.type(:syslog).new( - :name => "hostname test", - :facility => "*", - :level => "*", - :action_type => "hostname", - :action_port => "514", - :action_protocol => "tcp", - :action => "remote-host", - :target => target, - :provider => "rsyslog", - :ensure => "present" - )) + name: 'hostname test', + facility: '*', + level: '*', + action_type: 'hostname', + action_port: '514', + action_protocol: 'tcp', + action: 'remote-host', + target: target, + provider: 'rsyslog', + ensure: 'present' + )) expect(txn.any_failed?).not_to eq(nil) expect(@logs[0].level).to eq(:err) expect(@logs[0].message.include?('Protocol is not supported')).to eq(true) @@ -186,152 +186,152 @@ def valid_lens? end end - context "with full file" do - let(:tmptarget) { aug_fixture("full") } + context 'with full file' do + let(:tmptarget) { aug_fixture('full') } let(:target) { tmptarget.path } - it "should list instances" do + it 'lists instances' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true provider_class.stubs(:target).returns(target) - inst = provider_class.instances.map { |p| + inst = provider_class.instances.map do |p| { - :name => p.get(:name), - :ensure => p.get(:ensure), - :facility => p.get(:facility), - :level => p.get(:level), - :no_sync => p.get(:no_sync), - :action_type => p.get(:action_type), - :action_port => p.get(:action_port), - :action_protocol => p.get(:action_protocol), - :action => p.get(:action), + name: p.get(:name), + ensure: p.get(:ensure), + facility: p.get(:facility), + level: p.get(:level), + no_sync: p.get(:no_sync), + action_type: p.get(:action_type), + action_port: p.get(:action_port), + action_protocol: p.get(:action_protocol), + action: p.get(:action), } - } + end expect(inst.size).to eq(10) - expect(inst[0]).to eq({:name=>"*.info /var/log/messages", :ensure=>:present, :facility=>"*", :level=>"info", :no_sync=>:false, :action_type=>"file", :action=>"/var/log/messages", :action_port=>:absent, :action_protocol=>:absent}) - expect(inst[1]).to eq({:name=>"mail.none /var/log/messages", :ensure=>:present, :facility=>"mail", :level=>"none", :no_sync=>:false, :action_type=>"file", :action=>"/var/log/messages", :action_port=>:absent, :action_protocol=>:absent}) - expect(inst[5]).to eq({:name=>"mail.* -/var/log/maillog", :ensure=>:present, :facility=>"mail", :level=>"*", :no_sync=>:true, :action_type=>"file", :action=>"/var/log/maillog", :action_port=>:absent, :action_protocol=>:absent}) - expect(inst[8]).to eq({:name=>"news.crit /var/log/spooler", :ensure=>:present, :facility=>"news", :level=>"crit", :no_sync=>:false, :action_type=>"file", :action=>"/var/log/spooler", :action_port=>:absent, :action_protocol=>:absent}) - expect(inst[9]).to eq({:name=>"local7.* /var/log/boot.log", :ensure=>:present, :facility=>"local7", :level=>"*", :no_sync=>:false, :action_type=>"file", :action=>"/var/log/boot.log", :action_port=>:absent, :action_protocol=>:absent}) + expect(inst[0]).to eq({ name: '*.info /var/log/messages', ensure: :present, facility: '*', level: 'info', no_sync: :false, action_type: 'file', action: '/var/log/messages', action_port: :absent, action_protocol: :absent }) + expect(inst[1]).to eq({ name: 'mail.none /var/log/messages', ensure: :present, facility: 'mail', level: 'none', no_sync: :false, action_type: 'file', action: '/var/log/messages', action_port: :absent, action_protocol: :absent }) + expect(inst[5]).to eq({ name: 'mail.* -/var/log/maillog', ensure: :present, facility: 'mail', level: '*', no_sync: :true, action_type: 'file', action: '/var/log/maillog', action_port: :absent, action_protocol: :absent }) + expect(inst[8]).to eq({ name: 'news.crit /var/log/spooler', ensure: :present, facility: 'news', level: 'crit', no_sync: :false, action_type: 'file', action: '/var/log/spooler', action_port: :absent, action_protocol: :absent }) + expect(inst[9]).to eq({ name: 'local7.* /var/log/boot.log', ensure: :present, facility: 'local7', level: '*', no_sync: :false, action_type: 'file', action: '/var/log/boot.log', action_port: :absent, action_protocol: :absent }) end - describe "when creating settings" do - it "should create a simple new entry" do + describe 'when creating settings' do + it 'creates a simple new entry' do apply!(Puppet::Type.type(:syslog).new( - :name => "my test", - :facility => "local2", - :level => "info", - :action_type => "file", - :action => "/var/log/test.log", - :target => target, - :provider => "rsyslog", - :ensure => "present" - )) - - aug_open(target, "Rsyslog.lns") do |aug| - expect(aug.get("entry[selector/facility='local2']/action/file")).to eq("/var/log/test.log") + name: 'my test', + facility: 'local2', + level: 'info', + action_type: 'file', + action: '/var/log/test.log', + target: target, + provider: 'rsyslog', + ensure: 'present' + )) + + aug_open(target, 'Rsyslog.lns') do |aug| + expect(aug.get("entry[selector/facility='local2']/action/file")).to eq('/var/log/test.log') expect(aug.match("entry[selector/facility='local2']/action/no_sync").size).to eq(0) end end end - describe "when modifying settings" do - it "should add a no_sync flag" do + describe 'when modifying settings' do + it 'adds a no_sync flag' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true apply!(Puppet::Type.type(:syslog).new( - :name => "cron.*", - :facility => "cron", - :level => "*", - :action_type => "file", - :action => "/var/log/cron", - :target => target, - :no_sync => :true, - :provider => "rsyslog", - :ensure => "present" - )) - - aug_open(target, "Rsyslog.lns") do |aug| + name: 'cron.*', + facility: 'cron', + level: '*', + action_type: 'file', + action: '/var/log/cron', + target: target, + no_sync: :true, + provider: 'rsyslog', + ensure: 'present' + )) + + aug_open(target, 'Rsyslog.lns') do |aug| expect(aug.match("entry[selector/facility='cron']/action/no_sync").size).to eq(1) end end - it "should remove the no_sync flag" do + it 'removes the no_sync flag' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true apply!(Puppet::Type.type(:syslog).new( - :name => "mail.*", - :facility => "mail", - :level => "*", - :action_type => "file", - :action => "/var/log/maillog", - :target => target, - :no_sync => :false, - :provider => "rsyslog", - :ensure => "present" - )) - - aug_open(target, "Rsyslog.lns") do |aug| + name: 'mail.*', + facility: 'mail', + level: '*', + action_type: 'file', + action: '/var/log/maillog', + target: target, + no_sync: :false, + provider: 'rsyslog', + ensure: 'present' + )) + + aug_open(target, 'Rsyslog.lns') do |aug| expect(aug.match("entry[selector/facility='mail']/action/no_sync").size).to eq(0) end end end - describe "when removing settings" do - it "should remove the entry" do + describe 'when removing settings' do + it 'removes the entry' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true apply!(Puppet::Type.type(:syslog).new( - :name => "mail.*", - :facility => "mail", - :level => "*", - :action_type => "file", - :action => "/var/log/maillog", - :target => target, - :provider => "rsyslog", - :ensure => "absent" - )) - - aug_open(target, "Rsyslog.lns") do |aug| + name: 'mail.*', + facility: 'mail', + level: '*', + action_type: 'file', + action: '/var/log/maillog', + target: target, + provider: 'rsyslog', + ensure: 'absent' + )) + + aug_open(target, 'Rsyslog.lns') do |aug| expect(aug.match("entry[selector/facility='mail' and level='*']").size).to eq(0) end end end end - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } + context 'with broken file' do + let(:tmptarget) { aug_fixture('broken') } let(:target) { tmptarget.path } - it "should fail to load" do + it 'fails to load' do FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true FileTest.stubs(:exist?).returns false FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true txn = apply(Puppet::Type.type(:syslog).new( - :name => "mail.*", - :facility => "mail", - :level => "*", - :action_type => "file", - :action => "/var/log/maillog", - :target => target, - :provider => "rsyslog", - :ensure => "present" - )) + name: 'mail.*', + facility: 'mail', + level: '*', + action_type: 'file', + action: '/var/log/maillog', + target: target, + provider: 'rsyslog', + ensure: 'present' + )) expect(txn.any_failed?).not_to eq(nil) expect(@logs.first.level).to eq(:err) From a65b9323895c60e2beca08b85b7eefa9950d1bbc Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 15 Dec 2023 12:10:26 +0100 Subject: [PATCH 12/15] modulesync 7.2.0 --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 2 +- .msync.yml | 2 +- .pmtignore | 1 + .rubocop.yml | 3 +-- Gemfile | 8 +++----- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b18ef3..d6e7fc4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ concurrency: jobs: puppet: name: Puppet - uses: voxpupuli/gha-puppet/.github/workflows/basic.yml@v1 + uses: voxpupuli/gha-puppet/.github/workflows/basic.yml@v2 with: additional_packages: 'libaugeas-dev augeas-tools' rubocop: false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 15f1721..55324aa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,7 @@ on: jobs: release: name: Release - uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v1 + uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v2 with: allowed_owner: 'voxpupuli' secrets: diff --git a/.msync.yml b/.msync.yml index dd3e957..f818344 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: '7.0.0' +modulesync_config_version: '7.2.0' diff --git a/.pmtignore b/.pmtignore index 58a0408..10b9830 100644 --- a/.pmtignore +++ b/.pmtignore @@ -35,3 +35,4 @@ /.yardoc/ /.yardopts /Dockerfile +/HISTORY.md diff --git a/.rubocop.yml b/.rubocop.yml index ea22bff..fded90c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,8 +1,7 @@ --- -inherit_from: .rubocop_todo.yml - # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ +inherit_from: .rubocop_todo.yml inherit_gem: voxpupuli-test: rubocop.yml diff --git a/Gemfile b/Gemfile index 7221ee1..b61ba2a 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ group :test do gem 'voxpupuli-test', '~> 7.0', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false - gem 'puppet_metadata', '~> 3.0', :require => false + gem 'puppet_metadata', '~> 3.5', :require => false gem 'ruby-augeas', :require => false end @@ -17,13 +17,11 @@ group :development do end group :system_tests do - gem 'voxpupuli-acceptance', '~> 2.0', :require => false + gem 'voxpupuli-acceptance', '~> 3.0', :require => false end group :release do - gem 'github_changelog_generator', '>= 1.16.1', :require => false - gem 'voxpupuli-release', '~> 3.0', :require => false - gem 'faraday-retry', '~> 2.1', :require => false + gem 'voxpupuli-release', '~> 3.0', :require => false end gem 'rake', :require => false From 56f87c34a5f00e64d471e00e93bd825dcf7062a7 Mon Sep 17 00:00:00 2001 From: markuszilch Date: Tue, 6 Feb 2024 12:27:04 +0100 Subject: [PATCH 13/15] modulesync 7.3.0 --- .github/workflows/ci.yml | 7 ++++++- .msync.yml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d6e7fc4..318d583 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,12 @@ name: CI -on: pull_request +on: + pull_request: {} + push: + branches: + - main + - master concurrency: group: ${{ github.ref_name }} diff --git a/.msync.yml b/.msync.yml index f818344..f46ee02 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: '7.2.0' +modulesync_config_version: '7.3.0' From e5f2289dcab649ab2b4423214dab2f8dbf391446 Mon Sep 17 00:00:00 2001 From: markuszilch Date: Wed, 3 Apr 2024 13:33:40 +0200 Subject: [PATCH 14/15] replace stubs with rspec syntax --- .../provider/rsyslog_filter/augeas_spec.rb | 58 ++++++------- .../puppet/provider/syslog/augeas_spec.rb | 82 +++++++++---------- .../puppet/provider/syslog/rsyslog_spec.rb | 74 ++++++++--------- 3 files changed, 107 insertions(+), 107 deletions(-) diff --git a/spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb b/spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb index cb4bce4..149f2e0 100755 --- a/spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb +++ b/spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb @@ -11,10 +11,10 @@ let(:target) { tmptarget.path } it 'creates new entry with file' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:rsyslog_filter).new( name: 'my test', @@ -36,10 +36,10 @@ end it 'creates new entry with protocol/hostname/port' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:rsyslog_filter).new( name: 'my test', @@ -68,12 +68,12 @@ let(:target) { tmptarget.path } it 'lists instances' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) - provider_class.stubs(:target).returns(target) + allow(provider_class).to receive(:target).and_return(target) inst = provider_class.instances.map do |p| { name: p.get(:name), @@ -104,10 +104,10 @@ describe 'when creating settings' do it 'creates a simple new entry' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:rsyslog_filter).new( name: 'my test', @@ -129,10 +129,10 @@ describe 'when modifying settings' do it 'uses file' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:rsyslog_filter).new( name: 'ssh', @@ -154,10 +154,10 @@ describe 'when removing settings' do it 'removes the entry' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:rsyslog_filter).new( name: 'ssh', @@ -183,10 +183,10 @@ let(:target) { tmptarget.path } it 'fails to load' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) txn = apply(Puppet::Type.type(:rsyslog_filter).new( name: 'ssh', diff --git a/spec/unit/puppet/provider/syslog/augeas_spec.rb b/spec/unit/puppet/provider/syslog/augeas_spec.rb index ec1844b..8b6b68e 100755 --- a/spec/unit/puppet/provider/syslog/augeas_spec.rb +++ b/spec/unit/puppet/provider/syslog/augeas_spec.rb @@ -11,10 +11,10 @@ let(:target) { tmptarget.path } it 'creates simple new entry' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:syslog).new( name: 'my test', @@ -35,10 +35,10 @@ end it 'creates hostname entry with tcp protocol' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) if protocol_supported apply!(Puppet::Type.type(:syslog).new( @@ -77,10 +77,10 @@ end it 'creates hostname entry with udp protocol' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) if protocol_supported == :stock apply!(Puppet::Type.type(:syslog).new( @@ -137,10 +137,10 @@ end it 'creates hostname entry with port' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) if protocol_supported # port requires protocol apply!(Puppet::Type.type(:syslog).new( @@ -186,12 +186,12 @@ let(:target) { tmptarget.path } it 'lists instances' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) - provider_class.stubs(:target).returns(target) + allow(provider_class).to receive(:target).and_return(target) inst = provider_class.instances.map do |p| { name: p.get(:name), @@ -216,10 +216,10 @@ describe 'when creating settings' do it 'creates a simple new entry' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:syslog).new( name: 'my test', @@ -241,10 +241,10 @@ describe 'when modifying settings' do it 'adds a no_sync flag' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:syslog).new( name: 'cron.*', @@ -264,10 +264,10 @@ end it 'removes the no_sync flag' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:syslog).new( name: 'mail.*', @@ -289,10 +289,10 @@ describe 'when removing settings' do it 'removes the entry' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:syslog).new( name: 'mail.*', @@ -317,10 +317,10 @@ let(:target) { tmptarget.path } it 'fails to load' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) txn = apply(Puppet::Type.type(:syslog).new( name: 'mail.*', diff --git a/spec/unit/puppet/provider/syslog/rsyslog_spec.rb b/spec/unit/puppet/provider/syslog/rsyslog_spec.rb index 61fa9cb..e129d57 100755 --- a/spec/unit/puppet/provider/syslog/rsyslog_spec.rb +++ b/spec/unit/puppet/provider/syslog/rsyslog_spec.rb @@ -16,10 +16,10 @@ def valid_lens? let(:target) { tmptarget.path } it 'creates simple new entry' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:syslog).new( name: 'my test', @@ -40,10 +40,10 @@ def valid_lens? end it 'creates hostname entry with tcp protocol' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) if protocol_supported apply!(Puppet::Type.type(:syslog).new( @@ -82,10 +82,10 @@ def valid_lens? end it 'creates hostname entry with udp protocol' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) if protocol_supported == :stock apply!(Puppet::Type.type(:syslog).new( @@ -142,10 +142,10 @@ def valid_lens? end it 'creates hostname entry with port' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) if protocol_supported # port requires protocol apply!(Puppet::Type.type(:syslog).new( @@ -191,12 +191,12 @@ def valid_lens? let(:target) { tmptarget.path } it 'lists instances' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) - provider_class.stubs(:target).returns(target) + allow(provider_class).to receive(:target).and_return(target) inst = provider_class.instances.map do |p| { name: p.get(:name), @@ -241,10 +241,10 @@ def valid_lens? describe 'when modifying settings' do it 'adds a no_sync flag' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:syslog).new( name: 'cron.*', @@ -264,10 +264,10 @@ def valid_lens? end it 'removes the no_sync flag' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:syslog).new( name: 'mail.*', @@ -289,10 +289,10 @@ def valid_lens? describe 'when removing settings' do it 'removes the entry' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:syslog).new( name: 'mail.*', @@ -317,10 +317,10 @@ def valid_lens? let(:target) { tmptarget.path } it 'fails to load' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) txn = apply(Puppet::Type.type(:syslog).new( name: 'mail.*', From 6e0b8a05d0e05a8f2dc1938405cf6f294e40c8ad Mon Sep 17 00:00:00 2001 From: markuszilch Date: Wed, 3 Apr 2024 13:39:38 +0200 Subject: [PATCH 15/15] remove shebang and fix file permissions --- spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb | 2 -- spec/unit/puppet/provider/syslog/augeas_spec.rb | 2 -- spec/unit/puppet/provider/syslog/rsyslog_spec.rb | 2 -- 3 files changed, 6 deletions(-) mode change 100755 => 100644 spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb mode change 100755 => 100644 spec/unit/puppet/provider/syslog/augeas_spec.rb mode change 100755 => 100644 spec/unit/puppet/provider/syslog/rsyslog_spec.rb diff --git a/spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb b/spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb old mode 100755 new mode 100644 index 149f2e0..9cedc2b --- a/spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb +++ b/spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb @@ -1,5 +1,3 @@ -#!/usr/bin/env rspec - require 'spec_helper' provider_class = Puppet::Type.type(:rsyslog_filter).provider(:augeas) diff --git a/spec/unit/puppet/provider/syslog/augeas_spec.rb b/spec/unit/puppet/provider/syslog/augeas_spec.rb old mode 100755 new mode 100644 index 8b6b68e..6025c78 --- a/spec/unit/puppet/provider/syslog/augeas_spec.rb +++ b/spec/unit/puppet/provider/syslog/augeas_spec.rb @@ -1,5 +1,3 @@ -#!/usr/bin/env rspec - require 'spec_helper' provider_class = Puppet::Type.type(:syslog).provider(:augeas) diff --git a/spec/unit/puppet/provider/syslog/rsyslog_spec.rb b/spec/unit/puppet/provider/syslog/rsyslog_spec.rb old mode 100755 new mode 100644 index e129d57..bc46b38 --- a/spec/unit/puppet/provider/syslog/rsyslog_spec.rb +++ b/spec/unit/puppet/provider/syslog/rsyslog_spec.rb @@ -1,5 +1,3 @@ -#!/usr/bin/env rspec - require 'spec_helper' provider_class = Puppet::Type.type(:syslog).provider(:rsyslog)