From 2f794b26daa85d110bfe3dc1896bb5efa0c530fb Mon Sep 17 00:00:00 2001 From: Alberto Lorenzo Date: Mon, 6 Aug 2018 13:12:58 +0100 Subject: [PATCH 1/5] Removing deprecated fields on apilistener resource --- LWRP.md | 3 --- libraries/resource_apilistener.rb | 29 +---------------------------- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/LWRP.md b/LWRP.md index f6318f6..96cf49a 100644 --- a/LWRP.md +++ b/LWRP.md @@ -1370,9 +1370,6 @@ LWRP `apilistener` creates an icinga `ApiListener` object. ```ruby icinga2_apilistener 'master' do - cert_path 'SysconfDir + "/icinga2/pki/" + NodeName + ".crt"' - key_path 'SysconfDir + "/icinga2/pki/" + NodeName + ".key"' - ca_path 'SysconfDir + "/icinga2/pki/ca.crt"' bind_host 'host address' bind_port '5665' ticket_salt 'TicketSalt' diff --git a/libraries/resource_apilistener.rb b/libraries/resource_apilistener.rb index 21026ba..d7ec810 100644 --- a/libraries/resource_apilistener.rb +++ b/libraries/resource_apilistener.rb @@ -23,33 +23,6 @@ def cookbook(arg = nil) ) end - def cert_path(arg = nil) - set_or_return( - :cert_path, arg, - :kind_of => String, - :required => true, - :default => nil - ) - end - - def key_path(arg = nil) - set_or_return( - :key_path, arg, - :kind_of => String, - :required => true, - :default => nil - ) - end - - def ca_path(arg = nil) - set_or_return( - :ca_path, arg, - :kind_of => String, - :required => true, - :default => nil - ) - end - def crl_path(arg = nil) set_or_return( :crl_path, arg, @@ -110,7 +83,7 @@ def resource_properties(arg = nil) set_or_return( :resource_properties, arg, :kind_of => Array, - :default => %w(cert_path key_path ca_path crl_path bind_host bind_port ticket_salt accept_config accept_commands) + :default => %w(crl_path bind_host bind_port ticket_salt accept_config accept_commands) ) end end From 91d85f0b45989815328452fbe2b1c5d39217a523 Mon Sep 17 00:00:00 2001 From: Alberto Lorenzo Date: Wed, 12 Sep 2018 10:09:40 +0100 Subject: [PATCH 2/5] Fixing things to CI converge --- .kitchen.dokken.yml | 2 + .kitchen.yml | 2 + CHANGELOG.md | 7 + README.md | 3 + attributes/default.rb | 5 + recipes/config.rb | 1 + recipes/install.rb | 7 + templates/default/icinga2.service.config.erb | 4 +- .../default/mail-host-notification.sh.erb | 179 ++++++++++++++++-- .../default/mail-service-notification.sh.erb | 179 ++++++++++++++++-- 10 files changed, 357 insertions(+), 32 deletions(-) diff --git a/.kitchen.dokken.yml b/.kitchen.dokken.yml index eae04aa..af5a8c9 100644 --- a/.kitchen.dokken.yml +++ b/.kitchen.dokken.yml @@ -102,6 +102,8 @@ suites: verifier: inspec_tests: - test/smoke/server + attributes: + install_monitoring_plugins: true run_list: - recipe[icinga2::default] - recipe[icinga2-test::default] diff --git a/.kitchen.yml b/.kitchen.yml index f13f9c0..7761903 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -1,6 +1,8 @@ --- driver: name: vagrant + customize: + audio: none verifier: name: inspec diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cc0616..e75a24e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ icinga2 CHANGELOG This file is used to list changes made in each version of the icinga2 cookbook. +- Alberto Lorenzo - Workaround for VBox 5.2.8+ `Stderr: VBoxManage: error: The specified string / bytes buffer was to small` https://github.com/hashicorp/vagrant/issues/9524 +- Alberto Lorenzo - Implement install monitoring plugins with boolean default['icinga2']['install_monitoring_plugins'] +- Alberto Lorenzo - Updated old notification scripts +- Alberto Lorenzo - Fix deprecated fields on apilistener +- Alberto Lorenzo - Fix service config file removing the `$` (https://github.com/Icinga/icinga2/issues/6434) + + 4.0.0 ----- diff --git a/README.md b/README.md index 72aa0cd..78ef4eb 100644 --- a/README.md +++ b/README.md @@ -355,10 +355,13 @@ See LWRP.md for icinga2 resources. + ## Cookbook Core Attributes * `default['icinga2']['version']` (default: `2.8.0-X, calculated`): icinga2 package version +* `default['icinga2']['install_monitoring_plugins']` (default: `false`): whether to install monitoring-plugins (install_monitoring_plugins) or not + * `default['icinga2']['setup_epel']` (default: `true`): if set includes cookbook recipe `yum-epel::default` for rhel and fedora platform_family * `default['icinga2']['cookbook']` (default: `icinga2`): icinga2 resources cookbook name diff --git a/attributes/default.rb b/attributes/default.rb index 46186b8..e8208c5 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -36,6 +36,9 @@ %w(itl plugins) end +# Install monitoring-plugins +default['icinga2']['install_monitoring_plugins'] = false + # includes yum-epel cookbook to setup yum epel repository default['icinga2']['setup_epel'] = true @@ -85,6 +88,7 @@ case node['platform_family'] when 'fedora', 'rhel', 'amazon' + default['icinga2']['monitoring_plugins_packages'] = [ 'nagios-plugins-all' ] default['icinga2']['user'] = 'icinga' default['icinga2']['group'] = 'icinga' default['icinga2']['cmdgroup'] = 'icingacmd' @@ -97,6 +101,7 @@ end when 'debian' + default['icinga2']['monitoring_plugins_packages'] = [ 'monitoring-plugins' ] default['icinga2']['user'] = 'nagios' default['icinga2']['group'] = 'nagios' default['icinga2']['cmdgroup'] = 'nagios' diff --git a/recipes/config.rb b/recipes/config.rb index 2af377a..8294e27 100644 --- a/recipes/config.rb +++ b/recipes/config.rb @@ -92,6 +92,7 @@ variables( :log_dir => node['icinga2']['log_dir'], :conf_dir => node['icinga2']['conf_dir'], + :run_dir => node['icinga2']['run_dir'], :user => node['icinga2']['user'], :group => node['icinga2']['group'], :cmdgroup => node['icinga2']['cmdgroup'] diff --git a/recipes/install.rb b/recipes/install.rb index 58a5499..19af8d6 100644 --- a/recipes/install.rb +++ b/recipes/install.rb @@ -55,6 +55,13 @@ action :install end +node['icinga2']['monitoring_plugins_packages'].each do |pkg| + package pkg do + action :install + only_if node['icinga2']['install_monitoring_plugins'] + end +end + package 'icinga2' do version node['icinga2']['version'] + node['icinga2']['version_suffix'] unless node['icinga2']['ignore_version'] notifies :restart, 'service[icinga2]', :delayed diff --git a/templates/default/icinga2.service.config.erb b/templates/default/icinga2.service.config.erb index 18ba719..c37ce35 100644 --- a/templates/default/icinga2.service.config.erb +++ b/templates/default/icinga2.service.config.erb @@ -4,9 +4,9 @@ # DAEMON=/usr/sbin/icinga2 ICINGA2_CONFIG_FILE=<%= @conf_dir -%>/icinga2.conf -ICINGA2_RUN_DIR=/var/run +ICINGA2_RUN_DIR=<%= @run_dir %> ICINGA2_STATE_DIR=/var -ICINGA2_PID_FILE=$ICINGA2_RUN_DIR/icinga2/icinga2.pid +ICINGA2_PID_FILE=<%= @run_dir %>/icinga2.pid ICINGA2_ERROR_LOG=<%= @log_dir -%>/error.log ICINGA2_STARTUP_LOG=<%= @log_dir -%>/startup.log ICINGA2_LOG=<%= @log_dir -%>/icinga2.log diff --git a/templates/default/mail-host-notification.sh.erb b/templates/default/mail-host-notification.sh.erb index 908d9ab..ffbeb5e 100644 --- a/templates/default/mail-host-notification.sh.erb +++ b/templates/default/mail-host-notification.sh.erb @@ -1,26 +1,175 @@ #!/usr/bin/env bash # -# Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/) -# +# Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/) +# Except of function urlencode which is Copyright (C) by Brian White (brian@aljex.com) used under MIT license + # This file is managed by Chef. # Do NOT modify this file directly. -# -template=$(cat <