diff --git a/.fixtures.yml b/.fixtures.yml new file mode 100644 index 0000000..1a09ee4 --- /dev/null +++ b/.fixtures.yml @@ -0,0 +1,6 @@ +fixtures: + symlinks: + profiles: "#{source_dir}" + repositories: + staging: 'https://github.com/DSI-Ville-Noumea/puppet-staging.git' + diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..8f95c0d --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,106 @@ +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 + + +1. Fork the repo. + +1. Create a separate branch for your change. + +1. Run the tests. We only take pull requests with passing tests, and + documentation. + +1. 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. + +1. Squash your commits down into logical components. Make sure to rebase + against the current master. + +1. 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. + +## 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: + + export PUPPET_VERSION="~> 4.2.0" + +Install the dependencies like so... + + bundle install + +## 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: + + 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: + + 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: + + bundle exec rake test + +To run your all the unit tests + + bundle exec rake spec SPEC_OPTS='--format documentation' + +To run a specific spec test set the `SPEC` variable: + + bundle exec rake spec SPEC=spec/foo_spec.rb + +## 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: + + bundle exec rake acceptance + +This will run the tests on the module's default nodeset. You can override the +nodeset used, e.g., + + BEAKER_set=centos-7-x64 bundle exec rake acceptance + +There are default rake tasks for the various acceptance test modules, e.g., + + 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`. + +The easiest way to debug in a docker container is to open a shell: + + docker exec -it -u root ${container_id_or_name} bash diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..69c736f --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,24 @@ + + +## 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..2b44952 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,6 @@ + diff --git a/.gitignore b/.gitignore index 485dee6..e9b3cf4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,20 @@ -.idea +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 diff --git a/.msync.yml b/.msync.yml new file mode 100644 index 0000000..86ec7e3 --- /dev/null +++ b/.msync.yml @@ -0,0 +1 @@ +modulesync_config_version: '1.4.2' diff --git a/.overcommit.yml b/.overcommit.yml new file mode 100644 index 0000000..31699e7 --- /dev/null +++ b/.overcommit.yml @@ -0,0 +1,63 @@ +# 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: + - 'test' + - 'rubocop' + command: [ 'bundle', 'exec', 'rake' ] diff --git a/.pmtignore b/.pmtignore new file mode 100644 index 0000000..fb58957 --- /dev/null +++ b/.pmtignore @@ -0,0 +1,20 @@ +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/ diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..8c18f1a --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--format documentation +--color diff --git a/.rspec_parallel b/.rspec_parallel new file mode 100644 index 0000000..e4d136b --- /dev/null +++ b/.rspec_parallel @@ -0,0 +1 @@ +--format progress diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..3fc819b --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,545 @@ +require: rubocop-rspec +AllCops: + 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 + +Style/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 diff --git a/.travis.yml b/.travis.yml index 11d95f0..8b2bd46 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,24 +1,50 @@ +--- +sudo: false +dist: trusty language: ruby -bundler_args: --without development system_tests -before_install: rm Gemfile.lock || true +cache: bundler +before_install: + - bundle -v + - rm Gemfile.lock || true + - echo -e "machine github.com\n login $APIKEY\n protocol git" >> ~/.netrc + - gem update --system + - gem update bundler + - gem --version + - bundle -v script: - - bundle exec rake validate - - bundle exec rake lint + - 'bundle exec rake $CHECK' matrix: fast_finish: true include: - - rvm: 1.9.3 - env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes" - - rvm: 2.1.6 - env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes" -deploy: - provider: puppetforge - user: dsivillenoumea - password: - secure: "iQgR/75UkKUZdM0RbGiChWkFQ8r+4bVDgelF5yM9DW8MYtmEswB07DGS7UYS7JOgMe6VuNuHmM6E87kqUyiG13Hz3W5E2MRnB4K/10ljGd3GT+VN/kGNXFIiViZgNieYfTsPgQOE3TlnTuWGUfumt8dzv+3p0dP1/sXlqfIRRqoh+Kl+380+kgsqCJyCnRXJ6T5rOKro9S+4Tepflx8FjetEOG+urKZlZkvXMhyCPFZvAtATwQAvpvEqFiLJwB3J0dOk9Krlw9IbP0UcD9XS70m2b0w3jXpbi+ZKPHMa6EqTGmQjEbOW5IePaTFd8pRBtstXl1G0u5vDUKwQYTHV6BmJEyJEAnsXa7jJfLW8Wm3TY524bqFTJgVCYqDF1otpIG96CtQ0PUujuD4/C4qmmIh/V+NwIt2kJseQUmu7jjKxHR1Ogdr+vlXsWrIYcXywuQM0sDfB3ooosYMFpBEW9H9jawGKCYCuVxXa4lGRLx9rrwtZcG+FksmIniaHVBjIzcBbopybWyDpK5QxHqJnp4qihEQLE2itYDmigNL/F7Z2W6GX61DKPKnk9BZtlTQ2slMOQqju24kb2FkER7lk23xzt/YwCdPyDSvXUki1JS4wLYt9tHzzLMJ6J9jZ5ViFCteoCWiwC/w5cife+j/NxAFfTEyRdQcmM3hwvnMoRBM=" - on: - tags: true + - rvm: 2.1.9 + bundler_args: --without system_tests development release + env: PUPPET_VERSION="~> 5.0" CHECK=test + - rvm: 2.4.2 + bundler_args: --without system_tests development release + env: PUPPET_VERSION="~> 5.0" CHECK=test_with_coveralls + - rvm: 2.4.2 + bundler_args: --without system_tests development release + env: PUPPET_VERSION="~> 5.0" CHECK=rubocop +branches: + only: + - master + - /^v\d/ +notifications: + email: false +#deploy: +# provider: puppetforge +# user: puppet +# password: +# secure: "" + # on: + # tags: true # all_branches is required to use tags - all_branches: true - # Only publish if our main Ruby target builds - rvm: 2.1.6 + # all_branches: true + # # Only publish the build marked with "DEPLOY_TO_FORGE" + # condition: "$DEPLOY_TO_FORGE = yes" + slack: + secure: qWvpt1RYDBJr6J0wcVveFIa/s9JW4OiEmz8AAKce8dM9MR9yr8yDjJ6WKxL27Trofgl4W3Eb4rWOk4dePlhqUyt5x2OuSWL3W7/uyoubiBqJuC4voimf1c/Jp0JH3OV4bgnzZc15IJWic+/1myOlEaPHHNWltB8lnVcqppnjUWIr8lFhT4OvowaoBlFEIZDW/aKluVo3dQJrlNK4KRNRPR0Csk3p1CuzxeW1j5Xbn0qfWMHIzbZSryQ/4K65wcwxCn+HF5BWvl+9Rz59hu0QoC04dJY77NFKHAJ/4khoZaDuXb6M4Hy9et8At9Vk5uO4/rexzr4JhAVlKbEZKovnQ9mOmITyGCjz8wrHEnz9RVIa49iB9uIepPOKZEe2tSCLbncsvWSTTcfzMUAWOJYkC6ZfBeTwm0WygcGIfvaXNSYXvH2pk8YuQlvnzrstlJ8xNaQk0eP/v9tk/1LCPul+nErlzmR2PfBR49z1p2gGmgCoUCcid+MYzh0j4FQl8a8CJ00FxAXaRxxb86EMGr0ewnmKdDvMHcqex/AFUlN1kQUFpBiS2YM6dafXoj5TLsk95jSzZb4GTnzGuOEUcjoelPIVoHI9dlnogROIqsLx76VgHU/cE5LzRXPXdHORglxMSLjk1ViPFvl279NA9s6cNHoZzXnMFHgB2+1pUxGYLOo= +env: + global: + secure: "" + diff --git a/.yardopts b/.yardopts new file mode 100644 index 0000000..3687f51 --- /dev/null +++ b/.yardopts @@ -0,0 +1,2 @@ +--markup markdown +--output-dir docs/ diff --git a/Gemfile b/Gemfile index 533b614..cab936b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,13 +1,70 @@ -source 'https://rubygems.org' +source ENV['GEM_SOURCE'] || "https://rubygems.org" -if puppetversion = ENV['PUPPET_VERSION'] - gem 'puppet', puppetversion, require: false +def location_for(place, fake_version = nil) + if place =~ /^(git[:@][^#]*)#(.*)/ + [fake_version, { :git => $1, :branch => $2, :require => false }].compact + elsif place =~ /^file:\/\/(.*)/ + ['>= 0', { :path => File.expand_path($1), :require => false }] + else + [place, { :require => false }] + end +end + +group :test do + gem 'puppetlabs_spec_helper', '~> 2.4.0', :require => false + gem 'rspec-puppet', '~> 2.5', :require => false + gem 'rspec-puppet-facts', :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 'metadata-json-lint', :require => false + gem 'redcarpet', :require => false + gem 'rubocop', '~> 0.49.1', :require => false if RUBY_VERSION >= '2.3.0' + gem 'rubocop-rspec', '~> 1.15.0', :require => false if RUBY_VERSION >= '2.3.0' + gem 'mocha', '>= 1.2.1', :require => false + gem 'coveralls', :require => false + gem 'simplecov-console', :require => false + gem 'rack', '~> 1.0', :require => false if RUBY_VERSION < '2.2.2' + gem 'parallel_tests', :require => false +end + +group :development do + gem 'travis', :require => false + gem 'travis-lint', :require => false + gem 'guard-rake', :require => false + gem 'overcommit', '>= 0.39.1', :require => false +end + +group :system_tests do + gem 'winrm', :require => false + if beaker_version = ENV['BEAKER_VERSION'] + gem 'beaker', *location_for(beaker_version) + else + gem 'beaker', '>= 3.9.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-puppet_install_helper', :require => false + gem 'beaker-module_install_helper', :require => false +end + + + +if facterversion = ENV['FACTER_GEM_VERSION'] + gem 'facter', facterversion.to_s, :require => false, :groups => [:test] else - gem 'puppet', require: false + gem 'facter', :require => false, :groups => [:test] end -gem 'puppetlabs_spec_helper', require: false -gem 'puppet-lint', require: false -gem 'rspec-puppet', require: false -gem 'facter', require: false -gem 'puppet-blacksmith', require: false +ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 5.0' : puppetversion = ENV['PUPPET_VERSION'].to_s +gem 'puppet', puppetversion, :require => false, :groups => [:test] + +# vim: syntax=ruby diff --git a/Rakefile b/Rakefile index f076205..01cd3c0 100644 --- a/Rakefile +++ b/Rakefile @@ -1,28 +1,68 @@ -require 'rubygems' require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet-lint/tasks/puppet-lint' -require 'puppet_blacksmith/rake_tasks' -PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] -PuppetLint.configuration.relative = true -PuppetLint.configuration.disable_80chars +# load optional tasks for releases +# only available if gem group releases is installed +begin + require 'puppet_blacksmith/rake_tasks' +# require 'voxpupuli/release/rake_tasks' + require 'puppet-strings/tasks' +rescue LoadError +end + +PuppetLint.configuration.log_format = '%{path}:%{line}:%{check}:%{KIND}:%{message}' PuppetLint.configuration.fail_on_warnings = false -PuppetLint.configuration.send('disable_variable_scope') -PuppetLint.configuration.send('disable_autoloader_layout') +#PuppetLint.configuration.fail_on_warnings = true +PuppetLint.configuration.send('relative') +PuppetLint.configuration.send('disable_140chars') +PuppetLint.configuration.send('disable_class_inherits_from_params_class') +PuppetLint.configuration.send('disable_documentation') +PuppetLint.configuration.send('disable_single_quote_string_with_variables') -desc "Validate manifests, templates, and ruby files" -task :validate do - Dir['manifests/**/*.pp'].each do |manifest| - sh "puppet parser validate --noop #{manifest}" - end - Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file| - sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/ - end - Dir['templates/**/*.erb'].each do |template| - sh "erb -P -x -T '-' #{template} | ruby -c" +exclude_paths = %w( + pkg/**/* + vendor/**/* + .vendor/**/* + spec/**/* +) +PuppetLint.configuration.ignore_paths = exclude_paths +PuppetSyntax.exclude_paths = exclude_paths + +desc 'Run acceptance tests' +RSpec::Core::RakeTask.new(:acceptance) do |t| + t.pattern = 'spec/acceptance' +end + +desc 'Run tests metadata_lint, lint, validate, spec' +task test: [ + :metadata_lint, + :lint, + :validate, + :spec, +] + +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 -Blacksmith::RakeTask.new do |t| - t.build = false # do not build the module nor push it to the Forge, just do the tagging [:clean, :tag, :bump_commit] +begin + require 'github_changelog_generator/task' + GitHubChangelogGenerator::RakeTask.new :changelog do |config| + version = (Blacksmith::Modulefile.new).version + config.future_release = "v#{version}" if 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 = 'dsiNoumea' + metadata_json = File.join(File.dirname(__FILE__), 'metadata.json') + metadata = JSON.load(File.read(metadata_json)) + config.project = metadata['name'] + end +rescue LoadError end +# vim: syntax=ruby diff --git a/hiera_config b/hiera_config new file mode 100644 index 0000000..c1552e2 --- /dev/null +++ b/hiera_config @@ -0,0 +1,13 @@ +--- +version: 5 +defaults: + datadir: "./spec/fixtures/hieradata" +hierarchy: + - name: "general data" + paths: + - "%{::zone}/global.yaml" + - "%{::zone}/%{::clientcert}.yaml" + - "%{::clientcert}.yaml" + - global.yaml + + diff --git a/lib/puppet/parser/functions/get_latest.rb b/lib/puppet/parser/functions/get_latest.rb index 2930768..451cdf8 100644 --- a/lib/puppet/parser/functions/get_latest.rb +++ b/lib/puppet/parser/functions/get_latest.rb @@ -3,13 +3,13 @@ require 'uri' module Puppet::Parser::Functions - newfunction(:get_latest, :type => :rvalue) do |args| - u = URI.parse(args[0]) - h = Net::HTTP.new u.host, u.port - h.use_ssl = u.scheme == 'https' - head = h.start do |ua| - ua.head u.path - end - head['location'].sub('https://github.com/liquibase/liquibase/releases/tag/liquibase-parent-','') + newfunction(:get_latest, type: rvalue) do |args| + u = URI.parse(args[0]) + h = Net::HTTP.new u.host, u.port + h.use_ssl = u.scheme == 'https' + head = h.start do |ua| + ua.head u.path + end + head['location'].sub('https://github.com/liquibase/liquibase/releases/tag/liquibase-parent-', '') end end diff --git a/manifests/init.pp b/manifests/init.pp index 08e32c1..f3c1e44 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -12,7 +12,7 @@ $sqlite_version = $liquibase::sqlite_version, $jt400_version = $liquibase::jt400_version, $mariadb_version = $liquibase::mariadb_version, - $environment = hiera('environment'), + $environment = $liquibase::environment, ) inherits liquibase::params { class {'liquibase::install': } -> Class['liquibase'] } diff --git a/manifests/install.pp b/manifests/install.pp index 2cf22e7..85d568a 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -43,9 +43,9 @@ # See README.md include staging - staging::file { "liquibase-${version}-bin.tar.gz": + staging::file { "liquibase-${liquibase::version}-bin.tar.gz": environment => $environment, - source => "https://github.com/liquibase/liquibase/releases/download/liquibase-parent-${version}/liquibase-${version}-bin.tar.gz", + source => "https://github.com/liquibase/liquibase/releases/download/liquibase-parent-${liquibase::version}/liquibase-${liquibase::version}-bin.tar.gz", } file { '/opt/apps/liquibase/': @@ -53,23 +53,23 @@ recurse => true, purge => true, force => true, - require => Staging::File["liquibase-${version}-bin.tar.gz"], + require => Staging::File["liquibase-${liquibase::version}-bin.tar.gz"], } - file { "/opt/apps/liquibase/liquibase-${version}": + file { "/opt/apps/liquibase/liquibase-${liquibase::version}": ensure => directory, - require => Staging::File["liquibase-${version}-bin.tar.gz"], + require => Staging::File["liquibase-${liquibase::version}-bin.tar.gz"], } - staging::extract { "liquibase-${version}-bin.tar.gz": - target => "/opt/apps/liquibase/liquibase-${version}", - require => Staging::File["liquibase-${version}-bin.tar.gz"], + staging::extract { "liquibase-${liquibase::version}-bin.tar.gz": + target => "/opt/apps/liquibase/liquibase-${liquibase::version}", + require => Staging::File["liquibase-${liquibase::version}-bin.tar.gz"], } # Creation des liens synboliques file { '/opt/liquibase': ensure => 'link', - target => "/opt/apps/liquibase/liquibase-${version}", + target => "/opt/apps/liquibase/liquibase-${liquibase::version}", } file { '/usr/bin/liquibase': @@ -83,130 +83,136 @@ owner => root, group => root, source => 'puppet:///modules/liquibase/liquibase_env.sh', - require => Staging::Extract["liquibase-${version}-bin.tar.gz"], + require => Staging::Extract["liquibase-${liquibase::version}-bin.tar.gz"], } # Copie des drivers # PostgreSQL - staging::file { "postgresql-${postgresql_version}.jar": - environment => $environment, - source => "http://central.maven.org/maven2/org/postgresql/postgresql/${postgresql_version}/postgresql-${postgresql_version}.jar", - require => Staging::Extract["liquibase-${version}-bin.tar.gz"], + staging::file { "postgresql-${liquibase::postgresql_version}.jar": + environment => $liquibase::environment, + source => "http://central.maven.org/maven2/org/postgresql/postgresql/${liquibase::postgresql_version}/postgresql-${liquibase::postgresql_version}.jar", + require => Staging::Extract["liquibase-${liquibase::version}-bin.tar.gz"], } - exec { "copy_postgresql-${postgresql_version}.jar": - command => "/bin/cp ${staging::path}/liquibase/postgresql-${postgresql_version}.jar /opt/apps/liquibase/liquibase-${version}/lib/", + exec { "copy_postgresql-${liquibase::postgresql_version}.jar": + command => "/bin/cp ${staging::path}/liquibase/postgresql-${liquibase::postgresql_version}.jar /opt/apps/liquibase/liquibase-${liquibase::version}/lib/", path => '/usr/local/bin/:/bin/', - creates => "/opt/liquibase-${version}/lib/postgresql-${postgresql_version}.jar", - require => [Staging::Extract["liquibase-${version}-bin.tar.gz"], Staging::File["postgresql-${postgresql_version}.jar"]] + creates => "/opt/liquibase-${liquibase::version}/lib/postgresql-${liquibase::postgresql_version}.jar", + require => [ + Staging::Extract["liquibase-${liquibase::version}-bin.tar.gz"], + Staging::File["postgresql-${liquibase::postgresql_version}.jar"] + ], } # Derby - staging::file { "derbyclient-${derby_version}.jar": - environment => $environment, - source => "http://central.maven.org/maven2/org/apache/derby/derbyclient/${derby_version}/derbyclient-${derby_version}.jar", - require => Staging::Extract["liquibase-${version}-bin.tar.gz"], + staging::file { "derbyclient-${liquibase::derby_version}.jar": + environment => $liquibase::environment, + source => "http://central.maven.org/maven2/org/apache/derby/derbyclient/${liquibase::derby_version}/derbyclient-${liquibase::derby_version}.jar", + require => Staging::Extract["liquibase-${liquibase::version}-bin.tar.gz"], } - exec { "copy_derbyclient-${derby_version}.jar": - command => "/bin/cp ${staging::path}/liquibase/derbyclient-${derby_version}.jar /opt/apps/liquibase/liquibase-${version}/lib/", + exec { "copy_derbyclient-${liquibase::derby_version}.jar": + command => "/bin/cp ${staging::path}/liquibase/derbyclient-${liquibase::derby_version}.jar /opt/apps/liquibase/liquibase-${liquibase::version}/lib/", path => '/usr/local/bin/:/bin/', - creates => "/opt/apps/liquibase/liquibase-${version}/lib/derbyclient-${derby_version}.jar", - require => [Staging::Extract["liquibase-${version}-bin.tar.gz"], Staging::File["derbyclient-${derby_version}.jar"]], + creates => "/opt/apps/liquibase/liquibase-${liquibase::version}/lib/derbyclient-${liquibase::derby_version}.jar", + require => [ + Staging::Extract["liquibase-${liquibase::version}-bin.tar.gz"], + Staging::File["derbyclient-${liquibase::derby_version}.jar"] + ], } # H2 - staging::file { "h2-${h2_version}.jar": - environment => $environment, - source => "http://central.maven.org/maven2/com/h2database/h2/${h2_version}/h2-${h2_version}.jar", - require => Staging::Extract["liquibase-${version}-bin.tar.gz"], + staging::file { "h2-${liquibase::h2_version}.jar": + environment => $liquibase::environment, + source => "http://central.maven.org/maven2/com/h2database/h2/${liquibase::h2_version}/h2-${liquibase::h2_version}.jar", + require => Staging::Extract["liquibase-${liquibase::version}-bin.tar.gz"], } - exec { "copy_h2-${h2_version}.jar": - command => "/bin/cp ${staging::path}/liquibase/h2-${h2_version}.jar /opt/apps/liquibase/liquibase-${version}/lib/", + exec { "copy_h2-${liquibase::h2_version}.jar": + command => "/bin/cp ${staging::path}/liquibase/h2-${liquibase::h2_version}.jar /opt/apps/liquibase/liquibase-${liquibase::version}/lib/", path => '/usr/local/bin/:/bin/', - creates => "/opt/apps/liquibase/liquibase-${version}/lib/h2-${h2_version}.jar", - require => [Staging::Extract["liquibase-${version}-bin.tar.gz"], Staging::File["h2-${h2_version}.jar"]], + creates => "/opt/apps/liquibase/liquibase-${liquibase::version}/lib/h2-${liquibase::h2_version}.jar", + require => [Staging::Extract["liquibase-${liquibase::version}-bin.tar.gz"], Staging::File["h2-${liquibase::h2_version}.jar"]], } # Hsqldb - staging::file { "hsqldb-${hsqldb_version}.jar": - environment => $environment, - source => "http://central.maven.org/maven2/org/hsqldb/hsqldb/${hsqldb_version}/hsqldb-${hsqldb_version}.jar", - require => Staging::Extract["liquibase-${version}-bin.tar.gz"], + staging::file { "hsqldb-${liquibase::hsqldb_version}.jar": + environment => $liquibase::environment, + source => "http://central.maven.org/maven2/org/hsqldb/hsqldb/${liquibase::hsqldb_version}/hsqldb-${liquibase::hsqldb_version}.jar", + require => Staging::Extract["liquibase-${liquibase::version}-bin.tar.gz"], } - exec { "copy_hsqldb-${hsqldb_version}.jar": - command => "/bin/cp ${staging::path}/liquibase/hsqldb-${hsqldb_version}.jar /opt/apps/liquibase/liquibase-${version}/lib/", + exec { "copy_hsqldb-${liquibase::hsqldb_version}.jar": + command => "/bin/cp ${staging::path}/liquibase/hsqldb-${liquibase::hsqldb_version}.jar /opt/apps/liquibase/liquibase-${liquibase::version}/lib/", path => '/usr/local/bin/:/bin/', - creates => "/opt/apps/liquibase/liquibase-${version}/lib/hsqldb-${hsqldb_version}.jar", - require => [Staging::Extract["liquibase-${version}-bin.tar.gz"], Staging::File["hsqldb-${hsqldb_version}.jar"]], + creates => "/opt/apps/liquibase/liquibase-${liquibase::version}/lib/hsqldb-${liquibase::hsqldb_version}.jar", + require => [Staging::Extract["liquibase-${liquibase::version}-bin.tar.gz"], Staging::File["hsqldb-${liquibase::hsqldb_version}.jar"]], } # Jtds - staging::file { "jtds-${jtds_version}.jar": - environment => $environment, - source => "http://central.maven.org/maven2/net/sourceforge/jtds/jtds/${jtds_version}/jtds-${jtds_version}.jar", - require => Staging::Extract["liquibase-${version}-bin.tar.gz"], + staging::file { "jtds-${liquibase::jtds_version}.jar": + environment => $liquibase::environment, + source => "http://central.maven.org/maven2/net/sourceforge/jtds/jtds/${liquibase::jtds_version}/jtds-${liquibase::jtds_version}.jar", + require => Staging::Extract["liquibase-${liquibase::version}-bin.tar.gz"], } - exec { "copy_jtds-${jtds_version}.jar": - command => "/bin/cp ${staging::path}/liquibase/jtds-${jtds_version}.jar /opt/apps/liquibase/liquibase-${version}/lib/", + exec { "copy_jtds-${liquibase::jtds_version}.jar": + command => "/bin/cp ${staging::path}/liquibase/jtds-${liquibase::jtds_version}.jar /opt/apps/liquibase/liquibase-${liquibase::version}/lib/", path => '/usr/local/bin/:/bin/', - creates => "/opt/apps/liquibase/liquibase-${version}/lib/jtds-${jtds_version}.jar", - require => [Staging::Extract["liquibase-${version}-bin.tar.gz"], Staging::File["jtds-${jtds_version}.jar"]], + creates => "/opt/apps/liquibase/liquibase-${liquibase::version}/lib/jtds-${liquibase::jtds_version}.jar", + require => [Staging::Extract["liquibase-${liquibase::version}-bin.tar.gz"], Staging::File["jtds-${liquibase::jtds_version}.jar"]], } # MySql - staging::file { "mysql-connector-java-${mysql_version}.jar": - environment => $environment, - source => "http://central.maven.org/maven2/mysql/mysql-connector-java/${mysql_version}/mysql-connector-java-${mysql_version}.jar", - require => Staging::Extract["liquibase-${version}-bin.tar.gz"], + staging::file { "mysql-connector-java-${liquibase::mysql_version}.jar": + environment => $liquibase::environment, + source => "http://central.maven.org/maven2/mysql/mysql-connector-java/${liquibase::mysql_version}/mysql-connector-java-${liquibase::mysql_version}.jar", + require => Staging::Extract["liquibase-${liquibase::version}-bin.tar.gz"], } - exec { "copy_mysql-connector-java-${mysql_version}.jar": - command => "/bin/cp ${staging::path}/liquibase/mysql-connector-java-${mysql_version}.jar /opt/apps/liquibase/liquibase-${version}/lib/", + exec { "copy_mysql-connector-java-${liquibase::mysql_version}.jar": + command => "/bin/cp ${staging::path}/liquibase/mysql-connector-java-${liquibase::mysql_version}.jar /opt/apps/liquibase/liquibase-${liquibase::version}/lib/", path => '/usr/local/bin/:/bin/', - creates => "/opt/apps/liquibase/liquibase-${version}/lib/mysql-connector-java-${mysql_version}.jar", - require => [Staging::Extract["liquibase-${version}-bin.tar.gz"], Staging::File["mysql-connector-java-${mysql_version}.jar"]], + creates => "/opt/apps/liquibase/liquibase-${liquibase::version}/lib/mysql-connector-java-${liquibase::mysql_version}.jar", + require => [Staging::Extract["liquibase-${liquibase::version}-bin.tar.gz"], Staging::File["mysql-connector-java-${liquibase::mysql_version}.jar"]], } # Jt400 - staging::file { "jt400-${jt400_version}.jar": - environment => $environment, - source => "http://central.maven.org/maven2/net/sf/jt400/jt400/${jt400_version}/jt400-${jt400_version}.jar", - require => Staging::Extract["liquibase-${version}-bin.tar.gz"], + staging::file { "jt400-${liquibase::jt400_version}.jar": + environment => $liquibase::environment, + source => "http://central.maven.org/maven2/net/sf/jt400/jt400/${liquibase::jt400_version}/jt400-${liquibase::jt400_version}.jar", + require => Staging::Extract["liquibase-${liquibase::version}-bin.tar.gz"], } - exec { "copy_jt400-${jt400_version}.jar": - command => "/bin/cp ${staging::path}/liquibase/jt400-${jt400_version}.jar /opt/apps/liquibase/liquibase-${version}/lib/", + exec { "copy_jt400-${liquibase::jt400_version}.jar": + command => "/bin/cp ${staging::path}/liquibase/jt400-${liquibase::jt400_version}.jar /opt/apps/liquibase/liquibase-${liquibase::version}/lib/", path => '/usr/local/bin/:/bin/', - creates => "/opt/apps/liquibase/liquibase-${version}/lib/jt400-${jt400_version}.jar", - require => [Staging::Extract["liquibase-${version}-bin.tar.gz"], Staging::File["jt400-${jt400_version}.jar"]], + creates => "/opt/apps/liquibase/liquibase-${liquibase::version}/lib/jt400-${liquibase::jt400_version}.jar", + require => [Staging::Extract["liquibase-${liquibase::version}-bin.tar.gz"], Staging::File["jt400-${liquibase::jt400_version}.jar"]], } # MariaDB - staging::file { "mariadb-${mariadb_version}.jar": - environment => $environment, - source => "http://central.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/${mariadb_version}/mariadb-java-client-${mariadb_version}.jar", - require => Staging::Extract["liquibase-${version}-bin.tar.gz"], + staging::file { "mariadb-${liquibase::mariadb_version}.jar": + environment => $liquibase::environment, + source => "http://central.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/${liquibase::mariadb_version}/mariadb-java-client-${liquibase::mariadb_version}.jar", + require => Staging::Extract["liquibase-${liquibase::version}-bin.tar.gz"], } - exec { "copy_mariadb-${mariadb_version}.jar": - command => "/bin/cp ${staging::path}/liquibase/mariadb-${mariadb_version}.jar /opt/apps/liquibase/liquibase-${version}/lib/", + exec { "copy_mariadb-${liquibase::mariadb_version}.jar": + command => "/bin/cp ${staging::path}/liquibase/mariadb-${liquibase::mariadb_version}.jar /opt/apps/liquibase/liquibase-${liquibase::version}/lib/", path => '/usr/local/bin/:/bin/', - creates => "/opt/apps/liquibase/liquibase-${version}/lib/mariadb-${mariadb_version}.jar", - require => [Staging::Extract["liquibase-${version}-bin.tar.gz"], Staging::File["mariadb-${mariadb_version}.jar"]], + creates => "/opt/apps/liquibase/liquibase-${liquibase::version}/lib/mariadb-${liquibase::mariadb_version}.jar", + require => [Staging::Extract["liquibase-${liquibase::version}-bin.tar.gz"], Staging::File["mariadb-${liquibase::mariadb_version}.jar"]], } # Sqlite # Copie du jar car seule cette version (3.7.8) fonctionne - file { "/opt/apps/liquibase/liquibase-${version}/lib/sqlite-jdbc-${sqlite_version}.jar": + file { "/opt/apps/liquibase/liquibase-${liquibase::version}/lib/sqlite-jdbc-${liquibase::sqlite_version}.jar": ensure => present, owner => root, group => root, - source => "puppet:///modules/liquibase/sqlite-jdbc-${sqlite_version}.jar", - require => Staging::Extract["liquibase-${version}-bin.tar.gz"], + source => "puppet:///modules/liquibase/sqlite-jdbc-${liquibase::sqlite_version}.jar", + require => Staging::Extract["liquibase-${liquibase::version}-bin.tar.gz"], } } diff --git a/spec/acceptance/nodesets/centos-6-x64.yml b/spec/acceptance/nodesets/centos-6-x64.yml new file mode 100644 index 0000000..16abc8f --- /dev/null +++ b/spec/acceptance/nodesets/centos-6-x64.yml @@ -0,0 +1,15 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + centos-6-x64: + roles: + - master + platform: el-6-x86_64 + box: centos/6 + hypervisor: vagrant +CONFIG: + type: aio +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/centos-66-x64-pe.yml b/spec/acceptance/nodesets/centos-66-x64-pe.yml new file mode 100644 index 0000000..1e7aea6 --- /dev/null +++ b/spec/acceptance/nodesets/centos-66-x64-pe.yml @@ -0,0 +1,17 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + centos-66-x64: + roles: + - master + - database + - dashboard + platform: el-6-x86_64 + box: puppetlabs/centos-6.6-64-puppet-enterprise + hypervisor: vagrant +CONFIG: + type: pe +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/centos-7-x64.yml b/spec/acceptance/nodesets/centos-7-x64.yml new file mode 100644 index 0000000..e05a3ae --- /dev/null +++ b/spec/acceptance/nodesets/centos-7-x64.yml @@ -0,0 +1,15 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + centos-7-x64: + roles: + - master + platform: el-7-x86_64 + box: centos/7 + hypervisor: vagrant +CONFIG: + type: aio +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/centos-5.yml b/spec/acceptance/nodesets/docker/centos-5.yml new file mode 100644 index 0000000..c17bc3d --- /dev/null +++ b/spec/acceptance/nodesets/docker/centos-5.yml @@ -0,0 +1,19 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + centos-5-x64: + platform: el-5-x86_64 + hypervisor: docker + image: centos:5 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'yum install -y crontabs initscripts iproute openssl sysvinit-tools tar wget which' + - 'sed -i -e "/mingetty/d" /etc/inittab' +CONFIG: + trace_limit: 200 + masterless: true +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/centos-6.yml b/spec/acceptance/nodesets/docker/centos-6.yml new file mode 100644 index 0000000..d93f884 --- /dev/null +++ b/spec/acceptance/nodesets/docker/centos-6.yml @@ -0,0 +1,20 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + centos-6-x64: + platform: el-6-x86_64 + hypervisor: docker + image: centos:6 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'rm -rf /var/run/network/*' + - 'yum install -y crontabs initscripts iproute openssl sysvinit-tools tar wget which' + - 'rm /etc/init/tty.conf' +CONFIG: + trace_limit: 200 + masterless: true +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/centos-7.yml b/spec/acceptance/nodesets/docker/centos-7.yml new file mode 100644 index 0000000..41e924b --- /dev/null +++ b/spec/acceptance/nodesets/docker/centos-7.yml @@ -0,0 +1,19 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + centos-7-x64: + platform: el-7-x86_64 + hypervisor: docker + image: centos:7 + docker_preserve_image: true + docker_cmd: '["/usr/sbin/init"]' + docker_image_commands: + - 'yum install -y crontabs initscripts iproute openssl sysvinit-tools tar wget which ss' + - 'systemctl mask getty@tty1.service' +CONFIG: + trace_limit: 200 + masterless: true +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/debian-7.yml b/spec/acceptance/nodesets/docker/debian-7.yml new file mode 100644 index 0000000..41b284d --- /dev/null +++ b/spec/acceptance/nodesets/docker/debian-7.yml @@ -0,0 +1,18 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + debian-7-x64: + platform: debian-7-amd64 + hypervisor: docker + image: debian:7 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get update && apt-get install -y cron locales-all net-tools wget' +CONFIG: + trace_limit: 200 + masterless: true +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/debian-8.yml b/spec/acceptance/nodesets/docker/debian-8.yml new file mode 100644 index 0000000..a630b7e --- /dev/null +++ b/spec/acceptance/nodesets/docker/debian-8.yml @@ -0,0 +1,20 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + debian-8-x64: + platform: debian-8-amd64 + hypervisor: docker + image: debian:8 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get update && apt-get install -y cron locales-all net-tools wget' + - 'rm -f /usr/sbin/policy-rc.d' + - 'systemctl mask getty@tty1.service getty-static.service' +CONFIG: + trace_limit: 200 + masterless: true +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/debian-9.yml b/spec/acceptance/nodesets/docker/debian-9.yml new file mode 100644 index 0000000..dfc8e9c --- /dev/null +++ b/spec/acceptance/nodesets/docker/debian-9.yml @@ -0,0 +1,20 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/theforeman/foreman-installer-modulesync +HOSTS: + debian-9-x64: + platform: debian-9-amd64 + hypervisor: docker + image: debian:9 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get update && apt-get install -y cron locales-all net-tools wget systemd-sysv' + - 'rm -f /usr/sbin/policy-rc.d' + - 'systemctl mask getty@tty1.service getty-static.service' +CONFIG: + trace_limit: 200 + masterless: true +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/ubuntu-12.04.yml b/spec/acceptance/nodesets/docker/ubuntu-12.04.yml new file mode 100644 index 0000000..ab77cda --- /dev/null +++ b/spec/acceptance/nodesets/docker/ubuntu-12.04.yml @@ -0,0 +1,19 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + ubuntu-1204-x64: + platform: ubuntu-12.04-amd64 + hypervisor: docker + image: ubuntu:12.04 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y net-tools wget' + - 'locale-gen en_US.UTF-8' +CONFIG: + trace_limit: 200 + masterless: true +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/ubuntu-14.04.yml b/spec/acceptance/nodesets/docker/ubuntu-14.04.yml new file mode 100644 index 0000000..ae45304 --- /dev/null +++ b/spec/acceptance/nodesets/docker/ubuntu-14.04.yml @@ -0,0 +1,21 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + ubuntu-1404-x64: + platform: ubuntu-14.04-amd64 + hypervisor: docker + image: ubuntu:14.04 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'rm /usr/sbin/policy-rc.d' + - 'rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl' + - 'apt-get install -y net-tools wget apt-transport-https' + - 'locale-gen en_US.UTF-8' +CONFIG: + trace_limit: 200 + masterless: true +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/docker/ubuntu-16.04.yml b/spec/acceptance/nodesets/docker/ubuntu-16.04.yml new file mode 100644 index 0000000..2d173c5 --- /dev/null +++ b/spec/acceptance/nodesets/docker/ubuntu-16.04.yml @@ -0,0 +1,19 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +HOSTS: + ubuntu-1604-x64: + platform: ubuntu-16.04-amd64 + hypervisor: docker + image: ubuntu:16.04 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y net-tools wget locales apt-transport-https' + - 'locale-gen en_US.UTF-8' +CONFIG: + trace_limit: 200 + masterless: true +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/ec2/amazonlinux-2016091.yml b/spec/acceptance/nodesets/ec2/amazonlinux-2016091.yml new file mode 100644 index 0000000..19dd43e --- /dev/null +++ b/spec/acceptance/nodesets/ec2/amazonlinux-2016091.yml @@ -0,0 +1,31 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +# +# Additional ~/.fog config file with AWS EC2 credentials +# required. +# +# see: https://github.com/puppetlabs/beaker/blob/master/docs/how_to/hypervisors/ec2.md +# +# Amazon Linux is not a RHEL clone. +# +HOSTS: + amazonlinux-2016091-x64: + roles: + - master + platform: centos-6-x86_64 + hypervisor: ec2 + # refers to image_tempaltes.yaml AMI[vmname] entry: + vmname: amazonlinux-2016091-eu-central-1 + # refers to image_tempaltes.yaml entry inside AMI[vmname][:image]: + snapshot: aio + # t2.micro is free tier eligible (https://aws.amazon.com/en/free/): + amisize: t2.micro + # required so that beaker sanitizes sshd_config and root authorized_keys: + user: ec2-user +CONFIG: + type: aio + :ec2_yaml: spec/acceptance/nodesets/ec2/image_templates.yaml +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/ec2/image_templates.yaml b/spec/acceptance/nodesets/ec2/image_templates.yaml new file mode 100644 index 0000000..e50593e --- /dev/null +++ b/spec/acceptance/nodesets/ec2/image_templates.yaml @@ -0,0 +1,34 @@ +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +# +# see also: https://github.com/puppetlabs/beaker/blob/master/docs/how_to/hypervisors/ec2.md +# +# Hint: image IDs (ami-*) for the same image are different per location. +# +AMI: + # Amazon Linux AMI 2016.09.1 (HVM), SSD Volume Type + amazonlinux-2016091-eu-central-1: + :image: + :aio: ami-af0fc0c0 + :region: eu-central-1 + # Red Hat Enterprise Linux 7.3 (HVM), SSD Volume Type + rhel-73-eu-central-1: + :image: + :aio: ami-e4c63e8b + :region: eu-central-1 + # SUSE Linux Enterprise Server 12 SP2 (HVM), SSD Volume Type + sles-12sp2-eu-central-1: + :image: + :aio: ami-c425e4ab + :region: eu-central-1 + # Ubuntu Server 16.04 LTS (HVM), SSD Volume Type + ubuntu-1604-eu-central-1: + :image: + :aio: ami-fe408091 + :region: eu-central-1 + # Microsoft Windows Server 2016 Base + windows-2016-base-eu-central-1: + :image: + :aio: ami-88ec20e7 + :region: eu-central-1 diff --git a/spec/acceptance/nodesets/ec2/rhel-73-x64.yml b/spec/acceptance/nodesets/ec2/rhel-73-x64.yml new file mode 100644 index 0000000..7fac823 --- /dev/null +++ b/spec/acceptance/nodesets/ec2/rhel-73-x64.yml @@ -0,0 +1,29 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +# +# Additional ~/.fog config file with AWS EC2 credentials +# required. +# +# see: https://github.com/puppetlabs/beaker/blob/master/docs/how_to/hypervisors/ec2.md +# +HOSTS: + rhel-73-x64: + roles: + - master + platform: el-7-x86_64 + hypervisor: ec2 + # refers to image_tempaltes.yaml AMI[vmname] entry: + vmname: rhel-73-eu-central-1 + # refers to image_tempaltes.yaml entry inside AMI[vmname][:image]: + snapshot: aio + # t2.micro is free tier eligible (https://aws.amazon.com/en/free/): + amisize: t2.micro + # required so that beaker sanitizes sshd_config and root authorized_keys: + user: ec2-user +CONFIG: + type: aio + :ec2_yaml: spec/acceptance/nodesets/ec2/image_templates.yaml +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/ec2/sles-12sp2-x64.yml b/spec/acceptance/nodesets/ec2/sles-12sp2-x64.yml new file mode 100644 index 0000000..8542154 --- /dev/null +++ b/spec/acceptance/nodesets/ec2/sles-12sp2-x64.yml @@ -0,0 +1,29 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +# +# Additional ~/.fog config file with AWS EC2 credentials +# required. +# +# see: https://github.com/puppetlabs/beaker/blob/master/docs/how_to/hypervisors/ec2.md +# +HOSTS: + sles-12sp2-x64: + roles: + - master + platform: sles-12-x86_64 + hypervisor: ec2 + # refers to image_tempaltes.yaml AMI[vmname] entry: + vmname: sles-12sp2-eu-central-1 + # refers to image_tempaltes.yaml entry inside AMI[vmname][:image]: + snapshot: aio + # t2.micro is free tier eligible (https://aws.amazon.com/en/free/): + amisize: t2.micro + # required so that beaker sanitizes sshd_config and root authorized_keys: + user: ec2-user +CONFIG: + type: aio + :ec2_yaml: spec/acceptance/nodesets/ec2/image_templates.yaml +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/ec2/ubuntu-1604-x64.yml b/spec/acceptance/nodesets/ec2/ubuntu-1604-x64.yml new file mode 100644 index 0000000..9cf59d5 --- /dev/null +++ b/spec/acceptance/nodesets/ec2/ubuntu-1604-x64.yml @@ -0,0 +1,29 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +# +# Additional ~/.fog config file with AWS EC2 credentials +# required. +# +# see: https://github.com/puppetlabs/beaker/blob/master/docs/how_to/hypervisors/ec2.md +# +HOSTS: + ubuntu-1604-x64: + roles: + - master + platform: ubuntu-16.04-amd64 + hypervisor: ec2 + # refers to image_tempaltes.yaml AMI[vmname] entry: + vmname: ubuntu-1604-eu-central-1 + # refers to image_tempaltes.yaml entry inside AMI[vmname][:image]: + snapshot: aio + # t2.micro is free tier eligible (https://aws.amazon.com/en/free/): + amisize: t2.micro + # required so that beaker sanitizes sshd_config and root authorized_keys: + user: ubuntu +CONFIG: + type: aio + :ec2_yaml: spec/acceptance/nodesets/ec2/image_templates.yaml +... +# vim: syntax=yaml diff --git a/spec/acceptance/nodesets/ec2/windows-2016-base-x64.yml b/spec/acceptance/nodesets/ec2/windows-2016-base-x64.yml new file mode 100644 index 0000000..0932e29 --- /dev/null +++ b/spec/acceptance/nodesets/ec2/windows-2016-base-x64.yml @@ -0,0 +1,29 @@ +--- +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config +# +# Additional ~/.fog config file with AWS EC2 credentials +# required. +# +# see: https://github.com/puppetlabs/beaker/blob/master/docs/how_to/hypervisors/ec2.md +# +HOSTS: + windows-2016-base-x64: + roles: + - master + platform: windows-2016-64 + hypervisor: ec2 + # refers to image_tempaltes.yaml AMI[vmname] entry: + vmname: windows-2016-base-eu-central-1 + # refers to image_tempaltes.yaml entry inside AMI[vmname][:image]: + snapshot: aio + # t2.micro is free tier eligible (https://aws.amazon.com/en/free/): + amisize: t2.micro + # required so that beaker sanitizes sshd_config and root authorized_keys: + user: ec2-user +CONFIG: + type: aio + :ec2_yaml: spec/acceptance/nodesets/ec2/image_templates.yaml +... +# vim: syntax=yaml diff --git a/spec/classes/coverage_spec.rb b/spec/classes/coverage_spec.rb new file mode 100644 index 0000000..de44654 --- /dev/null +++ b/spec/classes/coverage_spec.rb @@ -0,0 +1,4 @@ +require 'rspec-puppet' + +at_exit { RSpec::Puppet::Coverage.report! } +# vim: syntax=ruby diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index e67630d..ec3fa97 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -1,7 +1,24 @@ require 'spec_helper' describe 'liquibase' do + let :facts do + { + kernel: 'Linux', + osfamily: 'RedHat', + operatingsystem: 'CentOS', + operatingsystemrelease: '6', + operatingsystemmajrelease: '6', + concat_basedir: '/dne', + path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + kernelmajversion: '2.6', + is_virtual: 'true', + fqdn: 'svq-nonexistant.domain', + architecture: 'x64', + selinux: true, + staging_http_get: 'http://yum' + } + end context 'with defaults for all parameters' do - it { should contain_class('liquibase') } + it { is_expected.to contain_class('liquibase') } end end diff --git a/spec/default_facts.yml b/spec/default_facts.yml new file mode 100644 index 0000000..15db661 --- /dev/null +++ b/spec/default_facts.yml @@ -0,0 +1,14 @@ +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/DSI-Ville-Noumea/puppet-modulesync_config +# +# use default_module_facts.yaml for module specific +# facts. +# +# Hint if using with rspec-puppet-facts ("on_supported_os.each"): +# if a same named fact exists in facterdb it will be overridden. +--- +concat_basedir: "/tmp" +ipaddress: "172.16.254.254" +is_pe: true +macaddress: "AA:AA:AA:AA:AA:AA" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5a08ce2..cdd4935 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,31 @@ require 'puppetlabs_spec_helper/module_spec_helper' +require 'rspec-puppet-facts' +include RspecPuppetFacts + +if Dir.exist?(File.expand_path('../../lib', __FILE__)) + require 'coveralls' + require 'simplecov' + require 'simplecov-console' + SimpleCov.formatters = [ + SimpleCov::Formatter::HTMLFormatter, + SimpleCov::Formatter::Console + ] + SimpleCov.start do + track_files 'lib/**/*.rb' + add_filter '/spec' + add_filter '/vendor' + add_filter '/.vendor' + end +end RSpec.configure do |c| - c.hiera_config = File.expand_path(File.join(__FILE__, '../fixtures/hiera.yaml')) + default_facts = { + puppetversion: Puppet.version, + facterversion: Facter.version + } + default_facts.merge!(YAML.load(File.read(File.expand_path('../default_facts.yml', __FILE__)))) if File.exist?(File.expand_path('../default_facts.yml', __FILE__)) + default_facts.merge!(YAML.load(File.read(File.expand_path('../default_module_facts.yml', __FILE__)))) if File.exist?(File.expand_path('../default_module_facts.yml', __FILE__)) + c.default_facts = default_facts end + +# vim: syntax=ruby