From 76117c72ae125da3f883ee3026210c967e167ce5 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Thu, 9 Jul 2015 15:16:30 -0700 Subject: [PATCH 1/2] (maint) Add Puppet version requirement to metadata Without this the Forge compares against Puppet 3.7, which will fail to compile the module. --- metadata.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/metadata.json b/metadata.json index b6e3aa2ad..9995156d2 100644 --- a/metadata.json +++ b/metadata.json @@ -46,6 +46,12 @@ ] } ], + "requirements": [ + { + "name": "puppet", + "version_requirement": ">= 3.8.0" + } + ], "dependencies": [ {"name":"puppetlabs-stdlib","version_requirement":">= 4.6.0"}, {"name":"puppetlabs-inifile","version_requirement":">= 1.2.0"}, From d5d9718127afd57d009dcfbd9a73be8c34b775dd Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Thu, 9 Jul 2015 15:23:32 -0700 Subject: [PATCH 2/2] (maint) Use Forge 'Puppet Approved' Lint settings https://forge.puppetlabs.com/approved/criteria outlines lint settings used to score Forge modules. Use those settings and fix new lint warnings/errors. Nested loops seem to throw puppet-lint for a loop, so introduce a local variable to circumvent a bogus warning. --- Rakefile | 25 +++++++------------------ manifests/init.pp | 4 ++-- manifests/osfamily/debian.pp | 8 ++++---- manifests/osfamily/redhat.pp | 14 +++++++------- manifests/params.pp | 18 +++++++++--------- manifests/prepare/mco_client_config.pp | 4 ++-- manifests/prepare/mco_server_config.pp | 4 ++-- manifests/prepare/puppet_config.pp | 3 ++- manifests/prepare/ssl.pp | 14 +++++++------- manifests/windows/install.pp | 14 +++++++------- 10 files changed, 49 insertions(+), 59 deletions(-) diff --git a/Rakefile b/Rakefile index 587b0348b..951dbbcc3 100644 --- a/Rakefile +++ b/Rakefile @@ -17,27 +17,16 @@ begin rescue LoadError end -Rake::Task[:lint].clear - -PuppetLint.configuration.relative = true -PuppetLint.configuration.send("disable_80chars") -PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}" PuppetLint.configuration.fail_on_warnings = true - -# Forsake support for Puppet 2.6.2 for the benefit of cleaner code. -# http://puppet-lint.com/checks/class_parameter_defaults/ -PuppetLint.configuration.send('disable_class_parameter_defaults') -# http://puppet-lint.com/checks/class_inherits_from_params_class/ +PuppetLint.configuration.send('relative') +PuppetLint.configuration.send('disable_80chars') 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.send('disable_only_variable_string') +PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] -exclude_paths = [ - "bundle/**/*", - "pkg/**/*", - "vendor/**/*", - "spec/**/*", -] -PuppetLint.configuration.ignore_paths = exclude_paths -PuppetSyntax.exclude_paths = exclude_paths +PuppetSyntax.exclude_paths = ["spec/**/*.pp", "pkg/**/*.pp"] desc "Run acceptance tests" RSpec::Core::RakeTask.new(:acceptance) do |t| diff --git a/manifests/init.pp b/manifests/init.pp index 76c5ef75d..e0394b969 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -23,10 +23,10 @@ validate_re($arch, ['^x86$','^x64$','^i386$','^amd64$','^x86_64$','^power$']) - if versioncmp("$::clientversion", '3.8.0') < 0 { + if versioncmp("${::clientversion}", '3.8.0') < 0 { fail('upgrading requires Puppet 3.8') } - elsif versioncmp("$::clientversion", '4.0.0') >= 0 { + elsif versioncmp("${::clientversion}", '4.0.0') >= 0 { info('puppet_agent performs no actions on Puppet 4+') } else { diff --git a/manifests/osfamily/debian.pp b/manifests/osfamily/debian.pp index 0c2930d4f..e64364554 100644 --- a/manifests/osfamily/debian.pp +++ b/manifests/osfamily/debian.pp @@ -42,13 +42,13 @@ apt::source { 'pc1_repo': - location => $source, - repos => 'PC1', - key => { + location => $source, + repos => 'PC1', + key => { 'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', 'server' => 'pgp.mit.edu', }, - notify => Notify['pc1_repo_force'], + notify => Notify['pc1_repo_force'], } # apt_update doesn't inherit the future class dependency, so it diff --git a/manifests/osfamily/redhat.pp b/manifests/osfamily/redhat.pp index a9cab96bd..3d008536f 100644 --- a/manifests/osfamily/redhat.pp +++ b/manifests/osfamily/redhat.pp @@ -56,14 +56,14 @@ } yumrepo { 'pc1_repo': - baseurl => $source, - descr => "Puppet Labs PC1 Repository", - enabled => true, - gpgcheck => '1', - gpgkey => "file://$gpg_path", - sslcacert => $_sslcacert_path, + baseurl => $source, + descr => 'Puppet Labs PC1 Repository', + enabled => true, + gpgcheck => '1', + gpgkey => "file://${gpg_path}", + sslcacert => $_sslcacert_path, sslclientcert => $_sslclientcert_path, - sslclientkey => $_sslclientkey_path, + sslclientkey => $_sslclientkey_path, } } diff --git a/manifests/params.pp b/manifests/params.pp index fada32ac7..021c1df76 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -38,8 +38,8 @@ $path_separator = ':' } 'windows' : { - $confdir = $puppet_confdir - $mco_dir = $mco_confdir + $confdir = $::puppet_confdir + $mco_dir = $::mco_confdir $mcodirs = [$mco_dir] # Directories should already exists as they have not changed $puppetdirs = [regsubst($confdir,'\/etc\/','/code/')] @@ -50,12 +50,12 @@ } } - $ssldir = "$confdir/ssl" - $config = "$confdir/puppet.conf" + $ssldir = "${confdir}/ssl" + $config = "${confdir}/puppet.conf" - $mco_server = "$mco_dir/server.cfg" - $mco_client = "$mco_dir/client.cfg" - $mco_libdir = "$mco_install/plugins" - $mco_plugins = "$mco_dir/facts.yaml" - $mco_log = "$logdir/mcollective.log" + $mco_server = "${mco_dir}/server.cfg" + $mco_client = "${mco_dir}/client.cfg" + $mco_libdir = "${mco_install}/plugins" + $mco_plugins = "${mco_dir}/facts.yaml" + $mco_log = "${logdir}/mcollective.log" } diff --git a/manifests/prepare/mco_client_config.pp b/manifests/prepare/mco_client_config.pp index ebd5ea49f..3e57d91f7 100644 --- a/manifests/prepare/mco_client_config.pp +++ b/manifests/prepare/mco_client_config.pp @@ -9,8 +9,8 @@ $mco_client = $::puppet_agent::params::mco_client file { $mco_client: - ensure => file, - source => $::mco_client_config, + ensure => file, + source => $::mco_client_config, } if $::mco_client_settings { diff --git a/manifests/prepare/mco_server_config.pp b/manifests/prepare/mco_server_config.pp index 0f2eeb90d..d3260f44e 100644 --- a/manifests/prepare/mco_server_config.pp +++ b/manifests/prepare/mco_server_config.pp @@ -9,8 +9,8 @@ $mco_server = $::puppet_agent::params::mco_server file { $mco_server: - ensure => file, - source => $::mco_server_config, + ensure => file, + source => $::mco_server_config, } if $::mco_server_settings { diff --git a/manifests/prepare/puppet_config.pp b/manifests/prepare/puppet_config.pp index 06c9ba4d0..0745d19b5 100644 --- a/manifests/prepare/puppet_config.pp +++ b/manifests/prepare/puppet_config.pp @@ -12,7 +12,8 @@ } # manage puppet.conf contents, using inifile module - ['master', 'agent', 'main'].each |$section| { + ['master', 'agent', 'main'].each |$loop_section| { + $section = $loop_section [# Removed settings 'allow_variables_with_dashes', 'async_storeconfigs', 'binder', 'catalog_format', 'certdnsnames', 'certificate_expire_warning', 'couchdb_url', 'dbadapter', 'dbconnections', 'dblocation', 'dbmigrate', 'dbname', diff --git a/manifests/prepare/ssl.pp b/manifests/prepare/ssl.pp index 2f8a2f86c..639c0185f 100644 --- a/manifests/prepare/ssl.pp +++ b/manifests/prepare/ssl.pp @@ -9,10 +9,10 @@ $ssl_dir = $::puppet_agent::params::ssldir file { $ssl_dir: - ensure => directory, - source => $::puppet_ssldir, - backup => false, - recurse => false, + ensure => directory, + source => $::puppet_ssldir, + backup => false, + recurse => false, } $sslpaths = { @@ -37,9 +37,9 @@ # The only one that's a file, not a directory. if $::puppet_sslpaths['hostcrl']['path_exists'] { file { "${ssl_dir}/crl.pem": - ensure => file, - source => $::puppet_sslpaths['hostcrl']['path'], - backup => false + ensure => file, + source => $::puppet_sslpaths['hostcrl']['path'], + backup => false } } } diff --git a/manifests/windows/install.pp b/manifests/windows/install.pp index 639d22cdf..487d33a8f 100644 --- a/manifests/windows/install.pp +++ b/manifests/windows/install.pp @@ -19,32 +19,32 @@ } $_msi_location = $_source ? { - /^puppet:/ => "${env_temp_variable}\\puppet-agent.msi", + /^puppet:/ => "${::env_temp_variable}\\puppet-agent.msi", default => $_source, } if $_source =~ /^puppet:/ { file{ $_msi_location: source => $_source, - before => File["${env_temp_variable}\\install_puppet.bat"], + before => File["${::env_temp_variable}\\install_puppet.bat"], } } $_cmd_location = $::rubyplatform ? { - /i386/ => "C:\\Windows\\system32\\cmd.exe", + /i386/ => 'C:\\Windows\\system32\\cmd.exe', default => "${::system32}\\cmd.exe" } $_timestamp = strftime('%Y_%m_%d-%H_%M') - $_logfile = "${env_temp_variable}\\puppet-${_timestamp}-installer.log" + $_logfile = "${::env_temp_variable}\\puppet-${_timestamp}-installer.log" notice ("Puppet upgrade log file at ${_logfile}") debug ("Installing puppet from ${_msi_location}") - file { "${env_temp_variable}\\install_puppet.bat": + file { "${::env_temp_variable}\\install_puppet.bat": ensure => file, content => template('puppet_agent/install_puppet.bat.erb') }-> exec { 'install_puppet.bat': - command => "${::system32}\\cmd.exe /c start /b ${_cmd_location} /c \"${env_temp_variable}\\install_puppet.bat\"", - path => $::path, + command => "${::system32}\\cmd.exe /c start /b ${_cmd_location} /c \"${::env_temp_variable}\\install_puppet.bat\"", + path => $::path, } }