From 2b169ede5aaf1979b074b4c407fba58f00808d2d Mon Sep 17 00:00:00 2001 From: Garrett Rowell Date: Tue, 13 Mar 2018 12:41:34 -0400 Subject: [PATCH 01/19] glob cactis db path, require stdlib --- manifests/mysql.pp | 2 +- metadata.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/manifests/mysql.pp b/manifests/mysql.pp index 3c79d52..32aa2b9 100644 --- a/manifests/mysql.pp +++ b/manifests/mysql.pp @@ -30,7 +30,7 @@ password => $::cacti::database_pass, host => $::cacti::database_host, grant => ['ALL'], - sql => '/usr/share/doc/cacti-1.1.10/cacti.sql', + sql => glob('/usr/share/doc/cacti-*/cacti.sql'), charset => 'utf8', collate => 'utf8_general_ci', notify => Exec['patch MySQL TimeZone support'], diff --git a/metadata.json b/metadata.json index 132b952..60cc911 100644 --- a/metadata.json +++ b/metadata.json @@ -9,7 +9,8 @@ "issues_url": "https://github.com/cnwrinc/cnwr-cacti/issues", "dependencies": [ { "name":"puppet/cron", "version_requirement":">=1.1.0" }, - { "name":"puppetlabs/mysql", "version_requirement":">= 3.6.1" } + { "name":"puppetlabs/mysql", "version_requirement":">= 3.6.1" }, + { "name":"puppetlabs/stdlib", "version_requirement":">= 3.2.0" } ], "tags": ["cacti"], "operatingsystem_support": [ From 93f6bce09c70579d741799370447c23add833def Mon Sep 17 00:00:00 2001 From: Garrett Rowell Date: Tue, 13 Mar 2018 12:56:24 -0400 Subject: [PATCH 02/19] update Gemfile and gitignore --- .gitignore | 1 + Gemfile | 93 +++++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 69 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index f89d371..8b24434 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ spec/fixtures/m* vendor *.lock coverage/* +bin/* diff --git a/Gemfile b/Gemfile index 158a189..57fcafa 100644 --- a/Gemfile +++ b/Gemfile @@ -1,34 +1,77 @@ -source "https://rubygems.org" +source ENV['GEM_SOURCE'] || "https://rubygems.org" + +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 "rake" - gem "puppet", ENV['PUPPET_GEM_VERSION'] || '~> 3.8.0' - gem "rspec", '< 3.2.0' - gem "rspec-puppet", :git => 'https://github.com/rodjek/rspec-puppet.git' - gem "puppetlabs_spec_helper" - gem "metadata-json-lint" - gem "rspec-puppet-facts" - gem 'rubocop', '0.33.0' - gem 'simplecov' - gem 'simplecov-console' - gem 'coveralls', require: false - gem "puppet-lint-absolute_classname-check" - gem "puppet-lint-leading_zero-check" - gem "puppet-lint-trailing_comma-check" - gem "puppet-lint-version_comparison-check" - gem "puppet-lint-classes_and_types_beginning_with_digits-check" - gem "puppet-lint-unquoted_string-check" + gem 'puppetlabs_spec_helper', '~> 2.6.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" - gem "travis-lint" - gem "puppet-blacksmith" - gem "guard-rake" + 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 "beaker" - gem "beaker-rspec" - gem "beaker-puppet_install_helper" + 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 + +group :release do + gem 'github_changelog_generator', :require => false, :git => 'https://github.com/skywinder/github-changelog-generator' if RUBY_VERSION >= '2.2.2' + 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 +end + + + +if facterversion = ENV['FACTER_GEM_VERSION'] + gem 'facter', facterversion.to_s, :require => false, :groups => [:test] +else + gem 'facter', :require => false, :groups => [:test] end + +ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 5.0' : puppetversion = ENV['PUPPET_VERSION'].to_s +gem 'puppet', puppetversion, :require => false, :groups => [:test] + +# vim: syntax=ruby From 9fcf122578aa6043389ae82b35c031d43ff8039a Mon Sep 17 00:00:00 2001 From: Garrett Rowell Date: Tue, 13 Mar 2018 13:06:56 -0400 Subject: [PATCH 03/19] linting + replace exec in mysql.pp --- manifests/config.pp | 2 +- manifests/mysql.pp | 42 ++++++++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 00c6ad4..2163083 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -24,7 +24,7 @@ 'defnode nomodauthzcore Directory[arg="/usr/share/cacti/"]/IfModule[arg="!mod_authz_core.c"] ""', 'set $nomodauthzcore/directive[.="Allow"]/arg[2] "all"', ], - notify => Service[$::cacti::managed_services], + notify => Service[$::cacti::managed_services], } cron::job { 'cacti': diff --git a/manifests/mysql.pp b/manifests/mysql.pp index 32aa2b9..56feab8 100644 --- a/manifests/mysql.pp +++ b/manifests/mysql.pp @@ -5,24 +5,26 @@ class cacti::mysql( $override_options = { 'mysqld' => { - 'max_heap_table_size' => Integer($::memory['system']['total_bytes'] * 0.10), - 'max_allowed_packet' => '16M', - 'tmp_table_size' => '64M', - 'join_buffer_size' => '64M', - 'innodb_file_per_table' => 'ON', - 'innodb_buffer_pool_size' => Integer($::memory['system']['total_bytes'] * 0.25), - 'innodb_doublewrite' => 'OFF', + 'max_heap_table_size' => Integer($::memory['system']['total_bytes'] * 0.10), + 'max_allowed_packet' => '16M', + 'tmp_table_size' => '64M', + 'join_buffer_size' => '64M', + 'innodb_file_per_table' => 'ON', + 'innodb_buffer_pool_size' => Integer($::memory['system']['total_bytes'] * 0.25), + 'innodb_doublewrite' => 'OFF', 'innodb_additional_mem_pool_size' => '80M', - 'innodb_lock_wait_timeout' => '50', - 'innodb_flush_log_at_trx_commit' => '2' - } + 'innodb_lock_wait_timeout' => '50', + 'innodb_flush_log_at_trx_commit' => '2', + 'character-set-server' => 'utf8', + 'collation-server' => 'utf8_general_ci', }, - ) inherits ::cacti{ + }, +) inherits ::cacti { class { '::mysql::server': root_password => $::cacti::database_root_pass, remove_default_accounts => true, - override_options => $override_options, + override_options => $override_options, } mysql::db { 'cacti': @@ -31,14 +33,18 @@ host => $::cacti::database_host, grant => ['ALL'], sql => glob('/usr/share/doc/cacti-*/cacti.sql'), - charset => 'utf8', - collate => 'utf8_general_ci', - notify => Exec['patch MySQL TimeZone support'], + charset => 'utf8', + collate => 'utf8_general_ci', + require => Package[$::cacti::cacti_package], } - exec { 'patch MySQL TimeZone support': - command => "mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -Dmysql -p$::cacti::database_root_pass && mysql -p$::cacti::database_root_pass -D mysql -e \"GRANT SELECT ON mysql.time_zone_name TO ${::cacti::database_user}@localhost; flush privileges;\"", - refreshonly => true; + mysql::db { 'mysql': + user => $::cacti::database_user, + password => $::cacti::database_pass, + host => $::cacti::database_host, + grant => ['ALL'], + charset => 'utf8', + collate => 'utf8_general_ci', } } From a4334732db7d4d0bee6cc7f2fc15944e2ffe3eb5 Mon Sep 17 00:00:00 2001 From: Garrett Rowell Date: Tue, 13 Mar 2018 13:16:21 -0400 Subject: [PATCH 04/19] dont move cacti source. stick with package defaults --- manifests/install.pp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index e30762f..373db21 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -8,13 +8,4 @@ ensure => present, } - if($::selinux_enforced){ - - # Move http scripts under /var/www/html, add symlink to /usr/share/cacti and - # restore context on the files - exec {'mv /usr/share/cacti /var/www/html/ && ln -s /var/www/html/cacti /usr/share && restorecon -v -r /var/www/html/cacti': - creates => '/var/www/html/cacti', - require => Package[$::cacti_package]; - } - } } From 06384409a3dd95cb1380c57361258aa474d03210 Mon Sep 17 00:00:00 2001 From: Garrett Rowell Date: Tue, 13 Mar 2018 16:53:35 -0400 Subject: [PATCH 05/19] optionally manage php + epel. minor param cleanup --- manifests/init.pp | 22 ++++++++++++---------- manifests/install.pp | 29 ++++++++++++++++++++++++++--- manifests/mysql.pp | 25 +++++++++++++++---------- manifests/params.pp | 19 +++++++++++-------- 4 files changed, 64 insertions(+), 31 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 7017331..5ead3f6 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -58,17 +58,19 @@ # Defaults to [] # class cacti ( - $cacti_package = $::cacti::params::cacti_package, + $cacti_package = $::cacti::params::cacti_package, $database_root_pass = $::cacti::params::database_root_pass, - $database_pass = $::cacti::params::database_pass, - $database_user = $::cacti::params::database_user, - $database_host = $::cacti::params::database_host, - $database_type = $::cacti::params::database_type, - $database_default = $::cacti::params::database_default, - $database_port = $::cacti::params::database_port, - $database_ssl = $::cacti::params::database_ssl, - $managed_services = $::cacti::params::managed_services, - + $database_pass = $::cacti::params::database_pass, + $database_user = $::cacti::params::database_user, + $database_host = $::cacti::params::database_host, + $database_type = $::cacti::params::database_type, + $database_default = $::cacti::params::database_default, + $database_port = $::cacti::params::database_port, + $database_ssl = $::cacti::params::database_ssl, + $managed_services = $::cacti::params::managed_services, + $configure_epel = $::cacti::params::configure_epel, + $configure_php = $::cacti::params::configure_php, + $php_timezone = $::cacti::params::php_timezone, ) inherits ::cacti::params { validate_string($cacti_package) diff --git a/manifests/install.pp b/manifests/install.pp index 373db21..81cc15d 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -2,10 +2,33 @@ # # This class is called from cacti for install. # -class cacti::install inherits cacti{ +class cacti::install ( + $cacti_package = $::cacti::cacti_package, + $configure_epel = $::cacti::configure_epel, + $configure_php = $::cacti::configure_php, + $php_timezone = $::cacti::php_timezone, +){ - package { $::cacti::cacti_package: - ensure => present, + package { $cacti_package: + ensure => present, + } + + if $configure_epel { + include ::epel + Class['epel'] -> Package[$cacti_package] + } + + if $configure_php { + package { 'php': + ensure => present, + before => Package[$cacti_package], + } + + class { '::php': + settings => { + 'Date/date.timezone' => $php_timezone, + } + } } } diff --git a/manifests/mysql.pp b/manifests/mysql.pp index 56feab8..9550e92 100644 --- a/manifests/mysql.pp +++ b/manifests/mysql.pp @@ -3,7 +3,12 @@ # This class is called from cacti for database config. # git@github.com:puppetlabs/puppetlabs-mysql.git class cacti::mysql( - $override_options = { + $database_root_pass = $::cacti::database_root_pass, + $database_user = $::cacti::database_user, + $database_pass = $::cacti::database_pass, + $database_host = $::cacti::database_host, + $cacti_package = $::cacti::cacti_package, + $override_options = { 'mysqld' => { 'max_heap_table_size' => Integer($::memory['system']['total_bytes'] * 0.10), 'max_allowed_packet' => '16M', @@ -19,29 +24,29 @@ 'collation-server' => 'utf8_general_ci', }, }, -) inherits ::cacti { +) { class { '::mysql::server': - root_password => $::cacti::database_root_pass, + root_password => $database_root_pass, remove_default_accounts => true, override_options => $override_options, } mysql::db { 'cacti': - user => $::cacti::database_user, - password => $::cacti::database_pass, - host => $::cacti::database_host, + user => $database_user, + password => $database_pass, + host => $database_host, grant => ['ALL'], sql => glob('/usr/share/doc/cacti-*/cacti.sql'), charset => 'utf8', collate => 'utf8_general_ci', - require => Package[$::cacti::cacti_package], + require => Package[$cacti_package], } mysql::db { 'mysql': - user => $::cacti::database_user, - password => $::cacti::database_pass, - host => $::cacti::database_host, + user => $database_user, + password => $database_pass, + host => $database_host, grant => ['ALL'], charset => 'utf8', collate => 'utf8_general_ci', diff --git a/manifests/params.pp b/manifests/params.pp index 527f8ba..e1d8240 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -4,21 +4,24 @@ # It sets variables according to platform. # class cacti::params { - $database_user = 'cacti' - $database_host = 'localhost' - $database_type = 'mysql' - $database_default = 'cacti' - $database_port = '3306' - $database_ssl = false - $managed_services = [] + $database_user = 'cacti' + $database_host = 'localhost' + $database_type = 'mysql' + $database_default = 'cacti' + $database_port = '3306' + $database_ssl = false + $managed_services = [] $database_root_pass = undef - $database_pass = undef + $database_pass = undef + $configure_php = true + $php_timezone = undef case $::osfamily { 'RedHat': { case $::operatingsystemmajrelease { '7': { $cacti_package = 'cacti' + $configure_epel = true } default: { fail("${::operatingsystem} ${::operatingsystemmajrelease} not supported") From e1ef9177fc805e9d53b6ec5fc85c5ea9c73df52b Mon Sep 17 00:00:00 2001 From: Garrett Rowell Date: Tue, 13 Mar 2018 17:07:18 -0400 Subject: [PATCH 06/19] update deps in metadata and fixtures --- .fixtures.yml | 7 +++---- metadata.json | 23 ++++++++++++++++++++--- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index c3f8979..fb696dc 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,9 +1,8 @@ fixtures: repositories: stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git" - mysql: - repo: "https://github.com/puppetlabs/puppetlabs-mysql.git" - ref: "fa66b38b588" - cron: "https://github.com/roman-mueller/rmueller-cron.git" + mysql: "https://github.com/puppetlabs/puppetlabs-mysql.git" + cron: "https://github.com/voxpupuli/puppet-cron" + php: "https://github.com/voxpupuli/puppet-php.git" symlinks: cacti: "#{source_dir}" diff --git a/metadata.json b/metadata.json index 60cc911..e5e8fdd 100644 --- a/metadata.json +++ b/metadata.json @@ -8,9 +8,26 @@ "project_page": "https://github.com/cnwrinc/cnwr-cacti", "issues_url": "https://github.com/cnwrinc/cnwr-cacti/issues", "dependencies": [ - { "name":"puppet/cron", "version_requirement":">=1.1.0" }, - { "name":"puppetlabs/mysql", "version_requirement":">= 3.6.1" }, - { "name":"puppetlabs/stdlib", "version_requirement":">= 3.2.0" } + { + "name":"puppet/cron", + "version_requirement":">=1.1.0" + }, + { + "name":"puppetlabs/mysql", + "version_requirement":">= 3.6.1" + }, + { + "name":"puppetlabs/stdlib", + "version_requirement":">= 3.2.0 < 5.0.0" + }, + { + "name":"stahnma/epel", + "version_requirement":">= 1.0.0 < 2.0.0" + }, + { + "name":"puppet/php", + "version_requirement":">= 5.0.0 < 6.0.0" + } ], "tags": ["cacti"], "operatingsystem_support": [ From 88f49781ac62959777ced93537dacc900a9a54be Mon Sep 17 00:00:00 2001 From: Garrett Rowell Date: Tue, 13 Mar 2018 17:22:31 -0400 Subject: [PATCH 07/19] trying out new badges --- README.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.markdown b/README.markdown index 84d5477..b0ae298 100644 --- a/README.markdown +++ b/README.markdown @@ -2,6 +2,10 @@ [![Build Status](https://travis-ci.org/cnwrinc/cnwr-cacti.svg?branch=master)](https://travis-ci.org/cnwrinc/cnwr-cacti) [![Coverage Status](https://coveralls.io/repos/cnwrinc/cnwr-cacti/badge.svg?branch=master&service=github)](https://coveralls.io/github/cnwrinc/cnwr-cacti?branch=master) +[![Puppet Forge](https://img.shields.io/puppetforge/v/cnwrinc/cnwr-cacti.svg)](https://forge.puppetlabs.com/cnwrinc/cnwr-cacti) +[![Puppet Forge - downloads](https://img.shields.io/puppetforge/dt/cnwrinc/cnwr-cacti.svg)](https://forge.puppetlabs.com/cnwrinc/cnwr-cacti) +[![Puppet Forge - endorsement](https://img.shields.io/puppetforge/e/cnwrinc/cnwr-cacti.svg)](https://forge.puppetlabs.com/cnwrinc/cnwr-cacti) +[![Puppet Forge - scores](https://img.shields.io/puppetforge/f/cnwrinc/cnwr-cacti.svg)](https://forge.puppetlabs.com/cnwrinc/cnwr-cacti) #### Table of Contents From be938e64386234913ef341d3b13d3f4b53689ed4 Mon Sep 17 00:00:00 2001 From: Garrett Rowell Date: Tue, 13 Mar 2018 17:24:37 -0400 Subject: [PATCH 08/19] fix badges --- README.markdown | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.markdown b/README.markdown index b0ae298..0b4967d 100644 --- a/README.markdown +++ b/README.markdown @@ -2,10 +2,10 @@ [![Build Status](https://travis-ci.org/cnwrinc/cnwr-cacti.svg?branch=master)](https://travis-ci.org/cnwrinc/cnwr-cacti) [![Coverage Status](https://coveralls.io/repos/cnwrinc/cnwr-cacti/badge.svg?branch=master&service=github)](https://coveralls.io/github/cnwrinc/cnwr-cacti?branch=master) -[![Puppet Forge](https://img.shields.io/puppetforge/v/cnwrinc/cnwr-cacti.svg)](https://forge.puppetlabs.com/cnwrinc/cnwr-cacti) -[![Puppet Forge - downloads](https://img.shields.io/puppetforge/dt/cnwrinc/cnwr-cacti.svg)](https://forge.puppetlabs.com/cnwrinc/cnwr-cacti) -[![Puppet Forge - endorsement](https://img.shields.io/puppetforge/e/cnwrinc/cnwr-cacti.svg)](https://forge.puppetlabs.com/cnwrinc/cnwr-cacti) -[![Puppet Forge - scores](https://img.shields.io/puppetforge/f/cnwrinc/cnwr-cacti.svg)](https://forge.puppetlabs.com/cnwrinc/cnwr-cacti) +[![Puppet Forge](https://img.shields.io/puppetforge/v/cnwr/cacti.svg)](https://forge.puppetlabs.com/cnwr/cacti) +[![Puppet Forge - downloads](https://img.shields.io/puppetforge/dt/cnwr/cacti.svg)](https://forge.puppetlabs.com/cnwr/cacti) +[![Puppet Forge - endorsement](https://img.shields.io/puppetforge/e/cnwr/-cacti.svg)](https://forge.puppetlabs.com/cnwr/cacti) +[![Puppet Forge - scores](https://img.shields.io/puppetforge/f/cnwr/cacti.svg)](https://forge.puppetlabs.com/cnwr/cacti) #### Table of Contents From b616baa5abf930423998e024f8a4f81921814258 Mon Sep 17 00:00:00 2001 From: Garrett Rowell Date: Tue, 13 Mar 2018 18:17:45 -0400 Subject: [PATCH 09/19] glob wont work due to timing. allow mysql exec to glob. dep uppper bounds --- .fixtures.yml | 1 - manifests/mysql.pp | 2 +- metadata.json | 8 ++------ 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index fb696dc..aea81ad 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,6 +1,5 @@ fixtures: repositories: - stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git" mysql: "https://github.com/puppetlabs/puppetlabs-mysql.git" cron: "https://github.com/voxpupuli/puppet-cron" php: "https://github.com/voxpupuli/puppet-php.git" diff --git a/manifests/mysql.pp b/manifests/mysql.pp index 9550e92..6106287 100644 --- a/manifests/mysql.pp +++ b/manifests/mysql.pp @@ -37,7 +37,7 @@ password => $database_pass, host => $database_host, grant => ['ALL'], - sql => glob('/usr/share/doc/cacti-*/cacti.sql'), + sql => '/usr/share/doc/cacti-*/cacti.sql', charset => 'utf8', collate => 'utf8_general_ci', require => Package[$cacti_package], diff --git a/metadata.json b/metadata.json index e5e8fdd..36d7c72 100644 --- a/metadata.json +++ b/metadata.json @@ -10,15 +10,11 @@ "dependencies": [ { "name":"puppet/cron", - "version_requirement":">=1.1.0" + "version_requirement":">=1.1.0 < 2.0.0" }, { "name":"puppetlabs/mysql", - "version_requirement":">= 3.6.1" - }, - { - "name":"puppetlabs/stdlib", - "version_requirement":">= 3.2.0 < 5.0.0" + "version_requirement":">= 3.6.1 < 6.0.0" }, { "name":"stahnma/epel", From 111a4d13fc0d967df4fdc3e4b8ba7851bd13ddf8 Mon Sep 17 00:00:00 2001 From: Garrett Rowell Date: Tue, 13 Mar 2018 18:53:52 -0400 Subject: [PATCH 10/19] php should restart httpd after install --- manifests/install.pp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index 81cc15d..6a117f5 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -3,10 +3,11 @@ # This class is called from cacti for install. # class cacti::install ( - $cacti_package = $::cacti::cacti_package, - $configure_epel = $::cacti::configure_epel, - $configure_php = $::cacti::configure_php, - $php_timezone = $::cacti::php_timezone, + $cacti_package = $::cacti::cacti_package, + $configure_epel = $::cacti::configure_epel, + $configure_php = $::cacti::configure_php, + $php_timezone = $::cacti::php_timezone, + $managed_services = $::cacti::managed_services, ){ package { $cacti_package: @@ -25,6 +26,7 @@ } class { '::php': + notify => Service[$managed_services], settings => { 'Date/date.timezone' => $php_timezone, } From 94e4432a9c55873d9ae5c748176110bd351d5532 Mon Sep 17 00:00:00 2001 From: Garrett Rowell Date: Wed, 14 Mar 2018 13:57:42 -0400 Subject: [PATCH 11/19] get existing tests working, disable coveralls for now --- README.markdown | 4 +++- spec/classes/cacti_spec.rb | 6 +++--- spec/classes/mysql_spec.rb | 2 +- spec/spec_helper_local.rb | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.markdown b/README.markdown index 0b4967d..599082c 100644 --- a/README.markdown +++ b/README.markdown @@ -1,7 +1,9 @@ # cacti [![Build Status](https://travis-ci.org/cnwrinc/cnwr-cacti.svg?branch=master)](https://travis-ci.org/cnwrinc/cnwr-cacti) + [![Puppet Forge](https://img.shields.io/puppetforge/v/cnwr/cacti.svg)](https://forge.puppetlabs.com/cnwr/cacti) [![Puppet Forge - downloads](https://img.shields.io/puppetforge/dt/cnwr/cacti.svg)](https://forge.puppetlabs.com/cnwr/cacti) [![Puppet Forge - endorsement](https://img.shields.io/puppetforge/e/cnwr/-cacti.svg)](https://forge.puppetlabs.com/cnwr/cacti) @@ -32,7 +34,7 @@ The Cacti module installs, configures, and manages all of Cacti's dependencies. Uses the [puppetlabs-mysql](https://github.com/puppetlabs/puppetlabs-mysql) module to install, manage, and configure mariadb for use with cacti. -Uses [rmueller-cron](https://github.com/roman-mueller/rmueller-cron) to manage /etc/cron.d/cacti. +Uses [puppet-cron](https://github.com/voxpupuli/puppet-cron) to manage /etc/cron.d/cacti. ## Setup diff --git a/spec/classes/cacti_spec.rb b/spec/classes/cacti_spec.rb index 69a5885..f2a95e0 100644 --- a/spec/classes/cacti_spec.rb +++ b/spec/classes/cacti_spec.rb @@ -29,9 +29,9 @@ end it { should compile.with_all_deps } it { should contain_class('cacti::params') } - it { should contain_class('cacti::install').that_comes_before('cacti::mysql') } - it { should contain_class('cacti::mysql').that_comes_before('cacti::config') } - it { should contain_class('cacti::config').that_comes_before('cacti::service') } + it { should contain_class('cacti::install').that_comes_before('Class[cacti::mysql]') } + it { should contain_class('cacti::mysql').that_comes_before('Class[cacti::config]') } + it { should contain_class('cacti::config').that_comes_before('Class[cacti::service]') } it { should contain_class('cacti::service') } end end diff --git a/spec/classes/mysql_spec.rb b/spec/classes/mysql_spec.rb index 16eb7ab..fd16eae 100644 --- a/spec/classes/mysql_spec.rb +++ b/spec/classes/mysql_spec.rb @@ -41,7 +41,7 @@ "password"=>"cacti_password", "host"=>"localhost", "grant"=>["ALL"], - "sql"=>"/usr/share/doc/cacti-0.8.8b/cacti.sql"}) + "sql"=>"/usr/share/doc/cacti-*/cacti.sql"}) end end end diff --git a/spec/spec_helper_local.rb b/spec/spec_helper_local.rb index 88c3c3c..fb5e9c6 100644 --- a/spec/spec_helper_local.rb +++ b/spec/spec_helper_local.rb @@ -2,7 +2,7 @@ require 'puppetlabs_spec_helper/module_spec_helper' require 'rspec-puppet-facts' include RspecPuppetFacts -require 'coveralls' +#require 'coveralls' #Coveralls.wear! RSpec.configure do |config| From 45bdb885a294efa5bb2030ef0488259f2cd23525 Mon Sep 17 00:00:00 2001 From: Garrett Rowell Date: Wed, 14 Mar 2018 14:48:34 -0400 Subject: [PATCH 12/19] require rspec-puppet in coverage spec --- spec/classes/coverage_spec.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/classes/coverage_spec.rb b/spec/classes/coverage_spec.rb index 12513b8..de44654 100644 --- a/spec/classes/coverage_spec.rb +++ b/spec/classes/coverage_spec.rb @@ -1 +1,4 @@ +require 'rspec-puppet' + at_exit { RSpec::Puppet::Coverage.report! } +# vim: syntax=ruby From f720b7d7342ea654f84be51a9e70b05fe3c650b1 Mon Sep 17 00:00:00 2001 From: Garrett Rowell Date: Wed, 14 Mar 2018 14:57:05 -0400 Subject: [PATCH 13/19] default tests should run against cent7 --- spec/acceptance/nodesets/default.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml index dba339c..5d8a460 100644 --- a/spec/acceptance/nodesets/default.yml +++ b/spec/acceptance/nodesets/default.yml @@ -1,10 +1,11 @@ HOSTS: - ubuntu-1404-x64: + centos-7-x64: roles: - agent - default - platform: ubuntu-14.04-amd64 + platform: el-7-x86_64 hypervisor: vagrant - box: puppetlabs/ubuntu-14.04-64-nocm + box: puppetlabs/centos-7.2-64-nocm CONFIG: type: foss + From 440d6d9ad69cbcd9be7eb73ffb70f1308ef07240 Mon Sep 17 00:00:00 2001 From: Garrett Rowell Date: Wed, 14 Mar 2018 15:06:59 -0400 Subject: [PATCH 14/19] remove beaker tests for now --- .travis.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index b5d3180..3ddeac7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,18 +7,6 @@ script: "bundle exec rake release_checks" matrix: fast_finish: true include: - - rvm: 2.3.1 - dist: trusty - env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/ubuntu-14.04 - script: bundle exec rake beaker - services: docker - sudo: required - - rvm: 2.3.1 - dist: trusty - env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/centos-7 - script: bundle exec rake beaker - services: docker - sudo: required - rvm: 2.4.1 bundler_args: --without system_tests env: PUPPET_GEM_VERSION="~> 5.0" From d926a163d48a2fda5ec21dc4568af6264d8c597c Mon Sep 17 00:00:00 2001 From: Garrett Rowell Date: Wed, 14 Mar 2018 15:25:33 -0400 Subject: [PATCH 15/19] tweaking travis config --- .travis.yml | 19 +++++++--- Rakefile | 107 +++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 95 insertions(+), 31 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3ddeac7..a29793c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,11 +7,20 @@ script: "bundle exec rake release_checks" matrix: fast_finish: true include: - - rvm: 2.4.1 - bundler_args: --without system_tests - env: PUPPET_GEM_VERSION="~> 5.0" - rvm: 2.1.9 - bundler_args: --without system_tests - env: PUPPET_GEM_VERSION="~> 4.0" + bundler_args: --without system_tests development release + env: PUPPET_VERSION="~> 4.0" CHECK=test PARALLEL_TEST_PROCESSORS=12 + - rvm: 2.4.3 + bundler_args: --without system_tests development release + env: PUPPET_VERSION="~> 5.0" CHECK=test_with_coveralls + - rvm: 2.5.0 + bundler_args: --without system_tests development release + env: PUPPET_VERSION="~> 5.0" CHECK=test_with_coveralls + - rvm: 2.4.3 + bundler_args: --without system_tests development release + env: PUPPET_VERSION="~> 5.0" CHECK=rubocop +# - rvm: 2.4.3 +# bundler_args: --without system_tests development release +# env: PUPPET_VERSION="~> 5.0" CHECK=build DEPLOY_TO_FORGE=yes notifications: email: false diff --git a/Rakefile b/Rakefile index d12d854..279580a 100644 --- a/Rakefile +++ b/Rakefile @@ -1,37 +1,92 @@ require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet-lint/tasks/puppet-lint' -require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? +# 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') + +exclude_paths = %w( + pkg/**/* + vendor/**/* + .vendor/**/* + spec/**/* +) +PuppetLint.configuration.ignore_paths = exclude_paths +PuppetSyntax.exclude_paths = exclude_paths + +desc 'Auto-correct puppet-lint offenses' +task 'lint:auto_correct' do + PuppetLint.configuration.fix = true + Rake::Task[:lint].invoke +end + +desc 'Run acceptance tests' +RSpec::Core::RakeTask.new(:acceptance) do |t| + t.pattern = 'spec/acceptance' +end -desc 'Generate pooler nodesets' -task :gen_nodeset do - require 'beaker-hostgenerator' - require 'securerandom' - require 'fileutils' - - agent_target = ENV['TEST_TARGET'] - if ! agent_target - STDERR.puts 'TEST_TARGET environment variable is not set' - STDERR.puts 'setting to default value of "redhat-64default."' - agent_target = 'redhat-64default.' +desc 'Run tests metadata_lint, release_checks' +task test: [ + :metadata_lint, + :release_checks, +] + +desc "Run main 'test' task and report merged results to coveralls" +task test_with_coveralls: [:test] do + if Dir.exist?(File.expand_path('../lib', __FILE__)) + require 'coveralls/rake/task' + Coveralls::RakeTask.new + Rake::Task['coveralls:push'].invoke + else + puts 'Skipping reporting to coveralls. Module has no lib dir' end +end + +desc "Print supported beaker sets" +task 'beaker_sets', [:directory] do |t, args| + directory = args[:directory] + + metadata = JSON.load(File.read('metadata.json')) - master_target = ENV['MASTER_TEST_TARGET'] - if ! master_target - STDERR.puts 'MASTER_TEST_TARGET environment variable is not set' - STDERR.puts 'setting to default value of "redhat7-64mdcl"' - master_target = 'redhat7-64mdcl' + (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 +end - targets = "#{master_target}-#{agent_target}" - cli = BeakerHostGenerator::CLI.new([targets]) - nodeset_dir = "tmp/nodesets" - nodeset = "#{nodeset_dir}/#{targets}-#{SecureRandom.uuid}.yaml" - FileUtils.mkdir_p(nodeset_dir) - File.open(nodeset, 'w') do |fh| - fh.print(cli.execute) +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 = 'voxpupuli' + metadata_json = File.join(File.dirname(__FILE__), 'metadata.json') + metadata = JSON.load(File.read(metadata_json)) + config.project = metadata['name'] end - puts nodeset +rescue LoadError end +# vim: syntax=ruby From 8659b5d0375816d82da790f613efa8f5f7f56c9c Mon Sep 17 00:00:00 2001 From: Garrett Rowell Date: Wed, 14 Mar 2018 15:33:35 -0400 Subject: [PATCH 16/19] Change Gemfile --- Gemfile | 121 ++++++++++++++++++++++++++------------------------------ 1 file changed, 57 insertions(+), 64 deletions(-) diff --git a/Gemfile b/Gemfile index 828505d..1f8d9a8 100644 --- a/Gemfile +++ b/Gemfile @@ -1,84 +1,77 @@ -#This file is generated by ModuleSync, do not edit. - source ENV['GEM_SOURCE'] || "https://rubygems.org" -# Determines what type of gem is requested based on place_or_version. -def gem_type(place_or_version) - if place_or_version =~ /^git:/ - :git - elsif place_or_version =~ /^file:/ - :file - else - :gem - end -end - -# Find a location or specific version for a gem. place_or_version can be a -# version, which is most often used. It can also be git, which is specified as -# `git://somewhere.git#branch`. You can also use a file source location, which -# is specified as `file://some/location/on/disk`. -def location_for(place_or_version, fake_version = nil) - if place_or_version =~ /^(git[:@][^#]*)#(.*)/ +def location_for(place, fake_version = nil) + if place =~ /^(git[:@][^#]*)#(.*)/ [fake_version, { :git => $1, :branch => $2, :require => false }].compact - elsif place_or_version =~ /^file:\/\/(.*)/ + elsif place =~ /^file:\/\/(.*)/ ['>= 0', { :path => File.expand_path($1), :require => false }] else - [place_or_version, { :require => false }] + [place, { :require => false }] end end -# Used for gem conditionals -ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments -minor_version = "#{ruby_version_segments[0]}.#{ruby_version_segments[1]}" - -# The following gems are not included by default as they require DevKit on Windows. -# You should probably include them in a Gemfile.local or a ~/.gemfile -#gem 'pry' #this may already be included in the gemfile -#gem 'pry-stack_explorer', :require => false -#if RUBY_VERSION =~ /^2/ -# gem 'pry-byebug' -#else -# gem 'pry-debugger' -#end +group :test do + gem 'puppetlabs_spec_helper', '~> 2.5.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 "puppet-module-posix-default-r#{minor_version}", :require => false, :platforms => "ruby" - gem "puppet-module-win-default-r#{minor_version}", :require => false, :platforms => ["mswin", "mingw", "x64_mingw"] - gem "puppet-module-posix-dev-r#{minor_version}", :require => false, :platforms => "ruby" - gem "puppet-module-win-dev-r#{minor_version}", '0.0.7', :require => false, :platforms => ["mswin", "mingw", "x64_mingw"] - gem "json_pure", '<= 2.0.1', :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') - gem "fast_gettext", '1.1.0', :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') - gem "fast_gettext", :require => false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') + gem '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 "puppet-module-posix-system-r#{minor_version}", :require => false, :platforms => "ruby" - gem "puppet-module-win-system-r#{minor_version}", :require => false, :platforms => ["mswin", "mingw", "x64_mingw"] - gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '>= 3') - gem "beaker-pe", :require => false - gem "beaker-rspec", *location_for(ENV['BEAKER_RSPEC_VERSION']) - gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION']) - gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1') - gem "puppet-blacksmith", '~> 3.4', :require => false + 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 -gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION']) +group :release do + gem 'github_changelog_generator', :require => false, :git => 'https://github.com/skywinder/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 +end -# Only explicitly specify Facter/Hiera if a version has been specified. -# Otherwise it can lead to strange bundler behavior. If you are seeing weird -# gem resolution behavior, try setting `DEBUG_RESOLVER` environment variable -# to `1` and then run bundle install. -gem 'facter', *location_for(ENV['FACTER_GEM_VERSION']) if ENV['FACTER_GEM_VERSION'] -gem 'hiera', *location_for(ENV['HIERA_GEM_VERSION']) if ENV['HIERA_GEM_VERSION'] -# Evaluate Gemfile.local if it exists -if File.exists? "#{__FILE__}.local" - eval(File.read("#{__FILE__}.local"), binding) -end -# Evaluate ~/.gemfile if it exists -if File.exists?(File.join(Dir.home, '.gemfile')) - eval(File.read(File.join(Dir.home, '.gemfile')), binding) +if facterversion = ENV['FACTER_GEM_VERSION'] + gem 'facter', facterversion.to_s, :require => false, :groups => [:test] +else + gem 'facter', :require => false, :groups => [:test] end -# vim:ft=ruby +ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 5.0' : puppetversion = ENV['PUPPET_VERSION'].to_s +gem 'puppet', puppetversion, :require => false, :groups => [:test] + +# vim: syntax=ruby From a36a0e73bbc246e20f2bbc10a4c559b7dd16dc0a Mon Sep 17 00:00:00 2001 From: Garrett Rowell Date: Wed, 14 Mar 2018 15:45:42 -0400 Subject: [PATCH 17/19] tweaking travis --- .travis.yml | 5 ++++- Rakefile | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a29793c..77582fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,10 @@ sudo: false language: ruby cache: bundler -script: "bundle exec rake release_checks" +before_install: + - rm -f Gemfile.lock +script: + - 'bundle exec rake $CHECK' matrix: fast_finish: true include: diff --git a/Rakefile b/Rakefile index 279580a..c6af322 100644 --- a/Rakefile +++ b/Rakefile @@ -82,7 +82,7 @@ begin 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 = 'voxpupuli' + config.user = 'cnwr' metadata_json = File.join(File.dirname(__FILE__), 'metadata.json') metadata = JSON.load(File.read(metadata_json)) config.project = metadata['name'] From a2d8359b51dce6dcdd660070ae2a874219078da7 Mon Sep 17 00:00:00 2001 From: Garrett Rowell Date: Thu, 15 Mar 2018 11:18:25 -0400 Subject: [PATCH 18/19] try to get coveralls working, linting, pleasing the rubocop gods, rewrite spec tests --- .rspec_parallel | 2 + .rubocop.yml | 617 ++++++++++++++++++++++++---- spec/acceptance/class_spec.rb | 6 +- spec/classes/cacti_spec.rb | 109 +++-- spec/classes/config_spec.rb | 54 --- spec/classes/install_spec.rb | 43 -- spec/classes/mysql_spec.rb | 48 --- spec/classes/service_spec.rb | 73 ---- spec/default_facts.yml | 5 + spec/fixtures/hiera/cacti_data.yaml | 3 - spec/spec_helper.rb | 36 +- spec/spec_helper_acceptance.rb | 4 +- spec/spec_helper_local.rb | 15 - 13 files changed, 643 insertions(+), 372 deletions(-) create mode 100644 .rspec_parallel delete mode 100644 spec/classes/config_spec.rb delete mode 100644 spec/classes/install_spec.rb delete mode 100644 spec/classes/mysql_spec.rb delete mode 100644 spec/classes/service_spec.rb create mode 100644 spec/default_facts.yml delete mode 100644 spec/fixtures/hiera/cacti_data.yaml delete mode 100644 spec/spec_helper_local.rb diff --git a/.rspec_parallel b/.rspec_parallel new file mode 100644 index 0000000..16f9cdb --- /dev/null +++ b/.rspec_parallel @@ -0,0 +1,2 @@ +--color +--format documentation diff --git a/.rubocop.yml b/.rubocop.yml index 515ef63..099a11c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,98 +1,545 @@ ---- -require: - - rubocop-rspec +require: rubocop-rspec AllCops: - TargetRubyVersion: '2.1' + TargetRubyVersion: 1.9 Include: - - "./**/*.rb" + - ./**/*.rb Exclude: - - bin/* - - ".vendor/**/*" - - Gemfile - - Rakefile - - pkg/**/* - - spec/fixtures/**/* - - vendor/**/* -inherit_from: .rubocop_todo.yml -Metrics/LineLength: - Description: People have wide screens, use them. - Max: 200 -RSpec/BeforeAfterAll: - Description: Beware of using after(:all) as it may cause state to leak between tests. - A necessary evil in acceptance testing. - Exclude: - - spec/acceptance/**/*.rb -RSpec/HookArgument: - Description: Prefer explicit :each argument, matching existing module's style - EnforcedStyle: each -Style/BlockDelimiters: - Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to - be consistent then. - EnforcedStyle: braces_for_chaining + - 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: - Description: Compact style reduces the required amount of indentation. - EnforcedStyle: compact -Style/EmptyElse: - Description: Enforce against empty else clauses, but allow `nil` for clarity. - EnforcedStyle: empty -Style/FormatString: - Description: Following the main puppet project's style, prefer the % format format. - EnforcedStyle: percent -Style/FormatStringToken: - Description: Following the main puppet project's style, prefer the simpler template - tokens over annotated ones. - EnforcedStyle: template + 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: - Description: Prefer the keyword for easier discoverability. - EnforcedStyle: literal + 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: - Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168 EnforcedStyle: percent_r -Style/TernaryParentheses: - Description: Checks for use of parentheses around ternary conditions. Enforce parentheses - on complex expressions for better readability, but seriously consider breaking - it up. - EnforcedStyle: require_parentheses_when_complex -Style/TrailingCommaInArguments: - Description: Prefer always trailing comma on multiline argument lists. This makes - diffs, and re-ordering nicer. - EnforcedStyleForMultiline: comma -Style/TrailingCommaInLiteral: - Description: Prefer always trailing comma on multiline literals. This makes diffs, - and re-ordering nicer. - EnforcedStyleForMultiline: comma -Style/SymbolArray: - Description: Using percent style obscures symbolic intent of array's contents. - EnforcedStyle: brackets -Style/CollectionMethods: - Enabled: true -Style/MethodCalledOnDoEndBlock: - Enabled: true -Style/StringMethods: - Enabled: true -Metrics/AbcSize: - Enabled: false -Metrics/BlockLength: - Enabled: false -Metrics/ClassLength: - Enabled: false -Metrics/CyclomaticComplexity: - Enabled: false -Metrics/MethodLength: - Enabled: false -Metrics/ModuleLength: - Enabled: false + Enabled: True + +Lint/UnderscorePrefixedVariableName: + Enabled: True + Metrics/ParameterLists: - Enabled: false + 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 + 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 -RSpec/MessageExpectation: - Enabled: false -Style/AsciiComments: - Enabled: false -Style/IfUnlessModifier: + +# This affects hiera interpolation, as well as some configs that we push. +Style/FormatStringToken: Enabled: false -Style/SymbolProc: + +# This is useful, but sometimes a little too picky about where unit tests files +# are located. +RSpec/FilePath: Enabled: false diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index e09e15b..d04e64a 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -3,14 +3,14 @@ describe 'cacti class' do context 'default parameters' do # Using puppet_apply as a helper - it 'should work idempotently with no errors' do + it 'hopefully works idempotently with no errors' do pp = <<-EOS class { 'cacti': } EOS # Run it twice and test for idempotency - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + apply_manifest(pp, 'catch_failures' => true) + apply_manifest(pp, 'catch_changes' => true) end describe package('cacti') do diff --git a/spec/classes/cacti_spec.rb b/spec/classes/cacti_spec.rb index f2a95e0..c8cfb09 100644 --- a/spec/classes/cacti_spec.rb +++ b/spec/classes/cacti_spec.rb @@ -1,39 +1,78 @@ require 'spec_helper' -required_params = "database_root_pass => 'root_password', database_pass => 'cacti_password'," - -describe 'cacti' do - on_supported_os({ - :hardwaremodels => ['x86_64'], - :supported_os => [ - { - "operatingsystem" => "RedHat", - "operatingsystemrelease" => [ - "7", - ] - } - ], - }).each do |os, facts| - context "on #{os}" do - context "defaults + required params" do - let(:pre_condition) { "class {'cacti': #{required_params}}" } - let(:facts) do - facts.merge({ - :root_home => '/root', - :memory => { - :system => { - :total_bytes => 1024 - } +describe 'cacti', type: :class do + on_supported_os.each do |os, facts| + context "on #{os} " do + let :facts do + facts + end + + let :required_params do + { + 'database_root_pass' => 'root_password', + 'database_pass' => 'cacti_password' + } + end + + context 'with required params SET' do + let :params do + required_params + end + + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_class('cacti::params') } + it { is_expected.to contain_class('cacti::install').that_comes_before('Class[cacti::mysql]') } + it { is_expected.to contain_class('cacti::mysql').that_comes_before('Class[cacti::config]') } + it { is_expected.to contain_class('cacti::config').that_comes_before('Class[cacti::service]') } + it { is_expected.to contain_class('cacti::service') } + + context 'and configure_epel => true' do + let :params do + required_params + end + + it { is_expected.to contain_class('epel').that_comes_before('Package[cacti]') } + end # context configure_epel => true + + context 'and configure_epel => false' do + let :params do + required_params.merge!('configure_epel' => false) + end + + it { is_expected.not_to contain_class('epel') } + end # context configure_epel => false + + context 'and configure_php => true' do + it do + is_expected.to contain_package('php').with( + 'ensure' => 'present', + 'before' => 'Package[cacti]' + ) + end + + it do + is_expected.to contain_class('php').with( + 'notify' => '[]', + 'settings' => { + 'Date/date.timezone' => :undef } - }) + ) end - it { should compile.with_all_deps } - it { should contain_class('cacti::params') } - it { should contain_class('cacti::install').that_comes_before('Class[cacti::mysql]') } - it { should contain_class('cacti::mysql').that_comes_before('Class[cacti::config]') } - it { should contain_class('cacti::config').that_comes_before('Class[cacti::service]') } - it { should contain_class('cacti::service') } - end - end - end -end + end # context configure_php => true + + context 'and configure_php => false' do + let :params do + required_params.merge!('configure_php' => false) + end + + it { is_expected.not_to contain_package('php') } + it { is_expected.not_to contain_class('php') } + end # context configure_php => false + end # context required params SET + + context 'with required params UNSET' do + it { is_expected.not_to compile.with_all_deps } + end # context required params UNSET + end # context on os + end # on_supported_os.each +end # describe cacti class diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb deleted file mode 100644 index ff374a1..0000000 --- a/spec/classes/config_spec.rb +++ /dev/null @@ -1,54 +0,0 @@ -require 'spec_helper' - -required_params = "database_root_pass => 'root_password', database_pass => 'cacti_password'," - -describe 'cacti::config' do - on_supported_os({ - :hardwaremodels => ['x86_64'], - :supported_os => [ - { - "operatingsystem" => "RedHat", - "operatingsystemrelease" => [ - "7", - ] - } - ], - }).each do |os, facts| - context "on #{os}" do - let(:pre_condition) { "class {'cacti': #{required_params}}" } - let(:facts) do - facts.merge({ - :root_home => '/root', - :memory => { - :system => { - :total_bytes => 1024 - } - } - }) - end - let(:params) do - { - } - end - it do - is_expected.to contain_file('/etc/cacti/db.php'). - with({"ensure"=>"present", - "content"=>/.*\$database_type\s=\s\"mysql\";\s\$database_default\s=\s\"cacti\";\s\$database_hostname\s=\s\"localhost\";\s\$database_username\s=\s\"cacti\";\s\$database_password\s=\s\"cacti_password\";\s*\$database_port\s=\s\"3306\";\s\$database_ssl\s=\sfalse;.*/m, - "mode"=>"0640", - "owner"=>"cacti", - "group"=>"apache"}) - end - it do - is_expected.to contain_augeas('cacti_perms'). - with({"incl"=>"/etc/httpd/conf.d/cacti.conf", - "lens"=>"Httpd.lns"}) - end - it do - is_expected.to contain_cron__job('cacti'). - with({"minute"=>"*/5", - "command"=>"/usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1", - "user"=>"cacti"}) - end - end - end -end diff --git a/spec/classes/install_spec.rb b/spec/classes/install_spec.rb deleted file mode 100644 index 535f681..0000000 --- a/spec/classes/install_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'spec_helper' - -required_params = "database_root_pass => 'root_password', database_pass => 'cacti_password'," - -describe 'cacti::install' do - on_supported_os({ - :hardwaremodels => ['x86_64'], - :supported_os => [ - { - "operatingsystem" => "RedHat", - "operatingsystemrelease" => [ - "7", - ] - } - ], - }).each do |os, facts| - context "on #{os}" do - let(:pre_condition) { "class {'cacti': #{required_params}}" } - let(:facts) do - facts.merge({ - :root_home => '/root', - :memory => { - :system => { - :total_bytes => 1024 - } - } - }) - end - let(:params) do - { - } - end - case os - when "redhat-7-x86_64" - it do - is_expected.to contain_package('cacti'). - with({"ensure"=>"present"}) - end - - end - end - end -end diff --git a/spec/classes/mysql_spec.rb b/spec/classes/mysql_spec.rb deleted file mode 100644 index fd16eae..0000000 --- a/spec/classes/mysql_spec.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'spec_helper' - -required_params = "database_root_pass => 'root_password', database_pass => 'cacti_password'," - -describe 'cacti::mysql' do - on_supported_os({ - :hardwaremodels => ['x86_64'], - :supported_os => [ - { - "operatingsystem" => "RedHat", - "operatingsystemrelease" => [ - "7", - ] - } - ], - }).each do |os, facts| - context "on #{os}" do - let(:pre_condition) { "class {'cacti': #{required_params}}" } - let(:facts) do - facts.merge({ - :root_home => '/root', - :memory => { - :system => { - :total_bytes => 1024 - } - } - }) - end - let(:params) do - { - } - end - it do - is_expected.to contain_class("mysql::server"). - with({"root_password"=>"root_password", - "remove_default_accounts"=>true}) - end - it do - is_expected.to contain_mysql__db('cacti'). - with({"user"=>"cacti", - "password"=>"cacti_password", - "host"=>"localhost", - "grant"=>["ALL"], - "sql"=>"/usr/share/doc/cacti-*/cacti.sql"}) - end - end - end -end diff --git a/spec/classes/service_spec.rb b/spec/classes/service_spec.rb deleted file mode 100644 index 154f3ac..0000000 --- a/spec/classes/service_spec.rb +++ /dev/null @@ -1,73 +0,0 @@ -require 'spec_helper' - -required_params = "database_root_pass => 'root_password', database_pass => 'cacti_password'," -services = [ 'httpd', 'snmpd' ] - -describe 'cacti::service' do - on_supported_os({ - :hardwaremodels => ['x86_64'], - :supported_os => [ - { - "operatingsystem" => "RedHat", - "operatingsystemrelease" => [ - "7", - ] - } - ], - }).each do |os, facts| - context "on #{os}" do - context "managed_services => #{services}" do - let(:pre_condition) { "class {'cacti': managed_services => #{services}, #{required_params}}" } - let(:facts) do - facts.merge({ - :root_home => '/root', - :memory => { - :system => { - :total_bytes => 1024 - } - } - }) - end - let(:params) do - { - } - end - services.each do |service| - it do - is_expected.to contain_service(service). - with({"ensure" =>"running", - "enable" =>"true", - "hasstatus" =>"true", - "hasrestart"=>"true"}) - end - end - end - context "managed_services => []" do - let(:pre_condition) { "class {'cacti': managed_services => [], #{required_params}}" } - let(:facts) do - facts.merge({ - :root_home => '/root', - :memory => { - :system => { - :total_bytes => 1024 - } - } - }) - end - let(:params) do - { - } - end - services.each do |service| - it do - is_expected.not_to contain_service(service). - with({"ensure" =>"running", - "enable" =>"true", - "hasstatus" =>"true", - "hasrestart"=>"true"}) - end - end - end - end - end -end diff --git a/spec/default_facts.yml b/spec/default_facts.yml new file mode 100644 index 0000000..b441577 --- /dev/null +++ b/spec/default_facts.yml @@ -0,0 +1,5 @@ +--- +root_home: '/root' +memory: + system: + total_bytes: 1024 diff --git a/spec/fixtures/hiera/cacti_data.yaml b/spec/fixtures/hiera/cacti_data.yaml deleted file mode 100644 index ebc6b89..0000000 --- a/spec/fixtures/hiera/cacti_data.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -cacti::database_root_pass: 'root_password' -cacti::database_pass: 'cacti_password' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c808092..cdd4935 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,17 +1,31 @@ -# This file is generated by ModuleSync, do not edit. require 'puppetlabs_spec_helper/module_spec_helper' +require 'rspec-puppet-facts' +include RspecPuppetFacts -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - RSpec.configure do |c| - c.before :each do - Puppet.settings[:strict] = :error - end +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 -# put local configuration and setup into spec_helper_local -begin - require 'spec_helper_local' -rescue LoadError => loaderror - puts "Could not require spec_helper_local: #{loaderror.message}" +RSpec.configure do |c| + 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 diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 5875ed3..512a57e 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -22,9 +22,9 @@ # Configure all nodes in nodeset c.before :suite do # Install module and dependencies - puppet_module_install(:source => proj_root, :module_name => 'cacti') + puppet_module_install('source' => proj_root, 'module_name' => 'cacti') hosts.each do |host| - on host, puppet('module', 'install', 'puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } + on host, puppet('module', 'install', 'puppetlabs-stdlib'), { 'acceptable_exit_codes' => [0, 1] } end end end diff --git a/spec/spec_helper_local.rb b/spec/spec_helper_local.rb deleted file mode 100644 index fb5e9c6..0000000 --- a/spec/spec_helper_local.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rubygems' -require 'puppetlabs_spec_helper/module_spec_helper' -require 'rspec-puppet-facts' -include RspecPuppetFacts -#require 'coveralls' -#Coveralls.wear! - -RSpec.configure do |config| - config.mock_framework = :rspec - - config.mock_with :rspec do |c| - c.syntax = [:should, :expect] - end - config.hiera_config = File.expand_path(File.join(__FILE__, '../fixtures/hiera.yaml')) -end From 653d64b2fac089cfbc9effc16b2bcee866f4672b Mon Sep 17 00:00:00 2001 From: Garrett Rowell Date: Thu, 15 Mar 2018 16:46:09 -0400 Subject: [PATCH 19/19] tweak spec_helper --- .rspec | 2 -- .rspec_parallel | 2 -- spec/classes/coverage_spec.rb | 4 ---- spec/spec_helper.rb | 7 +++++++ 4 files changed, 7 insertions(+), 8 deletions(-) delete mode 100644 .rspec delete mode 100644 .rspec_parallel delete mode 100644 spec/classes/coverage_spec.rb diff --git a/.rspec b/.rspec deleted file mode 100644 index 16f9cdb..0000000 --- a/.rspec +++ /dev/null @@ -1,2 +0,0 @@ ---color ---format documentation diff --git a/.rspec_parallel b/.rspec_parallel deleted file mode 100644 index 16f9cdb..0000000 --- a/.rspec_parallel +++ /dev/null @@ -1,2 +0,0 @@ ---color ---format documentation diff --git a/spec/classes/coverage_spec.rb b/spec/classes/coverage_spec.rb deleted file mode 100644 index de44654..0000000 --- a/spec/classes/coverage_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rspec-puppet' - -at_exit { RSpec::Puppet::Coverage.report! } -# vim: syntax=ruby diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cdd4935..e385cdc 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -19,6 +19,7 @@ end RSpec.configure do |c| + # Setup default facts default_facts = { puppetversion: Puppet.version, facterversion: Facter.version @@ -26,6 +27,12 @@ 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 + + # Move these settings from .rspec + c.color = true + c.formatter = 'documentation' end +at_exit { RSpec::Puppet::Coverage.report! } + # vim: syntax=ruby