diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..d77700e3 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +# editorconfig.org + +# MANAGED BY 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 00000000..cace33e6 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,283 @@ +# 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. [travis-ci](http://travis-ci.org) runs 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 +bundle exec rake acceptance +``` + +This will run the tests on the module's default nodeset. You can override the +nodeset used, e.g., + +```sh +BEAKER_set=centos-7-x64 bundle exec rake acceptance +``` + +There are default rake tasks for the various acceptance test modules, e.g., + +```sh +bundle exec rake beaker:centos-7-x64 +bundle exec rake beaker:ssh:centos-7-x64 +``` + +If you don't want to have to recreate the virtual machine every time you can +use `BEAKER_destroy=no` and `BEAKER_provision=no`. On the first run you will at +least need `BEAKER_provision` set to yes (the default). The Vagrantfile for the +created virtual machines will be in `.vagrant/beaker_vagrant_files`. + +Beaker also supports docker containers. We also use that in our automated CI +pipeline at [travis-ci](http://travis-ci.org). To use that instead of Vagrant: + +```sh +PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian10-64{hypervisor=docker} BEAKER_destroy=yes 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 +* centos6 +* centos7 +* centos8 + +The easiest way to debug in a docker container is to open a shell: + +```sh +docker exec -it -u root ${container_id_or_name} bash +``` + +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 00000000..593e7aa8 --- /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 00000000..342807bc --- /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 00000000..cacadf22 --- /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/.gitignore b/.gitignore index 5e135f2d..e9b3cf4b 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,3 @@ Puppetfile.lock .*.sw? .yardoc/ Guardfile -spec/fixtures/tmpdir/ diff --git a/.msync.yml b/.msync.yml new file mode 100644 index 00000000..5758aced --- /dev/null +++ b/.msync.yml @@ -0,0 +1,2 @@ +--- +modulesync_config_version: '3.1.0' diff --git a/.overcommit.yml b/.overcommit.yml new file mode 100644 index 00000000..0af0fdc0 --- /dev/null +++ b/.overcommit.yml @@ -0,0 +1,64 @@ +# Managed by https://github.com/voxpupuli/modulesync_configs +# +# 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 00000000..4e6d54b8 --- /dev/null +++ b/.pmtignore @@ -0,0 +1,21 @@ +docs/ +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/ +Dockerfile diff --git a/.rspec_parallel b/.rspec_parallel new file mode 100644 index 00000000..e4d136b7 --- /dev/null +++ b/.rspec_parallel @@ -0,0 +1 @@ +--format progress diff --git a/.rubocop.yml b/.rubocop.yml index c2ebc88d..198a3599 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,546 +1,3 @@ -require: rubocop-rspec -AllCops: -# Puppet Server 5 defaults to jruby 1.7 so TargetRubyVersion must stay at 1.9 until we drop support for puppet 5 - TargetRubyVersion: 1.9 - Include: - - ./**/*.rb - Exclude: - - files/**/* - - vendor/**/* - - .vendor/**/* - - pkg/**/* - - spec/fixtures/**/* - - Gemfile - - Rakefile - - Guardfile - - Vagrantfile -Lint/ConditionPosition: - Enabled: True - -Lint/ElseLayout: - Enabled: True - -Lint/UnreachableCode: - Enabled: True - -Lint/UselessComparison: - Enabled: True - -Lint/EnsureReturn: - Enabled: True - -Lint/HandleExceptions: - Enabled: True - -Lint/LiteralInCondition: - Enabled: True - -Lint/ShadowingOuterLocalVariable: - Enabled: True - -Lint/LiteralInInterpolation: - Enabled: True - -Style/HashSyntax: - Enabled: True - -Style/RedundantReturn: - Enabled: True - -Layout/EndOfLine: - Enabled: False - -Lint/AmbiguousOperator: - Enabled: True - -Lint/AssignmentInCondition: - Enabled: True - -Layout/SpaceBeforeComment: - Enabled: True - -Style/AndOr: - Enabled: True - -Style/RedundantSelf: - Enabled: True - -Metrics/BlockLength: - Enabled: False - -# Method length is not necessarily an indicator of code quality -Metrics/MethodLength: - Enabled: False - -# Module length is not necessarily an indicator of code quality -Metrics/ModuleLength: - Enabled: False - -Style/WhileUntilModifier: - Enabled: True - -Lint/AmbiguousRegexpLiteral: - Enabled: True - -Security/Eval: - Enabled: True - -Lint/BlockAlignment: - Enabled: True - -Lint/DefEndAlignment: - Enabled: True - -Lint/EndAlignment: - Enabled: True - -Lint/DeprecatedClassMethods: - Enabled: True - -Lint/Loop: - Enabled: True - -Lint/ParenthesesAsGroupedExpression: - Enabled: True - -Lint/RescueException: - Enabled: True - -Lint/StringConversionInInterpolation: - Enabled: True - -Lint/UnusedBlockArgument: - Enabled: True - -Lint/UnusedMethodArgument: - Enabled: True - -Lint/UselessAccessModifier: - Enabled: True - -Lint/UselessAssignment: - Enabled: True - -Lint/Void: - Enabled: True - -Layout/AccessModifierIndentation: - Enabled: True - -Style/AccessorMethodName: - Enabled: True - -Style/Alias: - Enabled: True - -Layout/AlignArray: - Enabled: True - -Layout/AlignHash: - Enabled: True - -Layout/AlignParameters: - Enabled: True - -Metrics/BlockNesting: - Enabled: True - -Style/AsciiComments: - Enabled: True - -Style/Attr: - Enabled: True - -Style/BracesAroundHashParameters: - Enabled: True - -Style/CaseEquality: - Enabled: True - -Layout/CaseIndentation: - Enabled: True - -Style/CharacterLiteral: - Enabled: True - -Style/ClassAndModuleCamelCase: - Enabled: True - -Style/ClassAndModuleChildren: - Enabled: False - -Style/ClassCheck: - Enabled: True - -# Class length is not necessarily an indicator of code quality -Metrics/ClassLength: - Enabled: False - -Style/ClassMethods: - Enabled: True - -Style/ClassVars: - Enabled: True - -Style/WhenThen: - Enabled: True - -Style/WordArray: - Enabled: True - -Style/UnneededPercentQ: - Enabled: True - -Layout/Tab: - Enabled: True - -Layout/SpaceBeforeSemicolon: - Enabled: True - -Layout/TrailingBlankLines: - Enabled: True - -Layout/SpaceInsideBlockBraces: - Enabled: True - -Layout/SpaceInsideBrackets: - Enabled: True - -Layout/SpaceInsideHashLiteralBraces: - Enabled: True - -Layout/SpaceInsideParens: - Enabled: True - -Layout/LeadingCommentSpace: - Enabled: True - -Layout/SpaceBeforeFirstArg: - Enabled: True - -Layout/SpaceAfterColon: - Enabled: True - -Layout/SpaceAfterComma: - Enabled: True - -Layout/SpaceAfterMethodName: - Enabled: True - -Layout/SpaceAfterNot: - Enabled: True - -Layout/SpaceAfterSemicolon: - Enabled: True - -Layout/SpaceAroundEqualsInParameterDefault: - Enabled: True - -Layout/SpaceAroundOperators: - Enabled: True - -Layout/SpaceBeforeBlockBraces: - Enabled: True - -Layout/SpaceBeforeComma: - Enabled: True - -Style/CollectionMethods: - Enabled: True - -Layout/CommentIndentation: - Enabled: True - -Style/ColonMethodCall: - Enabled: True - -Style/CommentAnnotation: - Enabled: True - -# 'Complexity' is very relative -Metrics/CyclomaticComplexity: - Enabled: False - -Style/ConstantName: - Enabled: True - -Style/Documentation: - Enabled: False - -Style/DefWithParentheses: - Enabled: True - -Style/PreferredHashMethods: - Enabled: True - -Layout/DotPosition: - EnforcedStyle: trailing - -Style/DoubleNegation: - Enabled: True - -Style/EachWithObject: - Enabled: True - -Layout/EmptyLineBetweenDefs: - Enabled: True - -Layout/IndentArray: - Enabled: True - -Layout/IndentHash: - Enabled: True - -Layout/IndentationConsistency: - Enabled: True - -Layout/IndentationWidth: - Enabled: True - -Layout/EmptyLines: - Enabled: True - -Layout/EmptyLinesAroundAccessModifier: - Enabled: True - -Style/EmptyLiteral: - Enabled: True - -# Configuration parameters: AllowURI, URISchemes. -Metrics/LineLength: - Enabled: False - -Style/MethodCallWithoutArgsParentheses: - Enabled: True - -Style/MethodDefParentheses: - Enabled: True - -Style/LineEndConcatenation: - Enabled: True - -Layout/TrailingWhitespace: - Enabled: True - -Style/StringLiterals: - Enabled: True - -Style/TrailingCommaInArguments: - Enabled: True - -Style/TrailingCommaInLiteral: - Enabled: True - -Style/GlobalVars: - Enabled: True - -Style/GuardClause: - Enabled: True - -Style/IfUnlessModifier: - Enabled: True - -Style/MultilineIfThen: - Enabled: True - -Style/NegatedIf: - Enabled: True - -Style/NegatedWhile: - Enabled: True - -Style/Next: - Enabled: True - -Style/SingleLineBlockParams: - Enabled: True - -Style/SingleLineMethods: - Enabled: True - -Style/SpecialGlobalVars: - Enabled: True - -Style/TrivialAccessors: - Enabled: True - -Style/UnlessElse: - Enabled: True - -Style/VariableInterpolation: - Enabled: True - -Style/VariableName: - Enabled: True - -Style/WhileUntilDo: - Enabled: True - -Style/EvenOdd: - Enabled: True - -Style/FileName: - Enabled: True - -Style/For: - Enabled: True - -Style/Lambda: - Enabled: True - -Style/MethodName: - Enabled: True - -Style/MultilineTernaryOperator: - Enabled: True - -Style/NestedTernaryOperator: - Enabled: True - -Style/NilComparison: - Enabled: True - -Style/FormatString: - Enabled: True - -Style/MultilineBlockChain: - Enabled: True - -Style/Semicolon: - Enabled: True - -Style/SignalException: - Enabled: True - -Style/NonNilCheck: - Enabled: True - -Style/Not: - Enabled: True - -Style/NumericLiterals: - Enabled: True - -Style/OneLineConditional: - Enabled: True - -Style/OpMethod: - Enabled: True - -Style/ParenthesesAroundCondition: - Enabled: True - -Style/PercentLiteralDelimiters: - Enabled: True - -Style/PerlBackrefs: - Enabled: True - -Style/PredicateName: - Enabled: True - -Style/RedundantException: - Enabled: True - -Style/SelfAssignment: - Enabled: True - -Style/Proc: - Enabled: True - -Style/RaiseArgs: - Enabled: True - -Style/RedundantBegin: - Enabled: True - -Style/RescueModifier: - Enabled: True - -# based on https://github.com/voxpupuli/modulesync_config/issues/168 -Style/RegexpLiteral: - EnforcedStyle: percent_r - Enabled: True - -Lint/UnderscorePrefixedVariableName: - Enabled: True - -Metrics/ParameterLists: - Enabled: False - -Lint/RequireParentheses: - Enabled: True - -Style/ModuleFunction: - Enabled: True - -Lint/Debugger: - Enabled: True - -Style/IfWithSemicolon: - Enabled: True - -Style/Encoding: - Enabled: True - -Style/BlockDelimiters: - Enabled: True - -Layout/MultilineBlockLayout: - Enabled: True - -# 'Complexity' is very relative -Metrics/AbcSize: - Enabled: False - -# 'Complexity' is very relative -Metrics/PerceivedComplexity: - Enabled: False - -Lint/UselessAssignment: - Enabled: True - -Layout/ClosingParenthesisIndentation: - Enabled: True - -# RSpec - -RSpec/BeforeAfterAll: - Exclude: - - spec/acceptance/**/* - -# We don't use rspec in this way -RSpec/DescribeClass: - Enabled: False - -# Example length is not necessarily an indicator of code quality -RSpec/ExampleLength: - Enabled: False - -RSpec/NamedSubject: - Enabled: False - -# disabled for now since they cause a lot of issues -# these issues aren't easy to fix -RSpec/RepeatedDescription: - Enabled: False - -RSpec/NestedGroups: - Enabled: False - -# this is broken on ruby1.9 -Layout/IndentHeredoc: - Enabled: False - -# disable Yaml safe_load. This is needed to support ruby2.0.0 development envs -Security/YAMLLoad: - Enabled: false - -# This affects hiera interpolation, as well as some configs that we push. -Style/FormatStringToken: - Enabled: false - -# This is useful, but sometimes a little too picky about where unit tests files -# are located. -RSpec/FilePath: - Enabled: false +--- +inherit_gem: + voxpupuli-test: rubocop.yml diff --git a/.sync.yml b/.sync.yml index 0b8bb4d4..401ad80a 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,13 +1,30 @@ -Gemfile: - puppet_version: '>= 3.0' -Rakefile: - strict_variables: false -spec/spec_helper_acceptance.rb: - modules: - - name: stahnma-epel - version: 0.1.0 - osfamily: RedHat - - name: puppetlabs-apache - version: 1.1.0 .travis.yml: - forge_password: "P0disPGZg4I9kuO98yZOPxpdJjBWV+3U9iFCfRKpCO4jzBiqkCaofnr79Iy+7aqyWAKdbp54JUIbKenvz+WixbVjxvJNiTV991B6anaDXOZfk5oudoxy+hMmkor881ZznWJgwaim4BA3qcTghpIhMSqFP5FF0CaJUfzTEaj73s8=" + secure: "NY8Ff5WxEBSitFLOeRDAwkp48+HQuDbqGT96nB+5FTfiTTS/yY134hsWlfnEVrFNvC09f36wh8XXEkW6cTgIBdfeb3ZLVkUg545Ae0m46RouPwwl6goo9fsGEEBoJXhln9gk6UQpkjbKh9tCDLij3WKDxrDUIb/8Xlp3WkzAhCQ=" +spec/acceptance/nodesets/archlinux-2-x64.yml: + delete: true +spec/acceptance/nodesets/centos-65-x64-docker.yml: + delete: true +spec/acceptance/nodesets/centos-65-x64.yml: + delete: true +spec/acceptance/nodesets/debian-7-x64-docker.yml: + delete: true +spec/acceptance/nodesets/debian-7-x64.yml: + delete: true +spec/acceptance/nodesets/debian-73-x64.yml: + delete: true +spec/acceptance/nodesets/default.yml: + delete: true +spec/acceptance/nodesets/ec2/amazonlinux-2016091.yml: + delete: true +spec/acceptance/nodesets/ec2/image_templates.yaml: + delete: true +spec/acceptance/nodesets/ec2/rhel-73-x64.yml: + delete: true +spec/acceptance/nodesets/ec2/sles-12sp2-x64.yml: + delete: true +spec/acceptance/nodesets/ec2/ubuntu-1604-x64.yml: + delete: true +spec/acceptance/nodesets/ec2/windows-2016-base-x64.yml: + delete: true +spec/acceptance/nodesets/ubuntu-server-1404-x64-docker.yml: + delete: true diff --git a/.travis.yml b/.travis.yml index e3807878..d630ffe3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ --- -dist: bionic +# yamllint disable rule:line-length rule:truthy +os: linux +dist: focal language: ruby cache: bundler before_install: @@ -7,19 +9,25 @@ before_install: - bundle --version script: - 'bundle exec rake $CHECK' -matrix: +jobs: fast_finish: true include: - - rvm: 2.4.4 - bundler_args: --without system_tests development release - env: PUPPET_VERSION="~> 5.0" CHECK=test - - rvm: 2.5.3 - bundler_args: --without system_tests development release - env: PUPPET_VERSION="~> 6.0" CHECK=test_with_coveralls + - rvm: 2.4.4 + bundler_args: --without system_tests development release + env: PUPPET_VERSION="~> 5.0" CHECK=test + - rvm: 2.5.3 + bundler_args: --without system_tests development release + env: PUPPET_VERSION="~> 6.0" CHECK=test_with_coveralls + - rvm: 2.5.3 + bundler_args: --without system_tests development release + env: PUPPET_VERSION="~> 6.0" CHECK=rubocop + - rvm: 2.4.4 + bundler_args: --without system_tests development release + env: PUPPET_VERSION="~> 5.0" CHECK=build DEPLOY_TO_FORGE=yes branches: only: - - master - - /^v\d/ + - master + - /^v\d/ notifications: email: false webhooks: https://voxpupu.li/incoming/travis @@ -28,3 +36,14 @@ notifications: on_failure: always channels: - "chat.freenode.org#voxpupuli-notifications" +deploy: + provider: puppetforge + username: puppet + password: + secure: "NY8Ff5WxEBSitFLOeRDAwkp48+HQuDbqGT96nB+5FTfiTTS/yY134hsWlfnEVrFNvC09f36wh8XXEkW6cTgIBdfeb3ZLVkUg545Ae0m46RouPwwl6goo9fsGEEBoJXhln9gk6UQpkjbKh9tCDLij3WKDxrDUIb/8Xlp3WkzAhCQ=" + on: + tags: true + # all_branches is required to use tags + all_branches: true + # Only publish the build marked with "DEPLOY_TO_FORGE" + condition: "$DEPLOY_TO_FORGE = yes" diff --git a/.yardopts b/.yardopts new file mode 100644 index 00000000..3687f518 --- /dev/null +++ b/.yardopts @@ -0,0 +1,2 @@ +--markup markdown +--output-dir docs/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..6fd63422 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM ruby:2.5.3 + +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 8b4adb5c..2fce93ce 100644 --- a/Gemfile +++ b/Gemfile @@ -11,27 +11,9 @@ def location_for(place, fake_version = nil) end group :test do - gem 'puppetlabs_spec_helper', '>= 2.14.0', :require => false - gem 'rspec-puppet-facts', '>= 1.9.5', :require => false - gem 'rspec-puppet-utils', :require => false - gem 'puppet-lint-leading_zero-check', :require => false - gem 'puppet-lint-trailing_comma-check', :require => false - gem 'puppet-lint-version_comparison-check', :require => false - gem 'puppet-lint-classes_and_types_beginning_with_digits-check', :require => false - gem 'puppet-lint-unquoted_string-check', :require => false - gem 'puppet-lint-variable_contains_upcase', :require => false - gem 'puppet-lint-absolute_classname-check', '>= 2.0.0', :require => false - gem 'puppet-lint-topscope-variable-check', :require => false - gem 'puppet-lint-legacy_facts-check', :require => false - gem 'puppet-lint-anchor-check', :require => false - gem 'metadata-json-lint', :require => false - gem 'redcarpet', :require => false - gem 'rubocop', '~> 0.49.1', :require => false - gem 'rubocop-rspec', '~> 1.15.0', :require => false - gem 'mocha', '~> 1.4.0', :require => false - gem 'coveralls', :require => false - gem 'simplecov-console', :require => false - gem 'parallel_tests', :require => false + gem 'voxpupuli-test', '~> 2.1', :require => false + gem 'coveralls', :require => false + gem 'simplecov-console', :require => false end group :development do @@ -42,27 +24,7 @@ group :development do end group :system_tests do - gem 'winrm', :require => false - if beaker_version = ENV['BEAKER_VERSION'] - gem 'beaker', *location_for(beaker_version) - else - gem 'beaker', '>= 4.2.0', :require => false - end - if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] - gem 'beaker-rspec', *location_for(beaker_rspec_version) - else - gem 'beaker-rspec', :require => false - end - gem 'serverspec', :require => false - gem 'beaker-hostgenerator', '>= 1.1.22', :require => false - gem 'beaker-docker', :require => false - gem 'beaker-puppet', :require => false - gem 'beaker-puppet_install_helper', :require => false - gem 'beaker-module_install_helper', :require => false - gem 'rbnacl', '>= 4', :require => false - gem 'rbnacl-libsodium', :require => false - gem 'bcrypt_pbkdf', :require => false - gem 'ed25519', :require => false + gem 'voxpupuli-acceptance', :require => false end group :release do diff --git a/Rakefile b/Rakefile index c844a789..b450fe7b 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,4 @@ -require 'puppetlabs_spec_helper/rake_tasks' +require 'voxpupuli/test/rake' # load optional tasks for releases # only available if gem group releases is installed @@ -7,37 +7,6 @@ begin rescue LoadError end -PuppetLint.configuration.log_format = '%{path}:%{line}:%{check}:%{KIND}:%{message}' - -desc 'Auto-correct puppet-lint offenses' -task 'lint:auto_correct' do - Rake::Task[:lint_fix].invoke -end - -desc 'Run acceptance tests' -RSpec::Core::RakeTask.new(:acceptance) do |t| - t.pattern = 'spec/acceptance' -end - -desc 'Run tests' -task test: [:release_checks] - -namespace :check do - desc 'Check for trailing whitespace' - task :trailing_whitespace do - Dir.glob('**/*.md', File::FNM_DOTMATCH).sort.each do |filename| - next if filename =~ %r{^((modules|acceptance|\.?vendor|spec/fixtures|pkg)/|REFERENCE.md)} - File.foreach(filename).each_with_index do |line, index| - if line =~ %r{\s\n$} - puts "#{filename} has trailing whitespace on line #{index + 1}" - exit 1 - end - end - end - end -end -Rake::Task[:release_checks].enhance ['check:trailing_whitespace'] - 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__)) @@ -51,7 +20,7 @@ end desc 'Generate REFERENCE.md' task :reference, [:debug, :backtrace] do |t, args| - patterns = 'lib/puppet/functions/extlib/*.rb functions/*.pp' + patterns = '' Rake::Task['strings:generate:reference'].invoke(patterns, args[:debug], args[:backtrace]) end diff --git a/lib/puppet/provider/rvm_gem/gem.rb b/lib/puppet/provider/rvm_gem/gem.rb index 98e1f898..aff38714 100644 --- a/lib/puppet/provider/rvm_gem/gem.rb +++ b/lib/puppet/provider/rvm_gem/gem.rb @@ -107,12 +107,10 @@ def install(useversion = true) # interpret it as a gem repository command << '--source' << source.to_s << resource[:name] end + elsif Gem::Version.new(rubygems_version) < Gem::Version.new('3.0.0') + command << '--no-rdoc' << '--no-ri' << resource[:name] # Deprecated options (backwards compatible) else - if Gem::Version.new(rubygems_version) < Gem::Version.new('3.0.0') - command << '--no-rdoc' << '--no-ri' << resource[:name] # Deprecated options (backwards compatible) - else - command << '--no-document' << resource[:name] - end + command << '--no-document' << resource[:name] end # makefile opts, diff --git a/lib/puppet/type/rvm_gem.rb b/lib/puppet/type/rvm_gem.rb index 8b3e5555..5da70c61 100644 --- a/lib/puppet/type/rvm_gem.rb +++ b/lib/puppet/type/rvm_gem.rb @@ -2,7 +2,7 @@ @doc = 'Ruby Gem support using RVM.' def self.title_patterns - [[/^(?:(.*)\/)?(.*)$/, [[:ruby_version, ->(x) { x }], [:name, ->(x) { x }]]]] + [[/^(?:(.*)\/)?(.*)$/, [[:ruby_version, ->(x) { x }], [:name, ->(x) { x }]]]] # rubocop:disable Style/RegexpLiteral end ensurable do diff --git a/manifests/dependencies/centos.pp b/manifests/dependencies/centos.pp index b4c9207d..756e71b1 100644 --- a/manifests/dependencies/centos.pp +++ b/manifests/dependencies/centos.pp @@ -1,6 +1,5 @@ # Install packages needed by RVM on RedHat systems when not using autolibs class rvm::dependencies::centos { - $version = $facts['os']['name'] ? { 'Amazon' => '6.x', default => $facts['os']['release']['full'], @@ -20,6 +19,6 @@ } ensure_packages(['which','gcc','gcc-c++','make','gettext-devel','expat-devel','zlib-devel','openssl-devel', - 'perl','cpio','gettext-devel','wget','bzip2','libxml2','libxml2-devel','libxslt','libxslt-devel', - 'readline-devel','patch','git','libyaml-devel','libffi-devel','libtool','bison']) + 'perl','cpio','gettext-devel','wget','bzip2','libxml2','libxml2-devel','libxslt','libxslt-devel', + 'readline-devel','patch','git','libyaml-devel','libffi-devel','libtool','bison']) } diff --git a/manifests/dependencies/oraclelinux.pp b/manifests/dependencies/oraclelinux.pp index 58fc9771..23ed8856 100644 --- a/manifests/dependencies/oraclelinux.pp +++ b/manifests/dependencies/oraclelinux.pp @@ -1,7 +1,6 @@ # Install packages needed by RVM on Oracle Linux when not using autolibs class rvm::dependencies::oraclelinux { - ensure_packages(['which','gcc','gcc-c++','make','gettext-devel','expat-devel','libcurl-devel', - 'zlib-devel','openssl-devel','perl','cpio','expat-devel','gettext-devel','wget','bzip2', - 'libxml2','libxml2-devel','libxslt','libxslt-devel','readline-devel','patch','git']) + 'zlib-devel','openssl-devel','perl','cpio','expat-devel','gettext-devel','wget','bzip2', + 'libxml2','libxml2-devel','libxslt','libxslt-devel','readline-devel','patch','git']) } diff --git a/manifests/dependencies/ubuntu.pp b/manifests/dependencies/ubuntu.pp index 2aa1e8e0..25363f17 100644 --- a/manifests/dependencies/ubuntu.pp +++ b/manifests/dependencies/ubuntu.pp @@ -1,9 +1,8 @@ # Install packages needed by RVM on Ubuntu when not using autolibs class rvm::dependencies::ubuntu { - ensure_packages(['build-essential','bison','openssl','libreadline6','libreadline6-dev','curl','git-core', - 'zlib1g','zlib1g-dev','libssl-dev','libyaml-dev','libsqlite3-0','libsqlite3-dev','sqlite3','libxml2-dev', - 'autoconf','libc6-dev']) + 'zlib1g','zlib1g-dev','libssl-dev','libyaml-dev','libsqlite3-0','libsqlite3-dev','sqlite3','libxml2-dev', + 'autoconf','libc6-dev']) - ensure_resource('package', 'libxslt1-dev', {'ensure' => 'present', 'alias' => 'libxslt-dev'}) + ensure_resource('package', 'libxslt1-dev', { 'ensure' => 'present', 'alias' => 'libxslt-dev' }) } diff --git a/manifests/gnupg_key.pp b/manifests/gnupg_key.pp index 1c0c6c22..4ecf4309 100644 --- a/manifests/gnupg_key.pp +++ b/manifests/gnupg_key.pp @@ -1,9 +1,8 @@ # RVM's GPG key import -class rvm::gnupg_key( +class rvm::gnupg_key ( $key_id = $rvm::params::gnupg_key_id, - $key_server = $rvm::params::key_server) inherits rvm::params { - +$key_server = $rvm::params::key_server) inherits rvm::params { gnupg_key { "rvm_${key_id}": ensure => present, key_id => $key_id, @@ -11,5 +10,4 @@ key_server => $key_server, key_type => public, } - } diff --git a/manifests/group.pp b/manifests/group.pp index 6388bc4d..e74bd587 100644 --- a/manifests/group.pp +++ b/manifests/group.pp @@ -1,7 +1,7 @@ # Create the RVM group class rvm::group inherits rvm::params { ensure_resource('group', $rvm::params::group, { - 'ensure' => 'present', - 'system' => true, + 'ensure' => 'present', + 'system' => true, }) } diff --git a/manifests/init.pp b/manifests/init.pp index ecaa26ed..8b5cca79 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,20 +1,18 @@ # Install RVM, create system user a install system level rubies -class rvm( +class rvm ( $version=undef, $install_from=undef, $install_rvm=true, $install_dependencies=false, $manage_rvmrc=$rvm::params::manage_rvmrc, $system_users=[], - $system_rubies={}, - $rvm_gems={}, + $system_rubies= {}, + $rvm_gems= {}, $proxy_url=$rvm::params::proxy_url, $no_proxy=$rvm::params::no_proxy, $key_server=$rvm::params::key_server, - $gnupg_key_id=$rvm::params::gnupg_key_id) inherits rvm::params { - +$gnupg_key_id=$rvm::params::gnupg_key_id) inherits rvm::params { if $install_rvm { - # rvm has now autolibs enabled by default so let it manage the dependencies if $install_dependencies { class { 'rvm::dependencies': @@ -36,8 +34,8 @@ } } - rvm::system_user{ $system_users: } - create_resources('rvm_system_ruby', $system_rubies, {'ensure' => present, 'proxy_url' => $proxy_url, 'no_proxy' => $no_proxy}) + rvm::system_user { $system_users: } + create_resources('rvm_system_ruby', $system_rubies, { 'ensure' => present, 'proxy_url' => $proxy_url, 'no_proxy' => $no_proxy }) if $rvm_gems != {} { validate_hash($rvm_gems) create_resources('rvm_gem', $rvm_gems ) diff --git a/manifests/params.pp b/manifests/params.pp index 0a82050a..8c1249e2 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,6 +1,5 @@ # Default module parameters -class rvm::params($manage_group = true) { - +class rvm::params ($manage_group = true) { $manage_rvmrc = $facts['os']['family'] ? { 'Windows' => false, default => true @@ -15,14 +14,14 @@ $key_server = 'hkp://keys.gnupg.net' # install the gpg key if gpg is installed or being installed in this puppet run - if defined(Class['::gnupg']) or $facts['gnupg_installed'] { + if defined(Class['gnupg']) or $facts['gnupg_installed'] { $gnupg_key_id = '39499BDB' } else { $gnupg_key_id = false } # ignored param, using gnupg module - $gpg_package = $::kernel ? { + $gpg_package = $facts['kernel'] ? { /(Linux|Darwin)/ => 'gnupg2', default => undef, } diff --git a/manifests/passenger/apache.pp b/manifests/passenger/apache.pp index 0d874b2f..e9c8fff8 100644 --- a/manifests/passenger/apache.pp +++ b/manifests/passenger/apache.pp @@ -1,5 +1,5 @@ # Install Passenger dependencies and Apache module -class rvm::passenger::apache( +class rvm::passenger::apache ( $ruby_version, $version, $rvm_prefix = '/usr/local', @@ -12,7 +12,6 @@ $package_ensure = undef, $install_timeout = 600 ) { - class { 'rvm::passenger::gem': ruby_version => $ruby_version, version => $version, @@ -47,7 +46,7 @@ exec { 'passenger-install-apache2-module': command => "${binpath}rvm ${ruby_version} exec passenger-install-apache2-module -a", creates => $modobjectpath, - environment => [ 'HOME=/root', ], + environment => ['HOME=/root',], path => '/usr/bin:/usr/sbin:/bin', require => Class['rvm::passenger::gem','rvm::passenger::dependencies','apache::dev'], timeout => $install_timeout, @@ -68,7 +67,7 @@ passenger_pool_idle_time => $poolidletime, mod_lib_path => $modpath, mod_package_ensure => $package_ensure, - require => [ Exec['passenger-install-apache2-module'], File['passenger_module_object'], ], + require => [Exec['passenger-install-apache2-module'], File['passenger_module_object'],], subscribe => Exec['passenger-install-apache2-module'], } @@ -94,7 +93,7 @@ command => "/bin/cp ${apache_mods_path}/passenger_extra.conf ${apache_mods_path}/passenger.conf", unless => "/usr/bin/diff ${apache_mods_path}/passenger_extra.conf ${apache_mods_path}/passenger.conf", onlyif => "test -f ${apache_mods_path}/passenger_extra.conf", - environment => [ 'HOME=/root', ], + environment => ['HOME=/root',], path => '/usr/bin:/usr/sbin:/bin', require => Class['apache::mod::passenger'], } diff --git a/manifests/passenger/dependencies/centos.pp b/manifests/passenger/dependencies/centos.pp index 4e75b8c4..1f0b1dfe 100644 --- a/manifests/passenger/dependencies/centos.pp +++ b/manifests/passenger/dependencies/centos.pp @@ -1,6 +1,5 @@ # Package dependencies for Passenger on RedHat class rvm::passenger::dependencies::centos { - $version = $facts['os']['name'] ? { 'Amazon' => '6.x', default => $facts['os']['release']['full'], diff --git a/manifests/passenger/gem.pp b/manifests/passenger/gem.pp index aaefd9ad..f414b436 100644 --- a/manifests/passenger/gem.pp +++ b/manifests/passenger/gem.pp @@ -1,5 +1,5 @@ # Install the passenger gem -class rvm::passenger::gem($ruby_version, $version, $proxy_url = undef ) { +class rvm::passenger::gem ($ruby_version, $version, $proxy_url = undef ) { $ruby_version_only = regsubst($ruby_version,'([^@]+)(@(.+))?','\1') rvm_gem { 'passenger': diff --git a/manifests/rvmrc.pp b/manifests/rvmrc.pp index 6870304b..28124685 100644 --- a/manifests/rvmrc.pp +++ b/manifests/rvmrc.pp @@ -1,12 +1,11 @@ # Configure the /etc/rvmrc file -class rvm::rvmrc( +class rvm::rvmrc ( $manage_group = $rvm::params::manage_group, $template = 'rvm/rvmrc.erb', $umask = 'u=rwx,g=rwx,o=rx', $max_time_flag = undef, $autoupdate_flag = 0, - $silence_path_mismatch_check_flag = undef) inherits rvm::params { - +$silence_path_mismatch_check_flag = undef) inherits rvm::params { if $manage_group { include rvm::group } file { '/etc/rvmrc': diff --git a/manifests/system.pp b/manifests/system.pp index 0dab65d0..b8483438 100644 --- a/manifests/system.pp +++ b/manifests/system.pp @@ -1,13 +1,13 @@ # Install the RVM system -class rvm::system( +class rvm::system ( $version=undef, $install_from=undef, $proxy_url=undef, $no_proxy=undef, $key_server=undef, $home=$::root_home, - $gnupg_key_id=$rvm::params::gnupg_key_id) inherits rvm::params { - + $gnupg_key_id=$rvm::params::gnupg_key_id +) inherits rvm::params { $actual_version = $version ? { undef => 'latest', 'present' => 'latest', @@ -16,12 +16,12 @@ # curl needs to be installed if ! defined(Package['curl']) { - case $::kernel { + case $facts['kernel'] { 'Linux': { ensure_packages(['curl']) Package['curl'] -> Exec['system-rvm'] } - default: { } + default: {} } } @@ -46,7 +46,6 @@ } if $install_from { - file { '/tmp/rvm': ensure => directory, } @@ -64,7 +63,6 @@ creates => '/usr/local/rvm/bin/rvm', environment => $environment, } - } else { exec { 'system-rvm': @@ -78,7 +76,6 @@ # the fact won't work until rvm is installed before puppet starts if getvar('::rvm_version') and !empty($::rvm_version) { if ($version != undef) and ($version != present) and ($version != $::rvm_version) { - if defined(Class['rvm::gnupg_key']) { Class['rvm::gnupg_key'] -> Exec['system-rvm-get'] } diff --git a/manifests/system_user.pp b/manifests/system_user.pp index bcb26762..2e43f340 100644 --- a/manifests/system_user.pp +++ b/manifests/system_user.pp @@ -1,8 +1,8 @@ # Create a user that belongs to the correct group to have access to RVM define rvm::system_user ( $create = true, - $manage_group = undef) { - + $manage_group = undef +) { if $facts['os']['family'] == 'Windows' { fail('rvm::system_user is not supported on Windows') } @@ -15,8 +15,8 @@ if $create { ensure_resource('user', $name, { - 'ensure' => 'present', - 'system' => true, + 'ensure' => 'present', + 'system' => true, }) User[$name] -> Exec["rvm-system-user-${name}"] } diff --git a/spec/acceptance/nodesets/centos-65-x64-docker.yml b/spec/acceptance/nodesets/centos-65-x64-docker.yml deleted file mode 100644 index 7ec622ec..00000000 --- a/spec/acceptance/nodesets/centos-65-x64-docker.yml +++ /dev/null @@ -1,23 +0,0 @@ -# This file is managed centrally by modulesync -# https://github.com/maestrodev/puppet-modulesync - -HOSTS: - centos-65-x64: - roles: - - master - platform: el-6-x86_64 - image: devopsil/puppet:3.5.1 - # ip: localhost - hypervisor : docker - docker_image_commands: - - yum -y install tar - - useradd vagrant - - "sed -ri 's/^#?PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config" - - "sed -ri 's/^#?PasswordAuthentication .*/PasswordAuthentication yes/' /etc/ssh/sshd_config" - docker_cmd: - - 'sh' - - '-c' - - 'service sshd start; tail -f /dev/null' -CONFIG: - log_level: debug - type: git diff --git a/spec/acceptance/nodesets/centos-65-x64.yml b/spec/acceptance/nodesets/centos-65-x64.yml deleted file mode 100644 index 5b60f7ab..00000000 --- a/spec/acceptance/nodesets/centos-65-x64.yml +++ /dev/null @@ -1,14 +0,0 @@ -# This file is managed centrally by modulesync -# https://github.com/maestrodev/puppet-modulesync - -HOSTS: - centos-65-x64: - roles: - - master - platform: el-6-x86_64 - box : centos-65-x64-virtualbox-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box - hypervisor : vagrant -CONFIG: - log_level: debug - type: git diff --git a/spec/acceptance/nodesets/debian-7-x64-docker.yml b/spec/acceptance/nodesets/debian-7-x64-docker.yml deleted file mode 100644 index d7ecfb4f..00000000 --- a/spec/acceptance/nodesets/debian-7-x64-docker.yml +++ /dev/null @@ -1,22 +0,0 @@ -# This file is managed centrally by modulesync -# https://github.com/maestrodev/puppet-modulesync - -HOSTS: - debian-7-x64: - roles: - - master - platform: debian-7-amd64 - image: debian:7 - # ip: localhost - hypervisor : docker - docker_image_commands: - - useradd vagrant - - "sed -ri 's/^#?PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config" - - "sed -ri 's/^#?PasswordAuthentication .*/PasswordAuthentication yes/' /etc/ssh/sshd_config" - docker_cmd: - - 'sh' - - '-c' - - 'service ssh start; tail -f /dev/null' -CONFIG: - log_level: debug - type: git diff --git a/spec/acceptance/nodesets/debian-7-x64.yml b/spec/acceptance/nodesets/debian-7-x64.yml deleted file mode 100644 index 3737e5d4..00000000 --- a/spec/acceptance/nodesets/debian-7-x64.yml +++ /dev/null @@ -1,14 +0,0 @@ -# This file is managed centrally by modulesync -# https://github.com/maestrodev/puppet-modulesync - -HOSTS: - debian-7-x64: - roles: - - master - platform: debian-7-amd64 - box : debian-73-x64-virtualbox-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-nocm.box - hypervisor : vagrant -CONFIG: - log_level: debug - type: git diff --git a/spec/acceptance/nodesets/debian-73-x64.yml b/spec/acceptance/nodesets/debian-73-x64.yml deleted file mode 100644 index db65d262..00000000 --- a/spec/acceptance/nodesets/debian-73-x64.yml +++ /dev/null @@ -1,14 +0,0 @@ -# This file is managed centrally by modulesync -# https://github.com/maestrodev/puppet-modulesync - -HOSTS: - debian-73-x64: - roles: - - master - platform: debian-7-amd64 - box : debian-73-x64-virtualbox-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-nocm.box - hypervisor : vagrant -CONFIG: - log_level: debug - type: git diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml deleted file mode 100644 index 7ec622ec..00000000 --- a/spec/acceptance/nodesets/default.yml +++ /dev/null @@ -1,23 +0,0 @@ -# This file is managed centrally by modulesync -# https://github.com/maestrodev/puppet-modulesync - -HOSTS: - centos-65-x64: - roles: - - master - platform: el-6-x86_64 - image: devopsil/puppet:3.5.1 - # ip: localhost - hypervisor : docker - docker_image_commands: - - yum -y install tar - - useradd vagrant - - "sed -ri 's/^#?PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config" - - "sed -ri 's/^#?PasswordAuthentication .*/PasswordAuthentication yes/' /etc/ssh/sshd_config" - docker_cmd: - - 'sh' - - '-c' - - 'service sshd start; tail -f /dev/null' -CONFIG: - log_level: debug - type: git diff --git a/spec/acceptance/nodesets/ubuntu-server-1404-x64-docker.yml b/spec/acceptance/nodesets/ubuntu-server-1404-x64-docker.yml deleted file mode 100644 index 0b714515..00000000 --- a/spec/acceptance/nodesets/ubuntu-server-1404-x64-docker.yml +++ /dev/null @@ -1,22 +0,0 @@ -# This file is managed centrally by modulesync -# https://github.com/maestrodev/puppet-modulesync - -HOSTS: - ubuntu-server-1404-x64: - roles: - - master - platform: ubuntu-14.04-amd64 - image: ubuntu:trusty - # ip: localhost - hypervisor : docker - docker_image_commands: - - useradd vagrant - - "sed -ri 's/^#?PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config" - - "sed -ri 's/^#?PasswordAuthentication .*/PasswordAuthentication yes/' /etc/ssh/sshd_config" - docker_cmd: - - 'sh' - - '-c' - - 'service ssh start; tail -f /dev/null' -CONFIG: - log_level: debug - type: git diff --git a/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml b/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml deleted file mode 100644 index 7e173ffe..00000000 --- a/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml +++ /dev/null @@ -1,14 +0,0 @@ -# This file is managed centrally by modulesync -# https://github.com/maestrodev/puppet-modulesync - -HOSTS: - ubuntu-server-1404-x64: - roles: - - master - platform: ubuntu-14.04-amd64 - box : ubuntu-server-1404-x64-cloud - box_url : https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box - hypervisor : vagrant -CONFIG: - log_level: debug - type: git diff --git a/spec/acceptance/rvm_system_spec.rb b/spec/acceptance/rvm_system_spec.rb index b56e89af..4bf8eabd 100644 --- a/spec/acceptance/rvm_system_spec.rb +++ b/spec/acceptance/rvm_system_spec.rb @@ -269,7 +269,7 @@ class { 'rvm::passenger::apache': it 'answers' do shell('/usr/bin/curl localhost:80') do |r| - r.stdout.should =~ /^hello world<\/b>$/ + r.stdout.should =~ %r{^hello world$} r.exit_code.should == 0 end end @@ -376,7 +376,7 @@ class { 'rvm::passenger::apache': it 'answers' do shell('/usr/bin/curl localhost:80') do |r| - r.stdout.should =~ /^hello world<\/b>$/ + r.stdout.should =~ %r{^hello world$} r.exit_code.should == 0 end end @@ -390,7 +390,7 @@ class { 'rvm::passenger::apache': r.stdout.should =~ %r{Requests in top\-level queue \: [0-9]+} r.stdout.should =~ %r{[\-]+ Application groups [\-]+} # the following will only appear after a request has been made, as in "should answer to" above - r.stdout.should =~ /App root\: \/var\/www\/passenger/ + r.stdout.should =~ %r{App root: /var/www/passenger} r.stdout.should =~ %r{Requests in queue\: [0-9]+} r.exit_code.should == 0 end diff --git a/spec/classes/dependencies_spec.rb b/spec/classes/dependencies_spec.rb index 8fb5302d..3ddd43c9 100644 --- a/spec/classes/dependencies_spec.rb +++ b/spec/classes/dependencies_spec.rb @@ -17,7 +17,7 @@ case os_facts[:operatingsystemmajrelease] when '5' if %w[CentOS RedHat].include? os_facts[:operatingsystem] - it { is_expected.to contain_package('autoconf') } + it { is_expected.to contain_package('autoconf') } # rubocop:disable RSpec/RepeatedExample it { is_expected.to contain_package('curl-devel') } it { is_expected.not_to contain_package('libcurl-devel') } end @@ -27,7 +27,7 @@ it { is_expected.not_to contain_package('curl-devel') } end when 'Debian' - it { is_expected.to contain_package('autoconf') } + it { is_expected.to contain_package('autoconf') } # rubocop:disable RSpec/RepeatedExample it { is_expected.to contain_package('build-essential') } it { is_expected.not_to contain_package('which') } it { is_expected.not_to contain_package('gcc') } diff --git a/spec/classes/gnupg_key_spec.rb b/spec/classes/gnupg_key_spec.rb index bd6a9498..9fc379bf 100644 --- a/spec/classes/gnupg_key_spec.rb +++ b/spec/classes/gnupg_key_spec.rb @@ -1,7 +1,11 @@ require 'spec_helper' -describe 'rvm::gnupg_key', :compile do - let(:facts) { { gnupg_installed: true } } +describe 'rvm::gnupg_key' do + on_supported_os.each do |os, os_facts| + context "on #{os}", :compile do + let(:facts) { os_facts.merge(gnupg_installed: true) } - it { is_expected.to contain_gnupg_key('rvm_39499BDB') } + it { is_expected.to contain_gnupg_key('rvm_39499BDB') } + end + end end diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 31bb807b..fef8689e 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -1,62 +1,61 @@ require 'spec_helper' describe 'rvm' do - let(:facts) do - { - rvm_version: '', - root_home: '/root' - } - end - - context 'default parameters', :compile do - it { is_expected.not_to contain_class('rvm::dependencies') } - it { is_expected.to contain_class('rvm::system') } - end - - context 'with install_rvm false', :compile do - let(:params) do - { - install_rvm: false - } - end - - it { is_expected.not_to contain_class('rvm::dependencies') } - it { is_expected.not_to contain_class('rvm::system') } - end - - context 'with system_rubies', :compile do - let(:params) do - { - system_rubies: { - 'ruby-1.9' => { - 'default_use' => true - }, - 'ruby-2.0' => {} + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts.merge(rvm_version: '', root_home: '/root') } + + context 'default parameters', :compile do + it { is_expected.not_to contain_class('rvm::dependencies') } + it { is_expected.to contain_class('rvm::system') } + end + + context 'with install_rvm false', :compile do + let(:params) do + { + install_rvm: false + } + end + + it { is_expected.not_to contain_class('rvm::dependencies') } + it { is_expected.not_to contain_class('rvm::system') } + end + + context 'with system_rubies', :compile do + let(:params) do + { + system_rubies: { + 'ruby-1.9' => { + 'default_use' => true + }, + 'ruby-2.0' => {} + } + } + end + + it { + is_expected.to contain_rvm_system_ruby('ruby-1.9').with(ensure: 'present', + default_use: true) } - } - end - - it { - is_expected.to contain_rvm_system_ruby('ruby-1.9').with(ensure: 'present', - default_use: true) - } - it { - is_expected.to contain_rvm_system_ruby('ruby-2.0').with(ensure: 'present', - default_use: nil) - } - end + it { + is_expected.to contain_rvm_system_ruby('ruby-2.0').with(ensure: 'present', + default_use: nil) + } + end - context 'with system_users', :compile do - let(:params) { { system_users: %w[john doe] } } + context 'with system_users', if: os_facts[:kernel] == 'Linux' do + let(:params) { { system_users: %w[john doe] } } - it { is_expected.to contain_rvm__system_user('john') } - it { is_expected.to contain_rvm__system_user('doe') } - end + it { is_expected.to contain_rvm__system_user('john') } + it { is_expected.to contain_rvm__system_user('doe') } + end - context 'with no gnupg key id', :compile do - let(:params) { { gnupg_key_id: false } } + context 'with no gnupg key id', :compile do + let(:params) { { gnupg_key_id: false } } - it { is_expected.not_to contain_gnupg_key('rvm_39499BDB') } - it { is_expected.not_to contain_gnupg_key('rvm_') } + it { is_expected.not_to contain_gnupg_key('rvm_39499BDB') } + it { is_expected.not_to contain_gnupg_key('rvm_') } + end + end end end diff --git a/spec/classes/rvmrc_spec.rb b/spec/classes/rvmrc_spec.rb index 2c9f3144..04fb16fa 100644 --- a/spec/classes/rvmrc_spec.rb +++ b/spec/classes/rvmrc_spec.rb @@ -1,19 +1,25 @@ require 'spec_helper' - describe 'rvm::rvmrc' do - let(:file) { '/etc/rvmrc' } - let(:pre_condition) { "exec {'system-rvm': path => '/bin'}" } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) do + os_facts + end + let(:file) { '/etc/rvmrc' } + let(:pre_condition) { "exec {'system-rvm': path => '/bin'}" } - context 'default parameters', :compile do - it { is_expected.to contain_file(file).with_group('rvm') } - it { is_expected.to contain_file(file).with_content(%r{^umask u=rwx,g=rwx,o=rx$}) } - it { is_expected.to contain_file(file).with_content(%r{^rvm_autoupdate_flag=0$}) } - it { is_expected.not_to contain_file(file).with_content(%r{rvm_max_time_flag}) } - end + context 'default parameters', :compile do + it { is_expected.to contain_file(file).with_group('rvm') } + it { is_expected.to contain_file(file).with_content(%r{^umask u=rwx,g=rwx,o=rx$}) } + it { is_expected.to contain_file(file).with_content(%r{^rvm_autoupdate_flag=0$}) } + it { is_expected.not_to contain_file(file).with_content(%r{rvm_max_time_flag}) } + end - context 'with max_time_flag', :compile do - let(:params) { { max_time_flag: 20 } } + context 'with max_time_flag', :compile do + let(:params) { { max_time_flag: 20 } } - it { is_expected.to contain_file(file).with_content(%r{^export rvm_max_time_flag=20$}) } + it { is_expected.to contain_file(file).with_content(%r{^export rvm_max_time_flag=20$}) } + end + end end end diff --git a/spec/classes/system_spec.rb b/spec/classes/system_spec.rb index 27c8f6b5..25344584 100644 --- a/spec/classes/system_spec.rb +++ b/spec/classes/system_spec.rb @@ -5,7 +5,11 @@ let(:facts) do { rvm_version: '1.10.0', - root_home: '/root' + root_home: '/root', + osfamily: 'Debian', + os: { + family: 'Debian' + } } end diff --git a/spec/fixtures/hiera.yaml b/spec/fixtures/hiera.yaml deleted file mode 100644 index b7f4998e..00000000 --- a/spec/fixtures/hiera.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -# This file is managed centrally by modulesync -# https://github.com/maestrodev/puppet-modulesync -:backends: - - rspec - - yaml -:yaml: - :datadir: './spec/fixtures/hieradata' -:hierarchy: - - '%{::clientcert}' - - 'default' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2a4d7d56..d266f6b4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,45 +1,18 @@ -# This file is managed centrally by modulesync -# https://github.com/maestrodev/puppet-modulesync +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config -require 'puppetlabs_spec_helper/module_spec_helper' -require 'rspec-puppet-facts' -include RspecPuppetFacts +# puppetlabs_spec_helper will set up coverage if the env variable is set. +# We want to do this if lib exists and it hasn't been explicitly set. +ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../../lib', __FILE__)) -RSpec.configure do |c| - c.mock_with :rspec - c.hiera_config = File.expand_path(File.join(__FILE__, '../fixtures/hiera.yaml')) +require 'voxpupuli/test/spec_helper' - c.before(:each) do - Puppet::Util::Log.level = :warning - Puppet::Util::Log.newdestination(:console) +if File.exist?(File.join(__dir__, 'default_module_facts.yml')) + facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml'))) + if facts + facts.each do |name, value| + add_custom_fact name.to_sym, value + end end - - c.default_facts = { - operatingsystem: 'CentOS', - operatingsystemrelease: '6.6', - kernel: 'Linux', - osfamily: 'RedHat', - architecture: 'x86_64', - clientcert: 'puppet.acme.com', - os: { - 'architecture' => 'x86_64', - 'family' => 'RedHat', - 'hardware' => 'x86_64', - 'name' => 'CentOS', - 'release' => { - 'full' => '6.6', - 'major' => '6', - 'minor' => '6' - } - } - }.merge({}) - - c.before do - # avoid "Only root can execute commands as other users" - Puppet.features.stubs(root?: true) - end -end - -shared_examples :compile, compile: true do - it { is_expected.to compile.with_all_deps } end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 68c4d151..844dd5e8 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -21,7 +21,7 @@ def install_puppet(host) # Project root proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) - c.before(:each) do + c.before do Puppet::Util::Log.level = :warning Puppet::Util::Log.newdestination(:console) end