From 565c78cc7faf636fb1f224a295c6c0c907dbc22a Mon Sep 17 00:00:00 2001 From: Sebastien Badia Date: Sun, 22 Feb 2015 22:14:37 +0100 Subject: [PATCH] Add Puppet 4.x lint checks This changes the puppet-lint requirement to 1.1.x, so that we can use puppet-lint plugins. Most of these plugins are for 4.x compat, but some just catch common errors. This commit also remove custom metadata rake task (this task is now provided by puppetlabs_spec_helper). Conflicts: Gemfile Change-Id: I22369948db6a2f8ddab9b8c93c3a047ff2e229ca --- Gemfile | 15 +++++++++++++-- Rakefile | 5 ----- examples/site.pp | 24 ++++++++++++------------ manifests/agent/central.pp | 2 +- manifests/agent/compute.pp | 2 +- manifests/agent/notification.pp | 2 +- manifests/agent/polling.pp | 2 +- manifests/alarm/evaluator.pp | 2 +- manifests/alarm/notifier.pp | 2 +- manifests/api.pp | 4 ++-- manifests/client.pp | 2 +- manifests/collector.pp | 2 +- manifests/db.pp | 4 ++-- manifests/expirer.pp | 2 +- manifests/init.pp | 2 +- manifests/keystone/auth.pp | 2 +- manifests/wsgi/apache.pp | 2 +- 17 files changed, 41 insertions(+), 35 deletions(-) diff --git a/Gemfile b/Gemfile index 7cd12c5f..b0b2d45f 100644 --- a/Gemfile +++ b/Gemfile @@ -2,9 +2,20 @@ source 'https://rubygems.org' group :development, :test do gem 'puppetlabs_spec_helper', :require => false - gem 'rspec-puppet', '~> 2.0.0' - gem 'puppet-lint-param-docs' + gem 'rspec-puppet', '~> 2.0.0', :require => false + gem 'metadata-json-lint' + gem 'puppet-lint-param-docs' + gem 'puppet-lint-absolute_classname-check' + gem 'puppet-lint-absolute_template_path' + gem 'puppet-lint-trailing_newline-check' + + # Puppet 4.x related lint checks + gem 'puppet-lint-unquoted_string-check' + gem 'puppet-lint-leading_zero-check' + gem 'puppet-lint-variable_contains_upcase' + gem 'puppet-lint-numericvariable' + gem 'json' gem 'webmock' end diff --git a/Rakefile b/Rakefile index c022216c..bb3e2bbf 100644 --- a/Rakefile +++ b/Rakefile @@ -10,8 +10,3 @@ PuppetLint.configuration.send('disable_only_variable_string') exclude_tests_paths = ['pkg/**/*','vendor/**/*'] PuppetLint.configuration.ignore_paths = exclude_tests_paths PuppetSyntax.exclude_paths = exclude_tests_paths - -desc "Lint metadata.json file" -task :metadata do - sh "metadata-json-lint metadata.json" -end diff --git a/examples/site.pp b/examples/site.pp index fd247203..e95812e2 100644 --- a/examples/site.pp +++ b/examples/site.pp @@ -4,39 +4,39 @@ node default { } # First, install a mysql server - class { 'mysql::server': } + class { '::mysql::server': } # And create the database - class { 'ceilometer::db::mysql': + class { '::ceilometer::db::mysql': password => 'ceilometer', } # Add the base ceilometer class & parameters # This class is required by ceilometer agents & api classes # The metering_secret parameter is mandatory - class { 'ceilometer': + class { '::ceilometer': metering_secret => 'darksecret' } # Configure the ceilometer database # Only needed if ceilometer::agent::central or ceilometer::api are declared - class { 'ceilometer::db': + class { '::ceilometer::db': } # Configure ceilometer database with mongodb - # class { 'ceilometer::db': + # class { '::ceilometer::db': # database_connection => 'mongodb://localhost:27017/ceilometer', # require => Class['mongodb'], # } # Install the ceilometer-api service # The keystone_password parameter is mandatory - class { 'ceilometer::api': + class { '::ceilometer::api': keystone_password => 'tralalayouyou' } # Set common auth parameters used by all agents (compute/central) - class { 'ceilometer::agent::auth': + class { '::ceilometer::agent::auth': auth_url => 'http://localhost:35357/v2.0', auth_password => 'tralalerotralala' } @@ -59,7 +59,7 @@ node default { # ipmi_namespace => true # } # As default use central and compute polling namespaces - class { 'ceilometer::agent::polling': + class { '::ceilometer::agent::polling': central_namespace => true, compute_namespace => true, ipmi_namespace => false, @@ -75,20 +75,20 @@ node default { # } # Install alarm notifier - class { 'ceilometer::alarm::notifier': + class { '::ceilometer::alarm::notifier': } # Install alarm evaluator - class { 'ceilometer::alarm::evaluator': + class { '::ceilometer::alarm::evaluator': } # Purge 1 month old meters - class { 'ceilometer::expirer': + class { '::ceilometer::expirer': time_to_live => '2592000' } # Install notification agent - class { 'ceilometer::agent::notification': + class { '::ceilometer::agent::notification': } } diff --git a/manifests/agent/central.pp b/manifests/agent/central.pp index a781255f..e197b383 100644 --- a/manifests/agent/central.pp +++ b/manifests/agent/central.pp @@ -25,7 +25,7 @@ class ceilometer::agent::central ( $coordination_url = undef, ) { - include ceilometer::params + include ::ceilometer::params Ceilometer_config<||> ~> Service['ceilometer-agent-central'] diff --git a/manifests/agent/compute.pp b/manifests/agent/compute.pp index 300ccef0..2cd02ac9 100644 --- a/manifests/agent/compute.pp +++ b/manifests/agent/compute.pp @@ -22,7 +22,7 @@ class ceilometer::agent::compute ( warning('This class is deprecated. Please use ceilometer::agent::polling with compute namespace instead.') - include ceilometer::params + include ::ceilometer::params Ceilometer_config<||> ~> Service['ceilometer-agent-compute'] diff --git a/manifests/agent/notification.pp b/manifests/agent/notification.pp index 9a692244..de0c9546 100644 --- a/manifests/agent/notification.pp +++ b/manifests/agent/notification.pp @@ -52,7 +52,7 @@ class ceilometer::agent::notification ( $package_ensure = 'present', ) { - include ceilometer::params + include ::ceilometer::params Ceilometer_config<||> ~> Service['ceilometer-agent-notification'] diff --git a/manifests/agent/polling.pp b/manifests/agent/polling.pp index 1d02a483..209b4eab 100644 --- a/manifests/agent/polling.pp +++ b/manifests/agent/polling.pp @@ -40,7 +40,7 @@ class ceilometer::agent::polling ( $coordination_url = undef, ) inherits ceilometer { - include ceilometer::params + include ::ceilometer::params if $central_namespace { $central_namespace_name = 'central' diff --git a/manifests/alarm/evaluator.pp b/manifests/alarm/evaluator.pp index 9a67843a..55c922ab 100644 --- a/manifests/alarm/evaluator.pp +++ b/manifests/alarm/evaluator.pp @@ -39,7 +39,7 @@ class ceilometer::alarm::evaluator ( $coordination_url = undef, ) { - include ceilometer::params + include ::ceilometer::params validate_re("${evaluation_interval}",'^(\d+)$') diff --git a/manifests/alarm/notifier.pp b/manifests/alarm/notifier.pp index 4bad2210..d4be85ce 100644 --- a/manifests/alarm/notifier.pp +++ b/manifests/alarm/notifier.pp @@ -34,7 +34,7 @@ class ceilometer::alarm::notifier ( $rest_notifier_ssl_verify = true, ) { - include ceilometer::params + include ::ceilometer::params validate_bool($rest_notifier_ssl_verify) diff --git a/manifests/api.pp b/manifests/api.pp index d85104dc..1d793323 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -76,8 +76,8 @@ class ceilometer::api ( $port = '8777' ) { - include ceilometer::params - include ceilometer::policy + include ::ceilometer::params + include ::ceilometer::policy validate_string($keystone_password) diff --git a/manifests/client.pp b/manifests/client.pp index faa791a1..c02ac3c0 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -9,7 +9,7 @@ class ceilometer::client ( $ensure = 'present' ) { - include ceilometer::params + include ::ceilometer::params package { 'python-ceilometerclient': ensure => $ensure, diff --git a/manifests/collector.pp b/manifests/collector.pp index 440538c5..3088fb41 100644 --- a/manifests/collector.pp +++ b/manifests/collector.pp @@ -19,7 +19,7 @@ class ceilometer::collector ( $package_ensure = 'present', ) { - include ceilometer::params + include ::ceilometer::params Ceilometer_config<||> ~> Service['ceilometer-collector'] diff --git a/manifests/db.pp b/manifests/db.pp index 02e5c799..74af7994 100644 --- a/manifests/db.pp +++ b/manifests/db.pp @@ -18,7 +18,7 @@ class ceilometer::db ( $mysql_module = undef, ) { - include ceilometer::params + include ::ceilometer::params if $mysql_module { warning('The mysql_module parameter is deprecated. The latest 2.x mysql module will be used.') @@ -33,7 +33,7 @@ class ceilometer::db ( /^mysql:\/\//: { $backend_package = false - include mysql::bindings::python + include ::mysql::bindings::python } /^postgresql:\/\//: { $backend_package = $::ceilometer::params::psycopg_package_name diff --git a/manifests/expirer.pp b/manifests/expirer.pp index 07a16fb7..a94159f5 100644 --- a/manifests/expirer.pp +++ b/manifests/expirer.pp @@ -51,7 +51,7 @@ class ceilometer::expirer ( $weekday = '*', ) { - include ceilometer::params + include ::ceilometer::params Package<| title == 'ceilometer-common' |> -> Class['ceilometer::expirer'] diff --git a/manifests/init.pp b/manifests/init.pp index b45a5ff8..cdfaef7b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -112,7 +112,7 @@ class ceilometer( validate_string($metering_secret) - include ceilometer::params + include ::ceilometer::params if $kombu_ssl_ca_certs and !$rabbit_use_ssl { fail('The kombu_ssl_ca_certs parameter requires rabbit_use_ssl to be set to true') diff --git a/manifests/keystone/auth.pp b/manifests/keystone/auth.pp index 2f8d9d8f..bc8b775b 100644 --- a/manifests/keystone/auth.pp +++ b/manifests/keystone/auth.pp @@ -125,7 +125,7 @@ class ceilometer::keystone::auth ( $real_service_name = $auth_name } - keystone::resource::service_identity { $auth_name: + ::keystone::resource::service_identity { $auth_name: configure_user => $configure_user, configure_user_role => $configure_user_role, configure_endpoint => $configure_endpoint, diff --git a/manifests/wsgi/apache.pp b/manifests/wsgi/apache.pp index d3d62959..8ddba112 100644 --- a/manifests/wsgi/apache.pp +++ b/manifests/wsgi/apache.pp @@ -102,7 +102,7 @@ class ceilometer::wsgi::apache ( include ::apache::mod::ssl } - openstacklib::wsgi::apache { 'ceilometer_wsgi': + ::openstacklib::wsgi::apache { 'ceilometer_wsgi': bind_host => $bind_host, bind_port => $port, group => 'ceilometer',