diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 4a519698..5d047472 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -51,19 +51,19 @@ You can install all needed gems for spec tests into the modules directory by running: ```sh -bundle install --path .vendor/ --without development --without system_tests --without release +bundle install --path .vendor/ --without development system_tests release ``` If you also want to run acceptance tests: ```sh -bundle install --path .vendor/ --without development --with system_tests --without release +bundle install --path .vendor/ --with system_tests --without development release ``` Our all in one solution if you don't know if you need to install or update gems: ```sh -bundle install --path .vendor/ --without development --with system_tests --without release; bundle update; bundle clean +bundle install --path .vendor/ --with system_tests --without development release; bundle update; bundle clean ``` ## Syntax and style diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index ef25cdbf..342807bc 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -8,13 +8,13 @@ Thank you for contributing to this project! --> #### Pull Request (PR) description #### This Pull Request (PR) fixes the following issues diff --git a/.msync.yml b/.msync.yml index fa528f53..55198916 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '2.4.0' +modulesync_config_version: '2.7.0' diff --git a/.travis.yml b/.travis.yml index d13789ce..d3f0310a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,66 +1,44 @@ --- -sudo: false dist: xenial language: ruby cache: bundler before_install: - - rm -f Gemfile.lock + - gem update --system + - gem update bundler + - bundle --version script: - 'bundle exec rake $CHECK' matrix: fast_finish: true include: - - rvm: 2.1.9 - bundler_args: --without system_tests development release - env: PUPPET_VERSION="~> 4.0" CHECK=test PARALLEL_TEST_PROCESSORS=12 - rvm: 2.4.4 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 5.0" CHECK=test - - rvm: 2.5.1 + - rvm: 2.5.3 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 6.0" CHECK=test_with_coveralls - - rvm: 2.5.1 + - 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 - - rvm: 2.5.1 + - rvm: 2.5.3 bundler_args: --without development release - dist: trusty env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker services: docker - sudo: required - - rvm: 2.5.1 + - rvm: 2.5.3 bundler_args: --without development release - dist: trusty env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker services: docker - sudo: required - - rvm: 2.5.1 - bundler_args: --without development release - dist: trusty - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6-nightly BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker - services: docker - sudo: required - - rvm: 2.5.1 + - rvm: 2.5.3 bundler_args: --without development release - dist: trusty env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1404-64 BEAKER_HYPERVISOR=docker CHECK=beaker services: docker - sudo: required - - rvm: 2.5.1 + - rvm: 2.5.3 bundler_args: --without development release - dist: trusty env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1404-64 BEAKER_HYPERVISOR=docker CHECK=beaker services: docker - sudo: required - - rvm: 2.5.1 - bundler_args: --without development release - dist: trusty - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6-nightly BEAKER_debug=true BEAKER_setfile=ubuntu1404-64 BEAKER_HYPERVISOR=docker CHECK=beaker - services: docker - sudo: required branches: only: - master diff --git a/Dockerfile b/Dockerfile index 27a33cf6..67048bb4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.5.1 +FROM ruby:2.5.3 WORKDIR /opt/puppet diff --git a/Gemfile b/Gemfile index 9648d7de..24dbb7ff 100644 --- a/Gemfile +++ b/Gemfile @@ -11,7 +11,7 @@ def location_for(place, fake_version = nil) end group :test do - gem 'puppetlabs_spec_helper', '>= 2.11.0', :require => false + gem 'puppetlabs_spec_helper', '>= 2.14.0', :require => false gem 'rspec-puppet-facts', '>= 1.8.0', :require => false gem 'rspec-puppet-utils', :require => false gem 'puppet-lint-leading_zero-check', :require => false @@ -20,16 +20,15 @@ group :test do 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', :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 '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 'rack', '~> 1.0', :require => false if RUBY_VERSION < '2.2.2' - gem 'parallel_tests', '2.24.0', :require => false if RUBY_VERSION < '2.2.0' - gem 'parallel_tests', :require => false if RUBY_VERSION >= '2.2.0' + gem 'parallel_tests', :require => false end group :development do @@ -57,16 +56,16 @@ group :system_tests do gem 'beaker-puppet', :require => false gem 'beaker-puppet_install_helper', :require => false gem 'beaker-module_install_helper', :require => false - gem 'rbnacl', '>= 4', :require => false if RUBY_VERSION >= '2.2.6' - gem 'rbnacl-libsodium', :require => false if RUBY_VERSION >= '2.2.6' + gem 'rbnacl', '>= 4', :require => false + gem 'rbnacl-libsodium', :require => false gem 'bcrypt_pbkdf', :require => false end group :release do - gem 'github_changelog_generator', :require => false, :git => 'https://github.com/github-changelog-generator/github-changelog-generator' if RUBY_VERSION >= '2.2.2' + gem 'github_changelog_generator', :require => false, :git => 'https://github.com/github-changelog-generator/github-changelog-generator' gem 'puppet-blacksmith', :require => false gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem' - gem 'puppet-strings', '>= 1.0', :require => false + gem 'puppet-strings', '>= 2.2', :require => false end @@ -77,7 +76,7 @@ else gem 'facter', :require => false, :groups => [:test] end -ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 5.0' : puppetversion = ENV['PUPPET_VERSION'].to_s +ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 6.0' : puppetversion = ENV['PUPPET_VERSION'].to_s gem 'puppet', puppetversion, :require => false, :groups => [:test] # vim: syntax=ruby diff --git a/Rakefile b/Rakefile index 279580ac..09701d0f 100644 --- a/Rakefile +++ b/Rakefile @@ -3,19 +3,12 @@ require 'puppetlabs_spec_helper/rake_tasks' # 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 = 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') +PuppetLint.configuration.absolute_classname_reverse = true exclude_paths = %w( pkg/**/* @@ -28,8 +21,7 @@ PuppetSyntax.exclude_paths = exclude_paths desc 'Auto-correct puppet-lint offenses' task 'lint:auto_correct' do - PuppetLint.configuration.fix = true - Rake::Task[:lint].invoke + Rake::Task[:lint_fix].invoke end desc 'Run acceptance tests' @@ -37,11 +29,24 @@ RSpec::Core::RakeTask.new(:acceptance) do |t| t.pattern = 'spec/acceptance' end -desc 'Run tests metadata_lint, release_checks' -task test: [ - :metadata_lint, - :release_checks, -] +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 @@ -54,25 +59,10 @@ task test_with_coveralls: [:test] do end end -desc "Print supported beaker sets" -task 'beaker_sets', [:directory] do |t, args| - directory = args[:directory] - - metadata = JSON.load(File.read('metadata.json')) - - (metadata['operatingsystem_support'] || []).each do |os| - (os['operatingsystemrelease'] || []).each do |release| - if directory - beaker_set = "#{directory}/#{os['operatingsystem'].downcase}-#{release}" - else - beaker_set = "#{os['operatingsystem'].downcase}-#{release}-x64" - end - - filename = "spec/acceptance/nodesets/#{beaker_set}.yml" - - puts beaker_set if File.exists? filename - end - end +desc 'Generate REFERENCE.md' +task :reference, [:debug, :backtrace] do |t, args| + patterns = '' + Rake::Task['strings:generate:reference'].invoke(patterns, args[:debug], args[:backtrace]) end begin diff --git a/examples/jira_mysql_install.pp b/examples/jira_mysql_install.pp index f1b45adc..39df7969 100644 --- a/examples/jira_mysql_install.pp +++ b/examples/jira_mysql_install.pp @@ -1,6 +1,6 @@ node default { - class { '::mysql::server': + class { 'mysql::server': root_password => 'strongpassword', } @@ -11,7 +11,7 @@ grant => ['ALL'], } - -> class { '::jira': + -> class { 'jira': javahome => '/opt/java/latest', db => 'mysql', dbport => '3306', @@ -19,6 +19,6 @@ dbtype => 'mysql', } - include ::jira::facts + include jira::facts } diff --git a/examples/jira_mysql_nativessl_install.pp b/examples/jira_mysql_nativessl_install.pp index db283fb9..e92545be 100644 --- a/examples/jira_mysql_nativessl_install.pp +++ b/examples/jira_mysql_nativessl_install.pp @@ -3,7 +3,7 @@ $cert = hiera('cert') $key = hiera('key') - class { '::mysql::server': + class { 'mysql::server': root_password => 'strongpassword', } @@ -45,7 +45,7 @@ ], } - class { '::jira': + class { 'jira': javahome => '/opt/java/latest', db => 'mysql', dbport => '3306', @@ -56,6 +56,6 @@ require => Mysql::Db['jira'], } - include ::jira::facts + include jira::facts } diff --git a/examples/jira_postgres_install.pp b/examples/jira_postgres_install.pp index 290247f7..fe724a13 100644 --- a/examples/jira_postgres_install.pp +++ b/examples/jira_postgres_install.pp @@ -1,21 +1,21 @@ node default { - class { '::postgresql::globals': + class { 'postgresql::globals': manage_package_repo => true, version => '9.3', } - -> class { '::postgresql::server': } + -> class { 'postgresql::server': } -> postgresql::server::db { 'jira': user => 'jiraadm', password => postgresql_password('jiraadm', 'mypassword'), } - -> class { '::jira': + -> class { 'jira': javahome => '/opt/java/latest', } - include ::jira::facts + include jira::facts } diff --git a/examples/jira_postgres_nginx_install.pp b/examples/jira_postgres_nginx_install.pp index cd4dfd40..33650003 100644 --- a/examples/jira_postgres_nginx_install.pp +++ b/examples/jira_postgres_nginx_install.pp @@ -1,20 +1,20 @@ node default { - class { '::nginx': } + class { 'nginx': } - -> class { '::postgresql::globals': + -> class { 'postgresql::globals': manage_package_repo => true, version => '9.3', } - -> class { '::postgresql::server': } + -> class { 'postgresql::server': } -> postgresql::server::db { 'jira': user => 'jiraadm', password => postgresql_password('jiraadm', 'mypassword'), } - -> class { '::jira': + -> class { 'jira': javahome => '/opt/java/latest', proxy => { scheme => 'http', @@ -23,7 +23,7 @@ }, } - include ::jira::facts + include jira::facts nginx::resource::upstream { 'jira': ensure => present, diff --git a/examples/jira_postgres_nginx_ssl_install.pp b/examples/jira_postgres_nginx_ssl_install.pp index 37b1710a..d0ccfd8b 100644 --- a/examples/jira_postgres_nginx_ssl_install.pp +++ b/examples/jira_postgres_nginx_ssl_install.pp @@ -1,20 +1,20 @@ node default { - class { '::nginx': } + class { 'nginx': } - -> class { '::postgresql::globals': + -> class { 'postgresql::globals': manage_package_repo => true, version => '9.3', } - -> class { '::postgresql::server': } + -> class { 'postgresql::server': } -> postgresql::server::db { 'jira': user => 'jiraadm', password => postgresql_password('jiraadm', 'mypassword'), } - -> class { '::jira': + -> class { 'jira': javahome => '/opt/java/latest', proxy => { scheme => 'https', @@ -23,7 +23,7 @@ }, } - include ::jira::facts + include jira::facts nginx::resource::upstream { 'jira': ensure => present, diff --git a/manifests/init.pp b/manifests/init.pp index cfa8977f..4172084f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -285,6 +285,6 @@ ~> Class['jira::service'] if ($enable_sso) { - class { '::jira::sso': } + class { 'jira::sso': } } } diff --git a/manifests/install.pp b/manifests/install.pp index 5ebb6bdc..396d341a 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -15,7 +15,7 @@ # ----------------------------------------------------------------------------- class jira::install { - include '::archive' + include 'archive' if $jira::manage_user { group { $jira::group: @@ -78,7 +78,7 @@ case $jira::deploy_module { 'staging': { - require ::staging + require staging staging::file { $file: source => "${jira::download_url}/${file}", timeout => 1800, @@ -140,14 +140,14 @@ if $jira::db == 'mysql' and $jira::mysql_connector_manage { if $jira::deploy_module == 'archive' { - class { '::jira::mysql_connector': + class { 'jira::mysql_connector': require => Archive["/tmp/${file}"], } } elsif $jira::deploy_module == 'deploy' { - class { '::jira::mysql_connector': + class { 'jira::mysql_connector': require => Staging::Extract[$file], } } - contain ::jira::mysql_connector + contain jira::mysql_connector } } diff --git a/manifests/mysql_connector.pp b/manifests/mysql_connector.pp index 44ab0f38..592af815 100644 --- a/manifests/mysql_connector.pp +++ b/manifests/mysql_connector.pp @@ -7,7 +7,7 @@ $download_url = $jira::mysql_connector_url, ) { - require ::staging + require staging $file = "${product}-${version}.${format}" diff --git a/metadata.json b/metadata.json index a5f03c26..437dbdc8 100644 --- a/metadata.json +++ b/metadata.json @@ -28,7 +28,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 4.10.0 < 7.0.0" + "version_requirement": ">= 5.5.8 < 7.0.0" } ], "operatingsystem_support": [ diff --git a/spec/default_facts.yml b/spec/default_facts.yml deleted file mode 100644 index 2f6698d5..00000000 --- a/spec/default_facts.yml +++ /dev/null @@ -1,13 +0,0 @@ -# This file is managed via modulesync -# https://github.com/voxpupuli/modulesync -# https://github.com/voxpupuli/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. ---- -ipaddress: "172.16.254.254" -is_pe: false -macaddress: "AA:AA:AA:AA:AA:AA" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 88bca595..c53e7031 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,10 +1,23 @@ # This file is managed via modulesync # https://github.com/voxpupuli/modulesync # https://github.com/voxpupuli/modulesync_config +RSpec.configure do |c| + c.mock_with :rspec +end + require 'puppetlabs_spec_helper/module_spec_helper' require 'rspec-puppet-facts' include RspecPuppetFacts +if File.exist?(File.join(__dir__, 'default_module_facts.yml')) + facts = YAML.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 +end + if Dir.exist?(File.expand_path('../../lib', __FILE__)) require 'coveralls' require 'simplecov' @@ -22,11 +35,6 @@ end RSpec.configure do |c| - default_facts = {} - 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 - # Coverage generation c.after(:suite) do RSpec::Puppet::Coverage.report!