Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Puppet Lint happy #37

Merged
merged 3 commits into from
Jan 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
PuppetLint.configuration.send('disable_selector_inside_resource')
PuppetLint.configuration.send('disable_only_variable_string')
PuppetLint.configuration.ignore_paths = [
"spec/**/*.pp",
"serverspec/**/*.pp",
"pkg/**/*.pp",
"examples/**/*.pp",
"vendor/**/*.pp"
]

desc "Validate manifests, templates, and ruby files"
task :validate do
Expand Down
12 changes: 6 additions & 6 deletions manifests/config/fragment.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
# Icinga Development Team <[email protected]>
#
define icinga2::config::fragment(
$code_name = $title,
$order = '0',
$content,
$target,
$code_name = $title,
$order = '0',
) {

include ::icinga2::params
Expand Down Expand Up @@ -58,13 +58,13 @@
}

concat::fragment { "icinga2::config::${code_name}":
target => $target,
content => $::osfamily ? {
target => $target,
content => $::osfamily ? {
'windows' => regsubst($content, '\n', "\r\n", 'EMG'),
default => $content,
},
order => $order,
notify => Class['::icinga2::service'],
order => $order,
notify => Class['::icinga2::service'],
}

}
20 changes: 9 additions & 11 deletions manifests/feature/api.pp
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@
$ssl_cacert = undef,
) {

include ::icinga2::params

$conf_dir = $::icinga2::params::conf_dir
$pki_dir = $::icinga2::params::pki_dir
$user = $::icinga2::params::user
Expand Down Expand Up @@ -215,12 +213,12 @@
'none': {
if $ssl_key {
file { $_ssl_key_path:
ensure => file,
mode => $::kernel ? {
ensure => file,
mode => $::kernel ? {
'windows' => undef,
default => '0600',
},
content => $::osfamily ? {
content => $::osfamily ? {
'windows' => regsubst($ssl_key, '\n', "\r\n", 'EMG'),
default => $ssl_key,
},
Expand All @@ -231,7 +229,7 @@
if $ssl_cert {
file { $_ssl_cert_path:
ensure => file,
content => $::osfamily ? {
content => $::osfamily ? {
'windows' => regsubst($ssl_cert, '\n', "\r\n", 'EMG'),
default => $ssl_cert,
},
Expand All @@ -242,7 +240,7 @@
if $ssl_cacert {
file { $_ssl_cacert_path:
ensure => file,
content => $::osfamily ? {
content => $::osfamily ? {
'windows' => regsubst($ssl_cacert, '\n', "\r\n", 'EMG'),
default => $ssl_cacert,
},
Expand All @@ -268,20 +266,20 @@
mode => '0600';
$_ssl_cert_path:
} ->

exec { 'icinga2 pki get trusted-cert':
command => "icinga2 pki save-cert --host '${ca_host}' --port ${ca_port} --key '${_ssl_key_path}' --cert '${_ssl_cert_path}' --trustedcert '${trusted_cert}'",
creates => $trusted_cert,
notify => Class['::icinga2::service'],
} ->
file { $trusted_cert: } ->

exec { 'icinga2 pki request':
command => "icinga2 pki request --host '${ca_host}' --port ${ca_port} --ca '${_ssl_cacert_path}' --key '${_ssl_key_path}' --cert '${_ssl_cert_path}' --trustedcert '${trusted_cert}' --ticket '${ticket_id}'",
creates => $_ssl_cacert_path,
notify => Class['::icinga2::service'],
} ->
file { $_ssl_cacert_path: }
file { $_ssl_cacert_path: }
} # icinga2
} # pki

Expand All @@ -300,7 +298,7 @@
create_resources('icinga2::object::zone', $zones)

# create object
icinga2::object { "icinga2::object::ApiListener::api":
icinga2::object { 'icinga2::object::ApiListener::api':
object_name => 'api',
object_type => 'ApiListener',
attrs => $attrs,
Expand Down
4 changes: 1 addition & 3 deletions manifests/feature/checker.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@
$ensure = present,
) {

include ::icinga2::params

$conf_dir = $::icinga2::params::conf_dir

# validation
validate_re($ensure, [ '^present$', '^absent$' ],
"${ensure} isn't supported. Valid values are 'present' and 'absent'.")

# create object
icinga2::object { "icinga2::object::CheckerComponent::checker":
icinga2::object { 'icinga2::object::CheckerComponent::checker':
object_name => 'checker',
object_type => 'CheckerComponent',
attrs => {},
Expand Down
6 changes: 4 additions & 2 deletions manifests/feature/command.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
class icinga2::feature::command(
$ensure = present,
$command_path = "${::icinga2::params::run_dir}/cmd/icinga2.cmd",
) inherits icinga2::params {
) {

$conf_dir = $::icinga2::params::conf_dir

validate_re($ensure, [ '^present$', '^absent$' ],
"${ensure} isn't supported. Valid values are 'present' and 'absent'.")
Expand All @@ -30,7 +32,7 @@
}

# create object
icinga2::object { "icinga2::object::ExternalCommandListener::command":
icinga2::object { 'icinga2::object::ExternalCommandListener::command':
object_name => 'command',
object_type => 'ExternalCommandListener',
attrs => $attrs,
Expand Down
6 changes: 4 additions & 2 deletions manifests/feature/compatlog.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
$ensure = present,
$log_dir = "${::icinga2::params::log_dir}/compat",
$rotation_method = 'DAILY',
) inherits icinga2::params {
) {

$conf_dir = $::icinga2::params::conf_dir

# validation
validate_re($ensure, [ '^present$', '^absent$' ],
Expand All @@ -38,7 +40,7 @@
}

# create object
icinga2::object { "icinga2::object::CompatLogger::compatlog":
icinga2::object { 'icinga2::object::CompatLogger::compatlog':
object_name => 'compatlog',
object_type => 'CompatLogger',
attrs => $attrs,
Expand Down
6 changes: 4 additions & 2 deletions manifests/feature/debuglog.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
class icinga2::feature::debuglog(
$ensure = present,
$path = "${::icinga2::params::log_dir}/debug.log",
) inherits icinga2::params {
) {

$conf_dir = $::icinga2::params::conf_dir

# validation
validate_re($ensure, [ '^present$', '^absent$' ],
Expand All @@ -33,7 +35,7 @@
}

# create object
icinga2::object { "icinga2::object::FileLogger::debuglog":
icinga2::object { 'icinga2::object::FileLogger::debuglog':
object_name => 'debug-file',
object_type => 'FileLogger',
attrs => $attrs,
Expand Down
4 changes: 1 addition & 3 deletions manifests/feature/gelf.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
$enable_send_perfdata = false,
) {

include ::icinga2::params

$conf_dir = $::icinga2::params::conf_dir

# validation
Expand All @@ -52,7 +50,7 @@
}

# create object
icinga2::object { "icinga2::object::GelfWriter::gelf":
icinga2::object { 'icinga2::object::GelfWriter::gelf':
object_name => 'gelf',
object_type => 'GelfWriter',
attrs => $attrs,
Expand Down
4 changes: 1 addition & 3 deletions manifests/feature/graphite.pp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
$enable_send_metadata = false,
) {

include ::icinga2::params

$conf_dir = $::icinga2::params::conf_dir

# validation
Expand All @@ -64,7 +62,7 @@
}

# create object
icinga2::object { "icinga2::object::GraphiteWriter::graphite":
icinga2::object { 'icinga2::object::GraphiteWriter::graphite':
object_name => 'graphite',
object_type => 'GraphiteWriter',
attrs => $attrs,
Expand Down
40 changes: 18 additions & 22 deletions manifests/feature/idomysql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,19 @@
$import_schema = false,
) {

include ::icinga2::params

require ::icinga2::config

$owner = $::icinga2::params::user
$group = $::icinga2::params::group
$node_name = $::icinga2::_constants['NodeName']
$conf_dir = $::icinga2::params::conf_dir
$ssl_dir = "${::icinga2::params::pki_dir}/ido-mysql"

File {
owner => $owner,
group => $group,
}

validate_re($ensure, [ '^present$', '^absent$' ],
"${ensure} isn't supported. Valid values are 'present' and 'absent'.")
validate_string($host)
Expand All @@ -178,19 +187,6 @@
if $ssl_capath { validate_absolute_path($ssl_capath) }
if $ssl_cipher { validate_string($ssl_cipher) }

$owner = $::icinga2::params::user
$group = $::icinga2::params::group
$node_name = $::icinga2::_constants['NodeName']

$conf_dir = $::icinga2::params::conf_dir

$ssl_dir = "${::icinga2::params::pki_dir}/ido-mysql"

File {
owner => $owner,
group => $group,
}

# Set defaults for certificate stuff and/or do validation
if $ssl_key_path {
validate_absolute_path($ssl_key_path)
Expand Down Expand Up @@ -250,12 +246,12 @@
'none': {
if $ssl_key {
file { $_ssl_key_path:
ensure => file,
mode => $::kernel ? {
ensure => file,
mode => $::kernel ? {
'windows' => undef,
default => '0600',
},
content => $::osfamily ? {
content => $::osfamily ? {
'windows' => regsubst($ssl_key, '\n', "\r\n", 'EMG'),
default => $ssl_key,
},
Expand All @@ -266,7 +262,7 @@
if $ssl_cert {
file { $_ssl_cert_path:
ensure => file,
content => $::osfamily ? {
content => $::osfamily ? {
'windows' => regsubst($ssl_cert, '\n', "\r\n", 'EMG'),
default => $ssl_cert,
},
Expand All @@ -277,7 +273,7 @@
if $ssl_cacert {
file { $_ssl_cacert_path:
ensure => file,
content => $::osfamily ? {
content => $::osfamily ? {
'windows' => regsubst($ssl_cacert, '\n', "\r\n", 'EMG'),
default => $ssl_cacert,
},
Expand Down Expand Up @@ -323,7 +319,7 @@
}

# create object
icinga2::object { "icinga2::object::IdoMysqlConnection::ido-mysql":
icinga2::object { 'icinga2::object::IdoMysqlConnection::ido-mysql':
object_name => 'ido-mysql',
object_type => 'IdoMysqlConnection',
attrs => merge($attrs, $attrs_ssl),
Expand All @@ -343,7 +339,7 @@
}

icinga2::feature { 'ido-mysql':
ensure => $ensure,
ensure => $ensure,
require => Package['icinga2-ido-mysql']
}
}
8 changes: 4 additions & 4 deletions manifests/feature/idopgsql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@

require ::icinga2::config

$conf_dir = $::icinga2::params::conf_dir

validate_re($ensure, [ '^present$', '^absent$' ],
"${ensure} isn't supported. Valid values are 'present' and 'absent'.")
validate_string($host)
Expand All @@ -108,8 +110,6 @@
if $categories { validate_array($categories) }
validate_bool($import_schema)

$conf_dir = $::icinga2::params::conf_dir

package { 'icinga2-ido-pgsql':
ensure => installed,
}
Expand Down Expand Up @@ -141,7 +141,7 @@
}

# create object
icinga2::object { "icinga2::object::IdoPgsqlConnection::ido-pgsql":
icinga2::object { 'icinga2::object::IdoPgsqlConnection::ido-pgsql':
object_name => 'ido-pgsql',
object_type => 'IdoPgsqlConnection',
attrs => $attrs,
Expand All @@ -161,7 +161,7 @@
}

icinga2::feature { 'ido-pgsql':
ensure => $ensure,
ensure => $ensure,
require => Package['icinga2-ido-pgsql']
}
}
Loading