Commit eef6a068 authored by Blerim Sheqa's avatar Blerim Sheqa

Merge branch 'testing'

parents 922c3310 8dd456a6
......@@ -16,20 +16,12 @@ script:
matrix:
fast_finish: true
include:
- rvm: 2.4.0-preview3
env: PUPPET_VERSION="~> 4.8" CHECK=spec
- rvm: 2.4.0-preview3
- rvm: 2.4.0
env: PUPPET_VERSION="~> 4.0" CHECK=spec
- rvm: 2.3.1
env: PUPPET_VERSION="~> 4.8" CHECK=spec
- rvm: 2.3.1
- rvm: 2.3.3
env: PUPPET_VERSION="~> 4.0" CHECK=spec
- rvm: 2.2.5
env: PUPPET_VERSION="~> 4.8" CHECK=spec
- rvm: 2.2.5
- rvm: 2.2.6
env: PUPPET_VERSION="~> 4.0" CHECK=spec
- rvm: 2.1.9
env: PUPPET_VERSION="~> 4.8" CHECK=spec
- rvm: 2.1.9
env: PUPPET_VERSION="~> 4.0" CHECK=spec
- rvm: 2.1.9
......@@ -41,11 +33,11 @@ matrix:
- rvm: 1.9.3
env: PUPPET_VERSION="~> 3.8" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" CHECK=spec
- rvm: 1.9.3
env: PUPPET_VERSION="~> 3.6" CHECK=spec
env: PUPPET_VERSION="~> 3.6.0" CHECK=spec
- rvm: 2.1.9
env: PUPPET_VERSION="~> 3.6" CHECK=spec
env: PUPPET_VERSION="~> 3.6.0" CHECK=spec
allow_failures:
- rvm: 2.4.0-preview3
- rvm: 2.4.0
notifications:
email: false
#deploy:
......
......@@ -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
......
......@@ -19,6 +19,15 @@ cd puppet-icinga2-rewrite
rake validate
```
## Puppet lint
With puppet-lint we test if our manifests conform to the recommended style guides from Puppet.
Run lint tests:
```
cd puppet-icinga2-rewrite
rake lint
```
## Unit tests
For unit testing we use [RSpec]. All classes, defined resource types and functions should have appropriate unit tests.
......@@ -66,6 +75,7 @@ rake spec:i2debian7puppet4
Since we don't want to violate any license of Microsoft, we are not making any Windows virtual box publicly available.
[README.md]: README.md
[puppet-lint]: http://puppet-lint.com/
[metadata.json]: metadata.json
[RSpec]: http://rspec-puppet.com/
[Serverspec]: http://serverspec.org/
......
......@@ -16,7 +16,7 @@
#
class icinga2::config {
if $module_name != $caller_module_name {
if defined($caller_module_name) and $module_name != $caller_module_name {
fail("icinga2::config is a private class of the module icinga2, you're not permitted to use it.")
}
......
......@@ -19,10 +19,10 @@
# Icinga Development Team <info@icinga.com>
#
define icinga2::config::fragment(
$code_name = $title,
$order = '0',
$content,
$target,
$code_name = $title,
$order = '0',
) {
include ::icinga2::params
......@@ -58,13 +58,13 @@ define icinga2::config::fragment(
}
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'],
}
}
......@@ -12,7 +12,7 @@ define icinga2::feature(
) {
require ::icinga2::config
if defined($caller_module_name) and $module_name != $caller_module_name {
if defined($caller_module_name) and $module_name != $caller_module_name and $caller_module_name != '' {
fail("icinga2::feature is a private define resource of the module icinga2, you're not permitted to use it.")
}
......
......@@ -140,8 +140,6 @@ class icinga2::feature::api(
$ssl_cacert = undef,
) {
include ::icinga2::params
$conf_dir = $::icinga2::params::conf_dir
$pki_dir = $::icinga2::params::pki_dir
$user = $::icinga2::params::user
......@@ -215,12 +213,12 @@ class icinga2::feature::api(
'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,
},
......@@ -231,7 +229,7 @@ class icinga2::feature::api(
if $ssl_cert {
file { $_ssl_cert_path:
ensure => file,
content => $::osfamily ? {
content => $::osfamily ? {
'windows' => regsubst($ssl_cert, '\n', "\r\n", 'EMG'),
default => $ssl_cert,
},
......@@ -242,7 +240,7 @@ class icinga2::feature::api(
if $ssl_cacert {
file { $_ssl_cacert_path:
ensure => file,
content => $::osfamily ? {
content => $::osfamily ? {
'windows' => regsubst($ssl_cacert, '\n', "\r\n", 'EMG'),
default => $ssl_cacert,
},
......@@ -268,20 +266,20 @@ class icinga2::feature::api(
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
......@@ -300,7 +298,7 @@ class icinga2::feature::api(
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,
......
......@@ -15,8 +15,6 @@ class icinga2::feature::checker(
$ensure = present,
) {
include ::icinga2::params
$conf_dir = $::icinga2::params::conf_dir
# validation
......@@ -24,7 +22,7 @@ class icinga2::feature::checker(
"${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 => {},
......
......@@ -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'.")
......@@ -30,7 +32,7 @@ class icinga2::feature::command(
}
# create object
icinga2::object { "icinga2::object::ExternalCommandListener::command":
icinga2::object { 'icinga2::object::ExternalCommandListener::command':
object_name => 'command',
object_type => 'ExternalCommandListener',
attrs => $attrs,
......
......@@ -23,7 +23,9 @@ class icinga2::feature::compatlog(
$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$' ],
......@@ -38,7 +40,7 @@ class icinga2::feature::compatlog(
}
# create object
icinga2::object { "icinga2::object::CompatLogger::compatlog":
icinga2::object { 'icinga2::object::CompatLogger::compatlog':
object_name => 'compatlog',
object_type => 'CompatLogger',
attrs => $attrs,
......
......@@ -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$' ],
......@@ -33,7 +35,7 @@ class icinga2::feature::debuglog(
}
# create object
icinga2::object { "icinga2::object::FileLogger::debuglog":
icinga2::object { 'icinga2::object::FileLogger::debuglog':
object_name => 'debug-file',
object_type => 'FileLogger',
attrs => $attrs,
......
......@@ -31,8 +31,6 @@ class icinga2::feature::gelf(
$enable_send_perfdata = false,
) {
include ::icinga2::params
$conf_dir = $::icinga2::params::conf_dir
# validation
......@@ -52,7 +50,7 @@ class icinga2::feature::gelf(
}
# create object
icinga2::object { "icinga2::object::GelfWriter::gelf":
icinga2::object { 'icinga2::object::GelfWriter::gelf':
object_name => 'gelf',
object_type => 'GelfWriter',
attrs => $attrs,
......
......@@ -39,8 +39,6 @@ class icinga2::feature::graphite(
$enable_send_metadata = false,
) {
include ::icinga2::params
$conf_dir = $::icinga2::params::conf_dir
# validation
......@@ -64,7 +62,7 @@ class icinga2::feature::graphite(
}
# create object
icinga2::object { "icinga2::object::GraphiteWriter::graphite":
icinga2::object { 'icinga2::object::GraphiteWriter::graphite':
object_name => 'graphite',
object_type => 'GraphiteWriter',
attrs => $attrs,
......
......@@ -152,10 +152,19 @@ class icinga2::feature::idomysql(
$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)
......@@ -178,19 +187,6 @@ class icinga2::feature::idomysql(
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)
......@@ -250,12 +246,12 @@ class icinga2::feature::idomysql(
'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,
},
......@@ -266,7 +262,7 @@ class icinga2::feature::idomysql(
if $ssl_cert {
file { $_ssl_cert_path:
ensure => file,
content => $::osfamily ? {
content => $::osfamily ? {
'windows' => regsubst($ssl_cert, '\n', "\r\n", 'EMG'),
default => $ssl_cert,
},
......@@ -277,7 +273,7 @@ class icinga2::feature::idomysql(
if $ssl_cacert {
file { $_ssl_cacert_path:
ensure => file,
content => $::osfamily ? {
content => $::osfamily ? {
'windows' => regsubst($ssl_cacert, '\n', "\r\n", 'EMG'),
default => $ssl_cacert,
},
......@@ -323,7 +319,7 @@ class icinga2::feature::idomysql(
}
# 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),
......@@ -343,7 +339,7 @@ class icinga2::feature::idomysql(
}
icinga2::feature { 'ido-mysql':
ensure => $ensure,
ensure => $ensure,
require => Package['icinga2-ido-mysql']
}
}
......@@ -92,6 +92,8 @@ class icinga2::feature::idopgsql(
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)
......@@ -108,8 +110,6 @@ class icinga2::feature::idopgsql(
if $categories { validate_array($categories) }
validate_bool($import_schema)
$conf_dir = $::icinga2::params::conf_dir
package { 'icinga2-ido-pgsql':
ensure => installed,
}
......@@ -141,7 +141,7 @@ class icinga2::feature::idopgsql(
}
# 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,
......@@ -161,7 +161,7 @@ class icinga2::feature::idopgsql(
}
icinga2::feature { 'ido-pgsql':
ensure => $ensure,
ensure => $ensure,
require => Package['icinga2-ido-pgsql']
}
}
......@@ -124,7 +124,16 @@ class icinga2::feature::influxdb(
$flush_threshold = 1024
) {
include ::icinga2::params
$user = $::icinga2::params::user
$group = $::icinga2::params::group
$node_name = $::icinga2::_constants['NodeName']
$conf_dir = $::icinga2::params::conf_dir
$ssl_dir = "${::icinga2::params::pki_dir}/influxdb"
File {
owner => $user,
group => $group,
}
validate_re($ensure, [ '^present$', '^absent$' ],
"${ensure} isn't supported. Valid values are 'present' and 'absent'.")
......@@ -145,19 +154,8 @@ class icinga2::feature::influxdb(
validate_re($flush_interval, '^\d+[ms]*$')
validate_integer($flush_threshold)
$user = $::icinga2::params::user
$group = $::icinga2::params::group
$node_name = $::icinga2::_constants['NodeName']
$conf_dir = $::icinga2::params::conf_dir
$ssl_dir = "${::icinga2::params::pki_dir}/influxdb"
$host_template = { measurement => "$host_measurement", tags => $host_tags }
$service_template = { measurement => "$service_measurement", tags => $service_tags}
File {
owner => $user,
group => $group,
}
$host_template = { measurement => "${host_measurement}", tags => $host_tags }
$service_template = { measurement => "${service_measurement}", tags => $service_tags}
# Set defaults for certificate stuff and/or do validation
if $ssl_key_path {
......@@ -216,12 +214,12 @@ class icinga2::feature::influxdb(
'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,
},
......@@ -232,7 +230,7 @@ class icinga2::feature::influxdb(
if $ssl_cert {
file { $_ssl_cert_path:
ensure => file,
content => $::osfamily ? {
content => $::osfamily ? {
'windows' => regsubst($ssl_cert, '\n', "\r\n", 'EMG'),
default => $ssl_cert,
},
......@@ -243,7 +241,7 @@ class icinga2::feature::influxdb(
if $ssl_cacert {
file { $_ssl_cacert_path:
ensure => file,
content => $::osfamily ? {
content => $::osfamily ? {
'windows' => regsubst($ssl_cacert, '\n', "\r\n", 'EMG'),
default => $ssl_cacert,
},
......@@ -272,7 +270,7 @@ class icinga2::feature::influxdb(
}
# create object
icinga2::object { "icinga2::object::InfluxdbWriter::influxdb":
icinga2::object { 'icinga2::object::InfluxdbWriter::influxdb':
object_name => 'influxdb',
object_type => 'InfluxdbWriter',
attrs => merge($attrs, $attrs_ssl),
......
......@@ -40,7 +40,9 @@ class icinga2::feature::livestatus(
$bind_port = '6558',
$socket_path = "${::icinga2::params::run_dir}/cmd/livestatus",
$compat_log_path = "${::icinga2::params::log_dir}/compat",
) inherits icinga2::params {
) {
$conf_dir = $::icinga2::params::conf_dir
# validation
validate_re($ensure, [ '^present$', '^absent$' ],
......@@ -62,7 +64,7 @@ class icinga2::feature::livestatus(
}
# create object
icinga2::object { "icinga2::object::LivestatusListener::livestatus":
icinga2::object { 'icinga2::object::LivestatusListener::livestatus':
object_name => 'livestatus',
object_type => 'LivestatusListener',
attrs => $attrs,
......
......@@ -22,7 +22,9 @@ class icinga2::feature::mainlog(
$ensure = present,
$severity = 'information',
$path = "${::icinga2::params::log_dir}/icinga2.log",
) inherits ::icinga2::params {
) {
$conf_dir = $::icinga2::params::conf_dir
# validation
validate_re($ensure, [ '^present$', '^absent$' ],
......@@ -37,7 +39,7 @@ class icinga2::feature::mainlog(
}
# create object
icinga2::object { "icinga2::object::FileLogger::mainlog":
icinga2::object { 'icinga2::object::FileLogger::mainlog':
object_name => 'main-log',
object_type => 'FileLogger',
attrs => $attrs,
......
......@@ -15,16 +15,14 @@ class icinga2::feature::notification(
$ensure = present,
) {
include ::icinga2::params
$conf_dir = $::icinga2::params::conf_dir
$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::NotificationComponent::notification":
icinga2::object { 'icinga2::object::NotificationComponent::notification':
object_name => 'notification',
object_type => 'NotificationComponent',
attrs => {},
......
......@@ -23,9 +23,7 @@ class icinga2::feature::opentsdb(
$port = '4242',
) {
include ::icinga2::params
$conf_dir = $::icinga2::params::conf_dir
$conf_dir = $::icinga2::params::conf_dir
# validation
validate_re($ensure, [ '^present$', '^absent$' ],
......@@ -40,7 +38,7 @@ class icinga2::feature::opentsdb(
}
# create object
icinga2::object { "icinga2::object::OpenTsdbWriter::opentsdb":
icinga2::object { 'icinga2::object::OpenTsdbWriter::opentsdb':
object_name => 'opentsdb',
object_type => 'OpenTsdbWriter',
attrs => $attrs,
......
......@@ -51,7 +51,9 @@ class icinga2::feature::perfdata(
$host_format_template = undef,
$service_format_template = undef,
$rotation_interval = '30s',
) inherits icinga2::params {
) {
$conf_dir = $::icinga2::params::conf_dir
# validation
validate_re($ensure, [ '^present$', '^absent$' ],
......@@ -79,7 +81,7 @@ class icinga2::feature::perfdata(
}
# create object
icinga2::object { "icinga2::object::PerfdataWriter::perfdata":
icinga2::object { 'icinga2::object::PerfdataWriter::perfdata':
object_name => 'perfdata',
object_type => 'PerfdataWriter',
attrs => $attrs,
......
......@@ -30,7 +30,9 @@ class icinga2::feature::statusdata(
$status_path = "${::icinga2::params::cache_dir}/status.dat",
$objects_path = "${::icinga2::params::cache_dir}/objects.cache",
$update_interval = '15s',
) inherits icinga2::params {
) {
$conf_dir = $::icinga2::params::conf_dir
# validation
validate_re($ensure, [ '^present$', '^absent$' ],
......@@ -47,7 +49,7 @@ class icinga2::feature::statusdata(
}
# create object
icinga2::object { "icinga2::object::StatusDataWriter::statusdata":
icinga2::object { 'icinga2::object::StatusDataWriter::statusdata':
object_name => 'statusdata',
object_type => 'StatusDataWriter',
attrs => $attrs,
......
......@@ -20,9 +20,7 @@ class icinga2::feature::syslog(
$severity = 'warning',
) {
include ::icinga2::params
$conf_dir = $::icinga2::params::conf_dir
$conf_dir = $::icinga2::params::conf_dir
# validation
validate_re($ensure, [ '^present$', '^absent$' ],
......@@ -35,7 +33,7 @@ class icinga2::feature::syslog(
}
# create object
icinga2::object { "icinga2::object::SyslogLogger::syslog":
icinga2::object { 'icinga2::object::SyslogLogger::syslog':
object_name => 'syslog',
object_type => 'SyslogLogger',
attrs => $attrs,
......
......@@ -148,7 +148,7 @@ class icinga2(
# validate confd, boolean or string
if is_bool($confd) {
if $confd { $_confd = "conf.d" } else { $_confd = undef }
if $confd { $_confd = 'conf.d' } else { $_confd = undef }
} elsif is_string($confd) {
$_confd = $confd
} else {
......