From 42825bc3fecc526d836f4cbf8f7590a286454389 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Tue, 30 Sep 2014 19:36:24 +0200 Subject: [PATCH 01/65] check_mk::agent::install: fix install from system repository on debian. --- manifests/agent/install.pp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/manifests/agent/install.pp b/manifests/agent/install.pp index 1c8a429..9dc317b 100644 --- a/manifests/agent/install.pp +++ b/manifests/agent/install.pp @@ -41,12 +41,22 @@ } } else { + $check_mk_agent = $::osfamily ? { + 'Debian' => 'check-mk-agent', + default => 'check_mk-agent', + } + $check_mk_agent_logwatch = $::osfamily ? { + 'Debian' => 'check-mk-agent-logwatch', + default => 'check_mk-agent-logwatch', + } package { 'check_mk-agent': ensure => present, + name => $check_mk_agent, require => Package['xinetd'], } package { 'check_mk-agent-logwatch': ensure => present, + name => $check_mk_agent_logwatch, require => Package['check_mk-agent'], } } From df6788a5ad427e329de0b626a26843ec10ca3aee Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Wed, 1 Oct 2014 15:14:44 +0200 Subject: [PATCH 02/65] Fix all_hosts_static.erb template, avoid breaking if static_hosts is not an array (ie. undef). --- templates/all_hosts_static.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/all_hosts_static.erb b/templates/all_hosts_static.erb index 7ba0114..79689c1 100644 --- a/templates/all_hosts_static.erb +++ b/templates/all_hosts_static.erb @@ -1,4 +1,6 @@ <% static_hosts = scope.lookupvar('check_mk::config::all_hosts_static') -%> +<% if static_hosts.is_a? Array -%> <% static_hosts.each do |check_host| -%> '<%= host_name %>', <% end -%> +<% end -%> From 73043acd4c5e0ae3ba8d936bc8b014404782fa0d Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Wed, 16 Sep 2015 11:33:16 +0200 Subject: [PATCH 03/65] check_mk::agent::service: on debian wheezy xinetd init has no status option --- manifests/agent/service.pp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/manifests/agent/service.pp b/manifests/agent/service.pp index 0f70708..0d3ff04 100644 --- a/manifests/agent/service.pp +++ b/manifests/agent/service.pp @@ -1,8 +1,17 @@ class check_mk::agent::service { if ! defined(Service['xinetd']) { - service { 'xinetd': - ensure => 'running', - enable => true, + if $::operatingsystem == 'Debian' and + versioncmp($::operatingsystemmajrelease, '7') == 0 { + service { 'xinetd': + ensure => 'running', + enable => true, + hasstatus => false, + } + } else { + service { 'xinetd': + ensure => 'running', + enable => true, + } } } } From 6e9652d647c2e7d8e8ad26fff64d964c2c615731 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Tue, 17 Nov 2015 09:54:33 +0100 Subject: [PATCH 04/65] check_mk::config: use cron instead of exec with schedule to avoid skipped resource --- manifests/config.pp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 3d751cc..a029c0e 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -90,9 +90,11 @@ command => "/bin/su -l -c '${bin_dir}/check_mk -O' ${site}", refreshonly => true, } - # re-read inventory at least daily - exec { 'check_mk-refresh-inventory-daily': - command => "/bin/su -l -c '${bin_dir}/check_mk -O' ${site}", - schedule => 'daily', + # re-read inventory daily + cron { 'check_mk-refresh-inventory-dailudo': + user => 'root', + command => "sudo -i -u ${site} ${bin_dir}/check_mk -O", + minute => 0, + hour => 0, } } From b9a2b72871d296d8a581703851d8dc4e8e62c472 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Tue, 17 Nov 2015 10:47:04 +0100 Subject: [PATCH 05/65] README: document fork. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6e8b11f..4175066 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Puppet module for: Agent hostnames are automatically added to the server all_hosts configuration using stored configs. -Currently only tested on Redhat-like systems. +Original code by erwbgy, forked as upstream seems unmaintained. ## Server From 21a9caa5adceb1287147f2e1b01a083672955dbc Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Tue, 17 Nov 2015 10:47:37 +0100 Subject: [PATCH 06/65] gitignore: do not ignore metadata.json. --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index f6dc3f6..6ee20c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ pkg/ -metadata.json *.swp From 393ec773b80e3101c7a5092bd8bb49fd3936cf0a Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Tue, 17 Nov 2015 10:47:51 +0100 Subject: [PATCH 07/65] Import license and metadata.json --- LICENSE | 201 ++++++++++++++++++++++++++++++++++++++++++++++++++ metadata.json | 44 +++++++++++ 2 files changed, 245 insertions(+) create mode 100644 LICENSE create mode 100644 metadata.json diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ad410e1 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..a6702e9 --- /dev/null +++ b/metadata.json @@ -0,0 +1,44 @@ +{ + "name": "gnubilafrance-check_mk", + "version": "0.0.4", + "author": "Baptiste Grenier ", + "license": "Apache-2.0", + "summary": "Check_MK installation and configuration", + + "source": "https://github.com/gnubila-france/puppet-check_mk", + "project_page": "https://github.com/gnubila-france/puppet-check_mk", + "issues_url": "https://github.com/gnubila-france/puppet-check_mk/issues", + + "tags": [ "check_mk", "monitoring", "nagios" ], + + "operatingsystem_support": [ + { + "operatingsystem": "RedHat", + "operatingsystemrelease": [ + "5", + "6", + "7" + ] + }, + { + "operatingsystem": "CentOS", + "operatingsystemrelease": [ + "5", + "6", + "7" + ] + }, + { + "operatingsystem": "Debian", + "operatingsystemrelease": [ + "6", + "7" + ] + } + ], + + "dependencies": [ + { "name": "puppetlabs/concat", "version_requirement": ">= 1.0.0 <2.0.0" }, + { "name": "puppetlabs/stdlib", "version_requirement": ">= 2.3.0" } + ] +} From 2601b8cab3f8906477416766655ad4225a1bfecb Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Tue, 17 Nov 2015 10:48:08 +0100 Subject: [PATCH 08/65] Changelog: add entry for v0.4.0 --- Changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Changelog b/Changelog index 0b2f8a1..d9c7345 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,10 @@ +0.4.0: + +* Fix all_hosts_static.erb, update xinetd on wheezy and use cron instead of a +scheduled exec. + +* Package a new version has upstream seems unmaintained. + 0.3.0: * Added host tags to agent config so that host groups can be auto-populated From 0105ec0b361edf690e12d1b22bfec5d4de347fb3 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Tue, 17 Nov 2015 10:49:32 +0100 Subject: [PATCH 09/65] Drop deprecated Modulefile --- Modulefile | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 Modulefile diff --git a/Modulefile b/Modulefile deleted file mode 100644 index 60c355a..0000000 --- a/Modulefile +++ /dev/null @@ -1,10 +0,0 @@ -name 'erwbgy-check_mk' -version '0.3.0' -source 'https://github.com/erwbgy/puppet-check_mk.git' -author 'erwbgy' -license 'Apache License, Version 2.0' -summary 'install and configure check_mk' -description 'Install and configure check_mk agent and Nagios plugin' -project_page 'https://github.com/erwbgy/puppet-check_mk' -dependency 'puppetlabs/stdlib', '>= 2.6.0' -dependency 'ripienaar/concat', '>= 0.2.0' From 95648ac2ce077845fbd6a5ce89e6eb09cb4589db Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Tue, 17 Nov 2015 10:50:45 +0100 Subject: [PATCH 10/65] metadata.json: bump version --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index a6702e9..2223eed 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "gnubilafrance-check_mk", - "version": "0.0.4", + "version": "0.4.0", "author": "Baptiste Grenier ", "license": "Apache-2.0", "summary": "Check_MK installation and configuration", From 519ba4fa0394bffc00016b19fefda8c06274ac9b Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Tue, 17 Nov 2015 10:51:57 +0100 Subject: [PATCH 11/65] metadata.json: bump version --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 2223eed..298a12e 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "gnubilafrance-check_mk", - "version": "0.4.0", + "version": "0.5.0", "author": "Baptiste Grenier ", "license": "Apache-2.0", "summary": "Check_MK installation and configuration", From c33d1b696c4b1b715a69565061e9e0e339dc2fb3 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Wed, 18 Nov 2015 09:48:05 +0100 Subject: [PATCH 12/65] check_mk::config: sudo requires a tty, so use su. --- manifests/config.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/config.pp b/manifests/config.pp index b8b4718..32fc4b3 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -93,7 +93,7 @@ # re-read inventory daily cron { 'check_mk-refresh-inventory-daily': user => 'root', - command => "sudo -i -u ${site} ${bin_dir}/check_mk -O", + command => "su -l -c '${bin_dir}/check_mk -O' ${site}", minute => 0, hour => 0, } From b4fe28185be7d5d5263b62ca32f91ff90693ec67 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Fri, 20 Nov 2015 17:22:14 +0100 Subject: [PATCH 13/65] check_mk::host: almost initialize parameter --- manifests/host.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/host.pp b/manifests/host.pp index 4e8d146..a584e71 100644 --- a/manifests/host.pp +++ b/manifests/host.pp @@ -1,5 +1,5 @@ define check_mk::host ( - $target, + $target = undef, $host_tags = [], ) { $host = $title From 0cff0e4aa56ea6c6b2a772086757d5da91641349 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Fri, 20 Nov 2015 18:05:16 +0100 Subject: [PATCH 14/65] metadata.json: bump version --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 298a12e..830e0f7 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "gnubilafrance-check_mk", - "version": "0.5.0", + "version": "0.5.1", "author": "Baptiste Grenier ", "license": "Apache-2.0", "summary": "Check_MK installation and configuration", From 9b8f3f812c38d75d94b07652395bb8926b7071ff Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Wed, 25 Nov 2015 12:11:31 +0100 Subject: [PATCH 15/65] check_mk::agent: update agent package management. It is now possible to specify a custom package name. Logwatch check has been merged with main package. EPEL now provides packages with an updated name. --- manifests/agent.pp | 2 ++ manifests/agent/install.pp | 34 ++++++++-------------------------- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/manifests/agent.pp b/manifests/agent.pp index b53882a..2d467f7 100644 --- a/manifests/agent.pp +++ b/manifests/agent.pp @@ -8,11 +8,13 @@ $user = 'root', $version = undef, $workspace = '/root/check_mk', + $package = undef, ) { class { 'check_mk::agent::install': version => $version, filestore => $filestore, workspace => $workspace, + package => $package, } class { 'check_mk::agent::config': ip_whitelist => $ip_whitelist, diff --git a/manifests/agent/install.pp b/manifests/agent/install.pp index 9dc317b..536cbf3 100644 --- a/manifests/agent/install.pp +++ b/manifests/agent/install.pp @@ -2,6 +2,7 @@ $version, $filestore, $workspace, + $package, ) { if ! defined(Package['xinetd']) { package { 'xinetd': @@ -19,45 +20,26 @@ source => "${filestore}/check_mk-agent-${version}.noarch.rpm", require => Package['xinetd'], } - file { "${workspace}/check_mk-agent-logwatch-${version}.noarch.rpm": - ensure => present, - source => "${filestore}/check_mk-agent-logwatch-${version}.noarch.rpm", - require => Package['xinetd'], - } package { 'check_mk-agent': ensure => present, provider => 'rpm', source => "${workspace}/check_mk-agent-${version}.noarch.rpm", require => File["${workspace}/check_mk-agent-${version}.noarch.rpm"], } - package { 'check_mk-agent-logwatch': - ensure => present, - provider => 'rpm', - source => "${workspace}/check_mk-agent-logwatch-${version}.noarch.rpm", - require => [ - File["${workspace}/check_mk-agent-logwatch-${version}.noarch.rpm"], - Package['check_mk-agent'], - ], - } } else { - $check_mk_agent = $::osfamily ? { - 'Debian' => 'check-mk-agent', - default => 'check_mk-agent', - } - $check_mk_agent_logwatch = $::osfamily ? { - 'Debian' => 'check-mk-agent-logwatch', - default => 'check_mk-agent-logwatch', + $check_mk_agent = $package ? { + undef => $::osfamily ? { + 'Debian' => 'check-mk-agent', + 'RedHat' => 'check-mk-agent', + default => 'check_mk-agent', + }, + default => $package, } package { 'check_mk-agent': ensure => present, name => $check_mk_agent, require => Package['xinetd'], } - package { 'check_mk-agent-logwatch': - ensure => present, - name => $check_mk_agent_logwatch, - require => Package['check_mk-agent'], - } } } From 0d17b4025ea2b58c56b851d4efe436b73e137b0b Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Wed, 25 Nov 2015 12:18:30 +0100 Subject: [PATCH 16/65] check_mk::agent::config: remove dependency on check_mk-agent-logwatch package --- manifests/agent/config.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/agent/config.pp b/manifests/agent/config.pp index dc6808a..1144367 100644 --- a/manifests/agent/config.pp +++ b/manifests/agent/config.pp @@ -23,7 +23,7 @@ group => 'root', mode => '0444', content => template('check_mk/agent/check_mk.erb'), - require => Package['check_mk-agent','check_mk-agent-logwatch'], + require => Package['check_mk-agent'], notify => Class['check_mk::agent::service'], } } From 6ae555ada1415423a338e8af1c966d8191fac850 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Wed, 25 Nov 2015 12:20:36 +0100 Subject: [PATCH 17/65] README: remove logwatch-related doc. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4175066..bc02044 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ created making the URL http://hostname/acme/check_mk/ running as the 'acme' user ## Agent -* Installs the check_mk-agent and check_mk-agent-logwatch packages +* Installs the check_mk-agent package. * Configures the /etc/xinetd.d/check_mk configuration file @@ -80,7 +80,7 @@ created making the URL http://hostname/acme/check_mk/ running as the 'acme' user include check_mk::agent -Installs the check_mk and check_mk_logwatch packages from the system repository +Installs the check_mk package from the system repository and configures /etc/xinetd.d/check_mk with no IP whitelist restrictions. ### Example 2 @@ -90,7 +90,7 @@ and configures /etc/xinetd.d/check_mk with no IP whitelist restrictions. ip_whitelist => [ '10.7.96.21', '10.7.96.22' ], } -Installs the specified versions of the check_mk and check_mk_logwatch packages +Installs the specified versions of the check_mk package after retrieving them from the Puppet file store. Configures /etc/xinetd.d/check_mk so that only the specified IPs (and localhost/127.0.0.1) are allowed to connect. From 08b903b314f39e61e3de249bc46481e08da3d22b Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Wed, 25 Nov 2015 12:21:00 +0100 Subject: [PATCH 18/65] example.yaml: drop non existing code conf... --- example.yaml | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/example.yaml b/example.yaml index de82ecc..b7280d0 100644 --- a/example.yaml +++ b/example.yaml @@ -69,25 +69,3 @@ check_mk::agent::host_tags: - '%{kernel}' - '%{role}' - '%{location}' - -check_mk::agent::jolokia::server: '127.0.0.1' -check_mk::agent::jolokia::port: '8080' -check_mk::agent::jolokia::user: 'monitoring' -check_mk::agent::jolokia::password: 'tinstaafl' -check_mk::agent::jolokia::suburi: 'jolokia' - -check_mk::agent::jolokia::instances: - 'My-App': - server: '10.0.0.1' - port: '8190' - -check_mk::agent::logwatch::keep_defaults: 'true' -check_mk::agent::logwatch::logfiles: - '/apps/tomcat1/logs/tomcat/catalina.*.log': - critical: - - '^SERVERE:' - - '^ERROR:' - warning: - - '^WARNING:' - ignore: - - '^INFO' From 20eed33bb25512dec358d5bf6d82e898735105a3 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Wed, 25 Nov 2015 12:27:56 +0100 Subject: [PATCH 19/65] check_mk::agent::config: document class, fix style. --- manifests/agent/config.pp | 46 +++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/manifests/agent/config.pp b/manifests/agent/config.pp index 1144367..29f35f5 100644 --- a/manifests/agent/config.pp +++ b/manifests/agent/config.pp @@ -1,22 +1,48 @@ +# == Class: check_mk::agent::config +# +# Configure check_mk agent. +# +# === Parameters +# +# [*ip_whitelist*] +# Array of IP allowed to access the check_mk agent. +# Default: undef +# +# [*port*] +# Check_mk port +# Default: undef +# +# [*server_dir*] +# Check_mk server directory. +# Default: undef +# +# [*use_cache*] +# Enable cache. +# Default: undef +# +# [*user*] +# Check_mk user. +# Default: undef +# class check_mk::agent::config ( - $ip_whitelist, - $port, - $server_dir, - $use_cache, - $user, + $ip_whitelist = undef, + $port = undef, + $server_dir = undef, + $use_cache = undef, + $user = undef, ) { if $use_cache { $server = "${server_dir}/check_mk_caching_agent" - } - else { + } else { $server = "${server_dir}/check_mk_agent" } + if $ip_whitelist { $only_from = join($ip_whitelist, ' ') - } - else { + } else { $only_from = undef } + file { '/etc/xinetd.d/check_mk': ensure => present, owner => 'root', @@ -27,3 +53,5 @@ notify => Class['check_mk::agent::service'], } } + +# vim: set et sta sw=2 ts=2 sts=2 noci noai:a From 78aebf9c8b9edc350562322626ffa375af8799d2 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Wed, 25 Nov 2015 15:45:55 +0100 Subject: [PATCH 20/65] metadata.json: bump version --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 830e0f7..2b8240e 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "gnubilafrance-check_mk", - "version": "0.5.1", + "version": "0.6.0", "author": "Baptiste Grenier ", "license": "Apache-2.0", "summary": "Check_MK installation and configuration", From dae41995426c5d4f02f2a3ba13aa080f256cbf0d Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Fri, 27 Nov 2015 09:42:40 +0100 Subject: [PATCH 21/65] check_mk::agent::config: on RHEL xinetd conf file is packaged elsewhere now. --- manifests/agent/config.pp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/manifests/agent/config.pp b/manifests/agent/config.pp index 29f35f5..1c06f7f 100644 --- a/manifests/agent/config.pp +++ b/manifests/agent/config.pp @@ -43,7 +43,12 @@ $only_from = undef } - file { '/etc/xinetd.d/check_mk': + $xinetd_file = $::osfamily ? { + 'RedHat' => '/etc/xinetd.d/check-mk-agent', + default => '/etc/xinetd.d/check_mk', + } + + file { $xinetd_file: ensure => present, owner => 'root', group => 'root', From 2c81ed4c8dc6107f16860ea29e1f10ed8d8f5589 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Fri, 27 Nov 2015 10:05:01 +0100 Subject: [PATCH 22/65] check_mk::agent::config: delete xinetd file from previous package on RHEL. --- manifests/agent/config.pp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/manifests/agent/config.pp b/manifests/agent/config.pp index 1c06f7f..5d4ddeb 100644 --- a/manifests/agent/config.pp +++ b/manifests/agent/config.pp @@ -49,7 +49,7 @@ } file { $xinetd_file: - ensure => present, + ensure => 'file', owner => 'root', group => 'root', mode => '0444', @@ -57,6 +57,13 @@ require => Package['check_mk-agent'], notify => Class['check_mk::agent::service'], } + + # Delete file from older check_mk package version + if $::osfamily == 'RedHat' { + file { '/etc/xinetd.d/check_mk': + ensure => 'absent', + } + } } # vim: set et sta sw=2 ts=2 sts=2 noci noai:a From 34cefee63200b72fe06b7a50cfcdc554e5a354a1 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Fri, 27 Nov 2015 14:42:26 +0100 Subject: [PATCH 23/65] metadata.json: bump version --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 2b8240e..3d832cc 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "gnubilafrance-check_mk", - "version": "0.6.0", + "version": "0.6.1", "author": "Baptiste Grenier ", "license": "Apache-2.0", "summary": "Check_MK installation and configuration", From 8c6294c76936fac088201eb5c01bd4ac98f10754 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Fri, 11 Dec 2015 11:27:21 +0100 Subject: [PATCH 24/65] Enable travis tests --- .travis.yml | 30 ++++++++++++++++++++++++++++++ Gemfile | 4 ++++ README.md | 3 +++ 3 files changed, 37 insertions(+) create mode 100644 .travis.yml create mode 100644 Gemfile diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..808039f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,30 @@ +--- +language: ruby +sudo: false +rvm: + - 1.8.7 + - 1.9.3 + - 2.0 + - 2.1 + - 2.2 +notifications: + email: false +env: + - PUPPET_GEM_VERSION="~> 3.7.0" + - PUPPET_GEM_VERSION="~> 3.8.0" + - PUPPET_GEM_VERSION="~> 4.1.0" + - PUPPET_GEM_VERSION="~> 4.2.0" +script: + - puppet --version + - puppet-lint --no-80chars-check --relative . + - find . -name *.pp | xargs puppet parser validate +matrix: + exclude: + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 4.1.0" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 4.2.0" + - rvm: 2.2 + env: PUPPET_GEM_VERSION="~> 3.7.0" + - rvm: 2.2 + env: PUPPET_GEM_VERSION="~> 3.8.0" diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..3d28825 --- /dev/null +++ b/Gemfile @@ -0,0 +1,4 @@ +source "https://rubygems.org" + +gem 'puppet-lint' +gem 'puppet', ENV['PUPPET_GEM_VERSION'] || '~> 3.8.0' diff --git a/README.md b/README.md index bc02044..2b8b51e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # check_mk +[![Puppet Forge](http://img.shields.io/puppetforge/v/gnubilafrance/check_mk.svg)](https://forge.puppetlabs.com/gnubilafrance/check_mk) +[![Build Status](https://travis-ci.org/gnubila-france/puppet-check_mk.png?branch=master)](https://travis-ci.org/gnubila-france/puppet-check_mk) + Puppet module for: * Installing and configuring the Open Monitoring Distribution (OMD) which From d865e43fa4d7a2033ec6ec9053d9a3286d65091a Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Fri, 29 May 2015 10:48:31 +0200 Subject: [PATCH 25/65] Add rspec-test basics --- .fixtures.yml | 6 ++++++ .rspec | 3 +++ Gemfile | 19 ++++++++++++++++--- Rakefile | 5 +++++ spec/classes/check_mk_spec.rb | 7 +++++++ spec/spec_helper.rb | 1 + 6 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 .fixtures.yml create mode 100644 .rspec create mode 100644 spec/classes/check_mk_spec.rb create mode 100644 spec/spec_helper.rb diff --git a/.fixtures.yml b/.fixtures.yml new file mode 100644 index 0000000..76f4e25 --- /dev/null +++ b/.fixtures.yml @@ -0,0 +1,6 @@ +fixtures: + repositories: + stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git" + concat: "https://github.com/puppetlabs/puppetlabs-concat.git" + symlinks: + check_mk: "#{source_dir}" diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..0357065 --- /dev/null +++ b/.rspec @@ -0,0 +1,3 @@ +--color +--format documentation +progress diff --git a/Gemfile b/Gemfile index 3d28825..88f98ad 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,17 @@ -source "https://rubygems.org" +source ENV['GEM_SOURCE'] || "https://rubygems.org" -gem 'puppet-lint' -gem 'puppet', ENV['PUPPET_GEM_VERSION'] || '~> 3.8.0' +group :development, :unit_tests do + gem 'rake', :require => false + gem 'rspec-puppet', :require => false + gem 'puppetlabs_spec_helper', :require => false + gem 'puppet-lint', :require => false + gem 'metadata-json-lint', :require => false +end + +if puppetversion = ENV['PUPPET_GEM_VERSION'] + gem 'puppet', puppetversion, :require => false +else + gem 'puppet', :require => false +end + +# vim:ft=ruby diff --git a/Rakefile b/Rakefile index 14f1c24..aa2d928 100644 --- a/Rakefile +++ b/Rakefile @@ -1,2 +1,7 @@ require 'rubygems' require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet-lint/tasks/puppet-lint' + +PuppetLint.configuration.fail_on_warnings +PuppetLint.configuration.send('disable_80chars') +PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] diff --git a/spec/classes/check_mk_spec.rb b/spec/classes/check_mk_spec.rb new file mode 100644 index 0000000..4c9e4e2 --- /dev/null +++ b/spec/classes/check_mk_spec.rb @@ -0,0 +1,7 @@ +require 'spec_helper' +describe 'check_mk', :type => :class do + + context 'with defaults for all parameters' do + it { should contain_class('check_mk') } + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..2c6f566 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1 @@ +require 'puppetlabs_spec_helper/module_spec_helper' From 7460f383834601b8aee942c5f6002c68a6f52c55 Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Thu, 25 Feb 2016 16:55:42 +0100 Subject: [PATCH 26/65] Use rspec version prior to 3.2.0 for ruby 1.8.7 This is done to cope with regression on ruby with rspec-core 3.2.0: https://github.com/rspec/rspec-core/issues/1864 --- .travis.yml | 8 ++++---- Gemfile | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 808039f..59437c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: ruby sudo: false rvm: - - 1.8.7 - 1.9.3 - 2.0 - 2.1 @@ -19,11 +18,12 @@ script: - puppet-lint --no-80chars-check --relative . - find . -name *.pp | xargs puppet parser validate matrix: - exclude: + include: - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 4.1.0" + env: PUPPET_GEM_VERSION="~> 3.7.0" RSPEC_GEM_VERSION="< 3.2.0" - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 4.2.0" + env: PUPPET_GEM_VERSION="~> 3.8.0" RSPEC_GEM_VERSION="< 3.2.0" + exclude: - rvm: 2.2 env: PUPPET_GEM_VERSION="~> 3.7.0" - rvm: 2.2 diff --git a/Gemfile b/Gemfile index 88f98ad..40339a9 100644 --- a/Gemfile +++ b/Gemfile @@ -14,4 +14,10 @@ else gem 'puppet', :require => false end +if rspecpuppetversion = ENV['RSPEC_GEM_VERSION'] + gem 'rspec', rspecpuppetversion, :require => false +else + gem 'rspec', :require => false +end + # vim:ft=ruby From 7944869a97e5113c91896683c707e1692814a53d Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Thu, 25 Feb 2016 16:04:44 +0100 Subject: [PATCH 27/65] Validate, lint-checks and execute rspec-tests via Travis --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 59437c4..ad552c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,8 +15,7 @@ env: - PUPPET_GEM_VERSION="~> 4.2.0" script: - puppet --version - - puppet-lint --no-80chars-check --relative . - - find . -name *.pp | xargs puppet parser validate + - bundle exec rake validate lint spec matrix: include: - rvm: 1.8.7 From 2974e180b0054f49854eb15d282c3b5860356629 Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Wed, 3 Jun 2015 10:29:16 +0200 Subject: [PATCH 28/65] Fix lint-warnings --- manifests/config.pp | 21 +++++++++++---------- manifests/install_tarball.pp | 12 ++++++------ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 32fc4b3..957cb89 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -1,3 +1,4 @@ + class check_mk::config ( $site, $host_groups = undef, @@ -47,9 +48,9 @@ } # local list of hosts is in /omd/sites/${site}/etc/check_mk/all_hosts_static and is appended concat::fragment { 'all-hosts-static': - ensure => "${etc_dir}/check_mk/all_hosts_static", - target => "${etc_dir}/check_mk/main.mk", - order => 18, + ensure => "${etc_dir}/check_mk/all_hosts_static", + target => "${etc_dir}/check_mk/main.mk", + order => 18, } # host_groups if $host_groups { @@ -68,17 +69,17 @@ } $groups = keys($host_groups) check_mk::hostgroup { $groups: - dir => "${etc_dir}/nagios/local/hostgroups", - hostgroups => $host_groups, - target => "${etc_dir}/check_mk/main.mk", - notify => Exec['check_mk-refresh'] + dir => "${etc_dir}/nagios/local/hostgroups", + hostgroups => $host_groups, + target => "${etc_dir}/check_mk/main.mk", + notify => Exec['check_mk-refresh'] } } # local config is in /omd/sites/${site}/etc/check_mk/main.mk.local and is appended concat::fragment { 'check_mk-local-config': - ensure => "${etc_dir}/check_mk/main.mk.local", - target => "${etc_dir}/check_mk/main.mk", - order => 99, + ensure => "${etc_dir}/check_mk/main.mk.local", + target => "${etc_dir}/check_mk/main.mk", + order => 99, } # re-read config if it changes exec { 'check_mk-refresh': diff --git a/manifests/install_tarball.pp b/manifests/install_tarball.pp index 4a0af23..f09e770 100644 --- a/manifests/install_tarball.pp +++ b/manifests/install_tarball.pp @@ -35,14 +35,14 @@ ensure => present, } file { "${workspace}/check_mk-${version}.tar.gz": - ensure => present, - source => "${filestore}/check_mk-${version}.tar.gz", + ensure => present, + source => "${filestore}/check_mk-${version}.tar.gz", } exec { 'unpack-check_mk-tarball': - command => "/bin/tar -zxf ${workspace}/check_mk-${version}.tar.gz", - cwd => $workspace, - creates => "${workspace}/check_mk-${version}", - require => File["${workspace}/check_mk-${version}.tar.gz"], + command => "/bin/tar -zxf ${workspace}/check_mk-${version}.tar.gz", + cwd => $workspace, + creates => "${workspace}/check_mk-${version}", + require => File["${workspace}/check_mk-${version}.tar.gz"], } exec { 'change-setup-config-location': command => "/usr/bin/perl -pi -e 's#^SETUPCONF=.*?$#SETUPCONF=${workspace}/check_mk_setup.conf#' ${workspace}/check_mk-${version}/setup.sh", From bfce33b48b4edae15bdd90338fc42514db5feb53 Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Fri, 26 Feb 2016 10:40:33 +0100 Subject: [PATCH 29/65] Generate coverage reports at exit --- spec/classes/coverage_spec.rb | 1 + 1 file changed, 1 insertion(+) create mode 100644 spec/classes/coverage_spec.rb diff --git a/spec/classes/coverage_spec.rb b/spec/classes/coverage_spec.rb new file mode 100644 index 0000000..12513b8 --- /dev/null +++ b/spec/classes/coverage_spec.rb @@ -0,0 +1 @@ +at_exit { RSpec::Puppet::Coverage.report! } From 0300c8c5f136c067c96cd20ac67597cf1642e466 Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Mon, 1 Jun 2015 09:43:44 +0200 Subject: [PATCH 30/65] Add test-cases for class check_mk --- spec/classes/check_mk_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/classes/check_mk_spec.rb b/spec/classes/check_mk_spec.rb index 4c9e4e2..169438f 100644 --- a/spec/classes/check_mk_spec.rb +++ b/spec/classes/check_mk_spec.rb @@ -3,5 +3,16 @@ context 'with defaults for all parameters' do it { should contain_class('check_mk') } + it { should contain_class('check_mk::install').with({ + :filestore => nil, + :package => 'omd-0.56', + :site => 'monitoring', + :workspace => '/root/check_mk', + }).that_comes_before('Class[check_mk::config]') } + it { should contain_class('check_mk::config').with({ + :host_groups => nil, + :site => 'monitoring', + }).that_comes_before('Class[check_mk::service]') } + it { should contain_class('check_mk::service') } end end From 4827d592dbd8a531c053598fd60676993f250d3f Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Mon, 1 Jun 2015 09:52:40 +0200 Subject: [PATCH 31/65] Add test for check_mk::install --- spec/classes/check_mk_install_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 spec/classes/check_mk_install_spec.rb diff --git a/spec/classes/check_mk_install_spec.rb b/spec/classes/check_mk_install_spec.rb new file mode 100644 index 0000000..9cf0b09 --- /dev/null +++ b/spec/classes/check_mk_install_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper' +describe 'check_mk::install', :type => :class do + context 'with necessary parameters set' do + let :params do + { + :filestore => false, + :package => 'package', + :site => 'site', + :workspace => 'workspace', + } + end + it { should contain_class('check_mk::install') } + it { should contain_package('package').with_ensure('installed').that_comes_before('Exec[omd-create-site]') } + it { should contain_exec('omd-create-site').with({ + :command => '/usr/bin/omd create site', + :creates => '/omd/sites/site/etc', + }) + } + end +end From e160d40fc36f840f8422dc5cd5880cae3c29ce6c Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Fri, 26 Feb 2016 10:44:37 +0100 Subject: [PATCH 32/65] Add test for check_mk::install_tarball --- spec/classes/check_mk_install_tarball_spec.rb | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 spec/classes/check_mk_install_tarball_spec.rb diff --git a/spec/classes/check_mk_install_tarball_spec.rb b/spec/classes/check_mk_install_tarball_spec.rb new file mode 100644 index 0000000..7537d85 --- /dev/null +++ b/spec/classes/check_mk_install_tarball_spec.rb @@ -0,0 +1,102 @@ +require 'spec_helper' +describe 'check_mk::install_tarball', :type => :class do + context 'with necessary parameters set' do + let :params do + { + :filestore => '/filestore', + :version => '1.2.3', + :workspace => '/workspace', + } + end + it { should contain_class('check_mk::install_tarball') } + it { should contain_package('nagios').with_ensure('present').that_comes_before('Package[nagios-plugins-all]') } + installed_packages = [ + 'xinetd', + 'mod_python', + 'make', + 'gcc-c++', + 'tar', + 'gzip' + ] + installed_packages.each do |package| + it { should contain_package(package).with_ensure('present') } + end + it { should contain_file('/etc/nagios/passwd').with({ + :ensure => 'present', + :owner => 'root', + :group => 'apache', + :mode => '0640', + }) + } + it { should contain_exec('set-nagiosadmin-password').with({ + :refreshonly => true, + :require => 'File[/etc/nagios/passwd]', + }) + } + it { should contain_exec('set-guest-password').with({ + :refreshonly => true, + :require => 'File[/etc/nagios/passwd]', + }) + } + it { should contain_exec('add-apache-to-nagios-group').with({ + :refreshonly => true, + }) + } + it { should contain_package('nagios-plugins-all').with({ + :ensure => 'present', + :require => 'Package[nagios]', + }) + } + it { should contain_exec('unpack-check_mk-tarball').with({ + :command => '/bin/tar -zxf /workspace/check_mk-1.2.3.tar.gz', + :cwd => '/workspace', + :creates => '/workspace/check_mk-1.2.3', + :require => 'File[/workspace/check_mk-1.2.3.tar.gz]', + }) + } + it { should contain_exec('change-setup-config-location').with({ + :command => "/usr/bin/perl -pi -e 's#^SETUPCONF=.*?$#SETUPCONF=/workspace/check_mk_setup.conf#' /workspace/check_mk-1.2.3/setup.sh", + :unless => "/bin/egrep '^SETUPCONF=/workspace/check_mk_setup.conf$' /workspace/check_mk-1.2.3/setup.sh", + :require => 'Exec[unpack-check_mk-tarball]', + }) + } + it { should contain_exec('remove-setup-header').with({ + :command => "/usr/bin/perl -pi -e 's#^DIRINFO=.*?$#DIRINFO=#' /workspace/check_mk-1.2.3/setup.sh", + :unless => "/bin/egrep '^DIRINFO=$' /workspace/check_mk-1.2.3/setup.sh", + :require => 'Exec[unpack-check_mk-tarball]', + }) + } + it { should contain_file('/workspace/check_mk_setup.conf').that_notifies('Exec[check_mk-setup]') } + it { should contain_file('/etc/nagios/check_mk').with({ + :ensure => 'directory', + :owner => 'nagios', + :group => 'nagios', + :recurse => true, + :require => 'Package[nagios]', + }) + } + it { should contain_file('/etc/nagios/check_mk/hostgroups').with({ + :ensure => 'directory', + :owner => 'nagios', + :group => 'nagios', + :require => 'File[/etc/nagios/check_mk]', + }) + } + it { should contain_exec('check_mk-setup').with({ + :command => '/workspace/check_mk-1.2.3/setup.sh --yes', + :cwd => '/workspace/check_mk-1.2.3', + :refreshonly => true, + :require => [ + 'Exec[change-setup-config-location]', + 'Exec[remove-setup-header]', + 'Exec[unpack-check_mk-tarball]', + 'File[/workspace/check_mk_setup.conf]', + 'File[/etc/nagios/check_mk]', + 'Package[nagios]', + ], + :notify => 'Class[Check_mk::Service]', + }) + } + + end +end From ea024c9fa0b89ca39b09939c692e0b5b969facd6 Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Mon, 1 Jun 2015 12:53:49 +0200 Subject: [PATCH 33/65] Add test for check_mk::config --- spec/classes/check_mk_config_spec.rb | 124 +++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 spec/classes/check_mk_config_spec.rb diff --git a/spec/classes/check_mk_config_spec.rb b/spec/classes/check_mk_config_spec.rb new file mode 100644 index 0000000..9de298b --- /dev/null +++ b/spec/classes/check_mk_config_spec.rb @@ -0,0 +1,124 @@ +require 'spec_helper' +describe 'check_mk::config', :type => :class do + context 'with site set' do + let :params do + { + :site => 'TEST_SITE' + } + end + it { should contain_class('check_mk::config') } + it { should contain_file('/omd/sites/TEST_SITE/etc/nagios/local').with_ensure_directory. + that_comes_before('File_line[nagios-add-check_mk-cfg_dir]') + } + it { should contain_file_line('nagios-add-check_mk-cfg_dir').with({ + :ensure => 'present', + :line => 'cfg_dir=/omd/sites/TEST_SITE/etc/nagios/local', + :path => '/omd/sites/TEST_SITE/etc/nagios/nagios.cfg', + :notify => 'Class[Check_mk::Service]', + }) + } + it { should contain_file_line('add-guest-users').with({ + :ensure => 'present', + :line => 'guest_users = [ "guest" ]', + :path => '/omd/sites/TEST_SITE/etc/check_mk/multisite.mk', + }) + } + it { should contain_file('/omd/sites/TEST_SITE/etc/check_mk/all_hosts_static').with({ + :ensure => 'file', + :content => '', + }) + } + it { should contain_concat('/omd/sites/TEST_SITE/etc/check_mk/main.mk').with({ + :owner => 'root', + :group => 'root', + :mode => '0644', + :notify => 'Exec[check_mk-refresh]', + }) + } + it { should contain_concat__fragment('all_hosts-header').with({ + :target => '/omd/sites/TEST_SITE/etc/check_mk/main.mk', + :content => /all_hosts = \[\n/, + :order => 10, + }) + } + it { should contain_concat__fragment('all_hosts-footer').with({ + :target => '/omd/sites/TEST_SITE/etc/check_mk/main.mk', + :content => /\]\n/, + :order => 19, + }) + } + it { should contain_concat__fragment('all-hosts-static').with({ + :ensure => '/omd/sites/TEST_SITE/etc/check_mk/all_hosts_static', + :target => '/omd/sites/TEST_SITE/etc/check_mk/main.mk', + :order => 18, + }) + } + it { should_not contain_file('/omd/sites/TEST_SITE/etc/nagios/local/hostgroups') } + it { should_not contain_concat__fragment('host_groups-header') } + it { should_not contain_concat__fragment('host_groups-footer') } + it { should_not contain_check_mk__hostgroup } + it { should contain_concat__fragment('check_mk-local-config').with({ + :ensure => '/omd/sites/TEST_SITE/etc/check_mk/main.mk.local', + :target => '/omd/sites/TEST_SITE/etc/check_mk/main.mk', + :order => 99, + }) + } + it { should contain_exec('check_mk-refresh').with({ + :command => /\/bin\/su -l -c '\/omd\/sites\/TEST_SITE\/bin\/check_mk -I' TEST_SITE/, + :refreshonly => true, + }) + } + it { should contain_exec('check_mk-reload').with({ + :command => /\/bin\/su -l -c '\/omd\/sites\/TEST_SITE\/bin\/check_mk -O' TEST_SITE/, + :refreshonly => true, + }) + } + it { should contain_cron('check_mk-refresh-inventory-daily').with({ + :user => 'root', + :command => /su -l -c '\/omd\/sites\/TEST_SITE\/bin\/check_mk -O' TEST_SITE/, + :minute => 0, + :hour => 0, + }) + } + end + context 'with host_groups' do + host_groups = { + 'group1' => {'host_tags' => []}, + 'group2' => {'host_tags' => []}, + } + let :params do + { + :site => 'TEST_SITE', + :host_groups => host_groups, + } + end + it { should contain_class('check_mk::config') } + it { should contain_file('/omd/sites/TEST_SITE/etc/nagios/local/hostgroups').with_ensure_directory } + it { should contain_concat__fragment('host_groups-header').with({ + :target => '/omd/sites/TEST_SITE/etc/check_mk/main.mk', + :content => /host_groups = \[\n/, + :order => 20, + }) + } + it { should contain_concat__fragment('host_groups-footer').with({ + :target => '/omd/sites/TEST_SITE/etc/check_mk/main.mk', + :content => /\]\n/, + :order => 29, + }) + } + it { should contain_check_mk__hostgroup('group1').with({ + :dir => '/omd/sites/TEST_SITE/etc/nagios/local/hostgroups', + :hostgroups => host_groups, + :target => '/omd/sites/TEST_SITE/etc/check_mk/main.mk', + :notify => 'Exec[check_mk-refresh]', + }) + } + it { should contain_check_mk__hostgroup('group2').with({ + :dir => '/omd/sites/TEST_SITE/etc/nagios/local/hostgroups', + :hostgroups => host_groups, + :target => '/omd/sites/TEST_SITE/etc/check_mk/main.mk', + :notify => 'Exec[check_mk-refresh]', + }) + } + end +end From b25613bddb87bae655b541ec961d9c381c8460b2 Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Mon, 1 Jun 2015 09:56:10 +0200 Subject: [PATCH 34/65] Add test for check_mk::service --- spec/classes/check_mk_service_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 spec/classes/check_mk_service_spec.rb diff --git a/spec/classes/check_mk_service_spec.rb b/spec/classes/check_mk_service_spec.rb new file mode 100644 index 0000000..bb05c3d --- /dev/null +++ b/spec/classes/check_mk_service_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' +describe 'check_mk::service', :type => :class do + context 'with defaults for all parameters' do + it { should contain_class('check_mk::service') } + it { should contain_service('httpd').with({ + :ensure => 'running', + :enable => 'true', + }) + } + it { should contain_service('omd').with({ + :ensure => 'running', + :enable => 'true', + }) + } + end +end From 2f83c6051a11b139f181b32a588dd1b82a6760ca Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Mon, 1 Jun 2015 10:08:51 +0200 Subject: [PATCH 35/65] Add test for check_mk::host --- spec/defines/check_mk_host_spec.rb | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 spec/defines/check_mk_host_spec.rb diff --git a/spec/defines/check_mk_host_spec.rb b/spec/defines/check_mk_host_spec.rb new file mode 100644 index 0000000..0a60870 --- /dev/null +++ b/spec/defines/check_mk_host_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' +describe 'check_mk::host', :type => :define do + let :title do + 'host' + end + context 'with empty host_tags array' do + let :params do + {:target => 'target'} + end + it { should contain_check_mk__host('host') } + it { should contain_concat__fragment('check_mk-host').with({ + :target => 'target', + :content => /^ 'host',\n$/, + :order => 11, + }) + } + end + context 'with custom host_tags' do + let :params do + { + :target => 'target', + :host_tags => ['tag1', 'tag2'], + } + end + it { should contain_check_mk__host('host') } + it { should contain_concat__fragment('check_mk-host').with({ + :target => 'target', + :content => /^ 'host|tag1|tag2',\n$/, + :order => 11, + }) + } + end +end From 97324f4cfe67c5e5a25e868446daa110d63c216d Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Mon, 1 Jun 2015 11:37:52 +0200 Subject: [PATCH 36/65] Add test for check_mk::hostgroup --- spec/defines/check_mk_hostgroup_spec.rb | 83 +++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 spec/defines/check_mk_hostgroup_spec.rb diff --git a/spec/defines/check_mk_hostgroup_spec.rb b/spec/defines/check_mk_hostgroup_spec.rb new file mode 100644 index 0000000..d2ba88e --- /dev/null +++ b/spec/defines/check_mk_hostgroup_spec.rb @@ -0,0 +1,83 @@ +require 'spec_helper' +describe 'check_mk::hostgroup', :type => :define do + + context 'with hostgroups, host_tags and description' do + let :title do + 'TEST_HOSTGROUP' + end + hostgroups = { + 'TEST_HOSTGROUP' => { + 'host_tags' => [ + 'tag1', + 'tag2', + ], + 'description' => 'TEST_DESCRIPTION', + }, + } + let :params do + { + :dir => '/dir', + :hostgroups => hostgroups, + :target => 'target' + } + end + it { should contain_check_mk__hostgroup('TEST_HOSTGROUP') } + it { should contain_concat__fragment('check_mk-hostgroup-TEST_HOSTGROUP').with({ + :target => 'target', + :content => /^ \( 'TEST_HOSTGROUP', \[ 'tag1', 'tag2' \], ALL_HOSTS \),\n$/, + :order => 21, + }) + } + expected_file_content = < 'present', + :content => expected_file_content, + }) + } + end + + context 'with hostgroups without description' do + let :title do + 'TEST_HOUSTGROUP_WITH_UNDERSCORES' + end + hostgroups = { + 'TEST_HOUSTGROUP_WITH_UNDERSCORES' => { + 'host_tags' => [ + 'tag1', + 'tag2', + ], + }, + } + let :params do + { + :dir => '/dir', + :hostgroups => hostgroups, + :target => '/target' + } + end + it { should contain_check_mk__hostgroup('TEST_HOUSTGROUP_WITH_UNDERSCORES') } + it { should contain_concat__fragment('check_mk-hostgroup-TEST_HOUSTGROUP_WITH_UNDERSCORES').with({ + :target => '/target', + :content => /^ \( 'TEST_HOUSTGROUP_WITH_UNDERSCORES', \[ 'tag1', 'tag2' \], ALL_HOSTS \),\n$/, + :order => 21, + }) + } + expected_file_content = < 'present', + :content => expected_file_content, + }) + } + end + +end From 869119d5e23d0016026f7c81abb1833ef534f7e4 Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Fri, 29 May 2015 11:21:51 +0200 Subject: [PATCH 37/65] Add test for check_mk::agent --- spec/classes/check_mk_agent_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 spec/classes/check_mk_agent_spec.rb diff --git a/spec/classes/check_mk_agent_spec.rb b/spec/classes/check_mk_agent_spec.rb new file mode 100644 index 0000000..26bb33f --- /dev/null +++ b/spec/classes/check_mk_agent_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper' +describe 'check_mk::agent', :type => :class do + context 'Redhat Linux' do + let :facts do + { + :kernel => 'Linux', + :operatingsystem => 'Redhat', + :osfamily => 'Redhat', + } + end + context 'with defaults for all parameters' do + it { should contain_class('check_mk::agent') } + it { should contain_class('check_mk::agent::install').that_comes_before('Class[check_mk::agent::config]') } + it { should contain_class('check_mk::agent::config') } + it { should contain_class('check_mk::agent::service') } + end + end +end From 8567406672a586079df4a119f0eaacddfc20d5c8 Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Fri, 29 May 2015 15:44:01 +0200 Subject: [PATCH 38/65] Add test for check_mk::agent::install --- spec/classes/check_mk_agent_install_spec.rb | 52 +++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 spec/classes/check_mk_agent_install_spec.rb diff --git a/spec/classes/check_mk_agent_install_spec.rb b/spec/classes/check_mk_agent_install_spec.rb new file mode 100644 index 0000000..821e9e2 --- /dev/null +++ b/spec/classes/check_mk_agent_install_spec.rb @@ -0,0 +1,52 @@ +require 'spec_helper' +describe 'check_mk::agent::install', :type => :class do + + context 'RedHat Linux' do + let :facts do + { + :kernel => 'Linux', + :operatingsystem => 'Redhat', + :osfamily => 'Redhat', + } + end + context 'with necessary parameters set' do + let :params do + { + :version => '1.2.3', + :filestore => false, + :workspace => '/workspace', + :package => 'custom-package', + } + end + it { should contain_class('check_mk::agent::install') } + it { should contain_package('xinetd') } + it { should contain_package('check_mk-agent').with_name('custom-package') } + end + + context 'with filestore' do + let :params do + { + :version => '1.2.3', + :filestore => '/filestore', + :workspace => '/workspace', + :package => 'custom-package', + } + end + it { should contain_class('check_mk::agent::install') } + it { should contain_package('xinetd') } + it { should contain_file('/workspace').with_ensure('directory') } + it { should contain_File('/workspace/check_mk-agent-1.2.3.noarch.rpm').with({ + :ensure => 'present', + :source => '/filestore/check_mk-agent-1.2.3.noarch.rpm', + :require => 'Package[xinetd]', + }).that_comes_before('Package[check_mk-agent]') + } + it { should contain_package('check_mk-agent').with({ + :provider => 'rpm', + :source => '/workspace/check_mk-agent-1.2.3.noarch.rpm', + }) + } + end + end + +end From 1a8d77c8a1d50c0bd42c97b52c0dde30101b9b3c Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Mon, 1 Jun 2015 09:04:19 +0200 Subject: [PATCH 39/65] Add test for check_mk::agent::service --- spec/classes/check_mk_agent_service_spec.rb | 29 +++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 spec/classes/check_mk_agent_service_spec.rb diff --git a/spec/classes/check_mk_agent_service_spec.rb b/spec/classes/check_mk_agent_service_spec.rb new file mode 100644 index 0000000..a85b3e9 --- /dev/null +++ b/spec/classes/check_mk_agent_service_spec.rb @@ -0,0 +1,29 @@ +require 'spec_helper' +describe 'check_mk::agent::service', :type => :class do + + context 'all' do + it { should contain_class('check_mk::agent::service') } + it { should contain_service('xinetd').with({ + :ensure => 'running', + :enable => true, + }) + } + end + + context 'Debian 7' do + let :facts do + { + :operatingsystem => 'Debian', + :operatingsystemmajrelease => '7', + } + end + it { should contain_class('check_mk::agent::service') } + it { should contain_service('xinetd').with({ + :ensure => 'running', + :enable => true, + :hasstatus => false, + }) + } + end + +end From a40f2a48d30d3b3eb320c53807c76aa235e528b3 Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Wed, 3 Jun 2015 16:54:28 +0200 Subject: [PATCH 40/65] Add test for check_mk::agent::config --- spec/classes/check_mk_agent_config_spec.rb | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 spec/classes/check_mk_agent_config_spec.rb diff --git a/spec/classes/check_mk_agent_config_spec.rb b/spec/classes/check_mk_agent_config_spec.rb new file mode 100644 index 0000000..ea0a197 --- /dev/null +++ b/spec/classes/check_mk_agent_config_spec.rb @@ -0,0 +1,24 @@ +require 'spec_helper' +describe 'check_mk::agent::config', :type => :class do + + context 'Redhat Linux' do + let :facts do + { + :kernel => 'Linux', + :osfamily => 'RedHat', + } + end + context 'with defaults for all parameters' do + it { should contain_class('check_mk::agent::config') } + it { should contain_file('/etc/xinetd.d/check-mk-agent'). + with_content(/^\tport\s+ = $/). + with_content(/^\tuser\s+ = $/). + with_content(/^\tserver\s+ = \/check_mk_agent$/). + without_content(/only_from/) + } + it { should contain_file('/etc/xinetd.d/check_mk').with_ensure('absent') } + end + end +end + + From 845b271871ae00470b30d659b412aee8f8303d69 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Mon, 7 Mar 2016 11:25:46 +0100 Subject: [PATCH 41/65] metadata.json: add missing up boundary for stdlib --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 3d832cc..d1a6c0c 100644 --- a/metadata.json +++ b/metadata.json @@ -39,6 +39,6 @@ "dependencies": [ { "name": "puppetlabs/concat", "version_requirement": ">= 1.0.0 <2.0.0" }, - { "name": "puppetlabs/stdlib", "version_requirement": ">= 2.3.0" } + { "name": "puppetlabs/stdlib", "version_requirement": ">= 2.3.0 <5.0.0" } ] } From 9248bae44c4943c7b35b9710d31eed0bc3e74ce1 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Mon, 7 Mar 2016 11:28:13 +0100 Subject: [PATCH 42/65] Update files for version 0.6.2 --- Changelog | 3 +++ metadata.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index d9c7345..c20eb30 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,6 @@ +0.6.2: +* Add rspec tests contributed by gerhardsam. + 0.4.0: * Fix all_hosts_static.erb, update xinetd on wheezy and use cron instead of a diff --git a/metadata.json b/metadata.json index d1a6c0c..fe2d303 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "gnubilafrance-check_mk", - "version": "0.6.1", + "version": "0.6.2", "author": "Baptiste Grenier ", "license": "Apache-2.0", "summary": "Check_MK installation and configuration", From f905fb14dcc7e5ce5da541d8cc0ef0726ea2a9e2 Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Wed, 2 Mar 2016 13:11:45 +0100 Subject: [PATCH 43/65] Set optional parameters to be undefined That way it is no longer necessary to pass the parameters. --- manifests/agent/config.pp | 8 +-- manifests/agent/install.pp | 8 +-- spec/classes/check_mk_agent_config_spec.rb | 17 ++++++- spec/classes/check_mk_agent_install_spec.rb | 56 ++++++++++++++++++--- 4 files changed, 73 insertions(+), 16 deletions(-) diff --git a/manifests/agent/config.pp b/manifests/agent/config.pp index 5d4ddeb..03cb7be 100644 --- a/manifests/agent/config.pp +++ b/manifests/agent/config.pp @@ -26,10 +26,10 @@ # class check_mk::agent::config ( $ip_whitelist = undef, - $port = undef, - $server_dir = undef, - $use_cache = undef, - $user = undef, + $port = undef, + $server_dir = undef, + $use_cache = undef, + $user = undef, ) { if $use_cache { $server = "${server_dir}/check_mk_caching_agent" diff --git a/manifests/agent/install.pp b/manifests/agent/install.pp index 536cbf3..bc05055 100644 --- a/manifests/agent/install.pp +++ b/manifests/agent/install.pp @@ -1,8 +1,8 @@ class check_mk::agent::install ( - $version, - $filestore, - $workspace, - $package, + $version = undef, + $filestore = undef, + $workspace = undef, + $package = undef, ) { if ! defined(Package['xinetd']) { package { 'xinetd': diff --git a/spec/classes/check_mk_agent_config_spec.rb b/spec/classes/check_mk_agent_config_spec.rb index ea0a197..f631fb3 100644 --- a/spec/classes/check_mk_agent_config_spec.rb +++ b/spec/classes/check_mk_agent_config_spec.rb @@ -4,7 +4,6 @@ context 'Redhat Linux' do let :facts do { - :kernel => 'Linux', :osfamily => 'RedHat', } end @@ -14,11 +13,25 @@ with_content(/^\tport\s+ = $/). with_content(/^\tuser\s+ = $/). with_content(/^\tserver\s+ = \/check_mk_agent$/). - without_content(/only_from/) + without_content(/only_from/). + with_notify('Class[Check_mk::Agent::Service]') } it { should contain_file('/etc/xinetd.d/check_mk').with_ensure('absent') } end end + + context 'Other OS' do + context 'with defaults for all parameters' do + it { should contain_file('/etc/xinetd.d/check_mk'). + with_content(/^\tport\s+ = $/). + with_content(/^\tuser\s+ = $/). + with_content(/^\tserver\s+ = \/check_mk_agent$/). + without_content(/only_from/). + with_notify('Class[Check_mk::Agent::Service]') + } + it { should_not contain_file('/etc/xinetd.d/check_mk').with_ensure('absent') } + end + end end diff --git a/spec/classes/check_mk_agent_install_spec.rb b/spec/classes/check_mk_agent_install_spec.rb index 821e9e2..148ec94 100644 --- a/spec/classes/check_mk_agent_install_spec.rb +++ b/spec/classes/check_mk_agent_install_spec.rb @@ -4,17 +4,19 @@ context 'RedHat Linux' do let :facts do { - :kernel => 'Linux', - :operatingsystem => 'Redhat', :osfamily => 'Redhat', } end - context 'with necessary parameters set' do + + context 'with default parameters' do + it { should contain_class('check_mk::agent::install') } + it { should contain_package('xinetd') } + it { should contain_package('check_mk-agent').with_name('check-mk-agent') } + end + + context 'with custom package' do let :params do { - :version => '1.2.3', - :filestore => false, - :workspace => '/workspace', :package => 'custom-package', } end @@ -49,4 +51,46 @@ end end + context 'Debian Linux' do + let :facts do + { + :osfamily => 'Debian', + } + end + + context 'with default parameters' do + it { should contain_class('check_mk::agent::install') } + it { should contain_package('xinetd') } + it { should contain_package('check_mk-agent').with_name('check-mk-agent') } + end + + context 'with custom package' do + let :params do + { + :package => 'custom-package', + } + end + it { should contain_class('check_mk::agent::install') } + it { should contain_package('xinetd') } + it { should contain_package('check_mk-agent').with_name('custom-package') } + end + end + + context 'Unknown OS' do + context 'with default parameters' do + it { should contain_class('check_mk::agent::install') } + it { should contain_package('xinetd') } + it { should contain_package('check_mk-agent').with_name('check_mk-agent') } + end + context 'with custom package' do + let :params do + { + :package => 'custom-package', + } + end + it { should contain_class('check_mk::agent::install') } + it { should contain_package('xinetd') } + it { should contain_package('check_mk-agent').with_name('custom-package') } + end + end end From 6c4395a80ad49004c6a0cea879c7eb43a730c907 Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Wed, 2 Mar 2016 13:23:08 +0100 Subject: [PATCH 44/65] Include agent classes instead of instantiating them --- manifests/agent.pp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/manifests/agent.pp b/manifests/agent.pp index 2d467f7..9b2e33f 100644 --- a/manifests/agent.pp +++ b/manifests/agent.pp @@ -10,21 +10,11 @@ $workspace = '/root/check_mk', $package = undef, ) { - class { 'check_mk::agent::install': - version => $version, - filestore => $filestore, - workspace => $workspace, - package => $package, - } - class { 'check_mk::agent::config': - ip_whitelist => $ip_whitelist, - port => $port, - server_dir => $server_dir, - use_cache => $use_cache, - user => $user, - require => Class['check_mk::agent::install'], - } + include check_mk::agent::install + include check_mk::agent::config include check_mk::agent::service + Class['check_mk::agent::install'] -> + Class['check_mk::agent::config'] @@check_mk::host { $::fqdn: host_tags => $host_tags, } From 22af0dc937473a73cd9b6903d4891d24ed03705e Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Tue, 8 Mar 2016 13:38:41 +0100 Subject: [PATCH 45/65] Inherit agent-config parameters from parent-class --- manifests/agent/config.pp | 12 ++--- spec/classes/check_mk_agent_config_spec.rb | 53 ++++++++++++++++++---- 2 files changed, 49 insertions(+), 16 deletions(-) diff --git a/manifests/agent/config.pp b/manifests/agent/config.pp index 03cb7be..dbf7b42 100644 --- a/manifests/agent/config.pp +++ b/manifests/agent/config.pp @@ -25,12 +25,12 @@ # Default: undef # class check_mk::agent::config ( - $ip_whitelist = undef, - $port = undef, - $server_dir = undef, - $use_cache = undef, - $user = undef, -) { + $ip_whitelist = $check_mk::agent::ip_whitelist, + $port = $check_mk::agent::port, + $server_dir = $check_mk::agent::server_dir, + $use_cache = $check_mk::agent::use_cache, + $user = $check_mk::agent::user, +) inherits check_mk::agent { if $use_cache { $server = "${server_dir}/check_mk_caching_agent" } else { diff --git a/spec/classes/check_mk_agent_config_spec.rb b/spec/classes/check_mk_agent_config_spec.rb index f631fb3..68fd2aa 100644 --- a/spec/classes/check_mk_agent_config_spec.rb +++ b/spec/classes/check_mk_agent_config_spec.rb @@ -10,24 +10,57 @@ context 'with defaults for all parameters' do it { should contain_class('check_mk::agent::config') } it { should contain_file('/etc/xinetd.d/check-mk-agent'). - with_content(/^\tport\s+ = $/). - with_content(/^\tuser\s+ = $/). - with_content(/^\tserver\s+ = \/check_mk_agent$/). - without_content(/only_from/). - with_notify('Class[Check_mk::Agent::Service]') + with_content(/^\tport\s+ = 6556$/). + with_content(/^\tuser\s+ = root$/). + with_content(/^\tserver\s+ = \/usr\/bin\/check_mk_agent$/). + without_content(/only_from/). + with_notify('Class[Check_mk::Agent::Service]') } it { should contain_file('/etc/xinetd.d/check_mk').with_ensure('absent') } end + context 'with use_cache' do + let :params do + { + :use_cache => true, + } + end + it { should contain_file('/etc/xinetd.d/check-mk-agent'). + with_content(/^\tserver\s+ = \/usr\/bin\/check_mk_caching_agent$/) + } + end + context 'with ip_whitelist' do + let :params do + { + :ip_whitelist => [ + '1.2.3.4', + '5.6.7.8', + ], + } + end + it { should contain_file('/etc/xinetd.d/check-mk-agent'). + with_content(/^\tonly_from\s+= 127.0.0.1 1.2.3.4 5.6.7.8$/) + } + end + context 'with custom user' do + let :params do + { + :user => 'custom', + } + end + it { should contain_file('/etc/xinetd.d/check-mk-agent'). + with_content(/^\tuser\s+ = custom$/) + } + end end context 'Other OS' do context 'with defaults for all parameters' do it { should contain_file('/etc/xinetd.d/check_mk'). - with_content(/^\tport\s+ = $/). - with_content(/^\tuser\s+ = $/). - with_content(/^\tserver\s+ = \/check_mk_agent$/). - without_content(/only_from/). - with_notify('Class[Check_mk::Agent::Service]') + with_content(/^\tport\s+ = 6556$/). + with_content(/^\tuser\s+ = root$/). + with_content(/^\tserver\s+ = \/usr\/bin\/check_mk_agent$/). + without_content(/only_from/). + with_notify('Class[Check_mk::Agent::Service]') } it { should_not contain_file('/etc/xinetd.d/check_mk').with_ensure('absent') } end From 7f3f49baa30a3f36f30eb6813dcacb561981e373 Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Tue, 8 Mar 2016 13:29:23 +0100 Subject: [PATCH 46/65] Inherit agent-install parameters version and workspace from parent-class --- manifests/agent/install.pp | 6 +++--- spec/classes/check_mk_agent_install_spec.rb | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/manifests/agent/install.pp b/manifests/agent/install.pp index bc05055..1e0324e 100644 --- a/manifests/agent/install.pp +++ b/manifests/agent/install.pp @@ -1,9 +1,9 @@ class check_mk::agent::install ( - $version = undef, + $version = $check_mk::agent::version, $filestore = undef, - $workspace = undef, + $workspace = $check_mk::agent::workspace, $package = undef, -) { +) inherits check_mk::agent { if ! defined(Package['xinetd']) { package { 'xinetd': ensure => present, diff --git a/spec/classes/check_mk_agent_install_spec.rb b/spec/classes/check_mk_agent_install_spec.rb index 148ec94..00efbd4 100644 --- a/spec/classes/check_mk_agent_install_spec.rb +++ b/spec/classes/check_mk_agent_install_spec.rb @@ -9,7 +9,15 @@ end context 'with default parameters' do - it { should contain_class('check_mk::agent::install') } + it { should contain_class('check_mk::agent::install').with( + { + :version => nil, + :filestore => nil, + :workspace => '/root/check_mk', + :package => nil, + } + ) + } it { should contain_package('xinetd') } it { should contain_package('check_mk-agent').with_name('check-mk-agent') } end From 4aa26ea038f1c6b742495ca13e22931bd7915dfb Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Tue, 8 Mar 2016 13:51:04 +0100 Subject: [PATCH 47/65] Make parameter version only mandatory with given filestore parameter --- manifests/agent/install.pp | 4 ++ spec/classes/check_mk_agent_install_spec.rb | 55 +++++++++++++-------- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/manifests/agent/install.pp b/manifests/agent/install.pp index 1e0324e..a377e56 100644 --- a/manifests/agent/install.pp +++ b/manifests/agent/install.pp @@ -10,6 +10,10 @@ } } if $filestore { + if ! $version { + fail('version must be specified.') + } + if ! defined(File[$workspace]) { file { $workspace: ensure => directory, diff --git a/spec/classes/check_mk_agent_install_spec.rb b/spec/classes/check_mk_agent_install_spec.rb index 00efbd4..dce3bd2 100644 --- a/spec/classes/check_mk_agent_install_spec.rb +++ b/spec/classes/check_mk_agent_install_spec.rb @@ -34,28 +34,43 @@ end context 'with filestore' do - let :params do - { - :version => '1.2.3', - :filestore => '/filestore', - :workspace => '/workspace', - :package => 'custom-package', + context 'without version' do + let :params do + { + :filestore => '/filestore', + } + end + it 'should fail' do + expect { catalogue }.to raise_error(Puppet::Error, /version must be specified/) + end + end + context 'with custom parameters' do + let :params do + { + :version => '1.2.3', + :filestore => '/filestore', + :workspace => '/workspace', + } + end + it { should contain_class('check_mk::agent::install') } + it { should contain_package('xinetd') } + it { should contain_file('/workspace').with_ensure('directory') } + it { should contain_File('/workspace/check_mk-agent-1.2.3.noarch.rpm').with( + { + :ensure => 'present', + :source => '/filestore/check_mk-agent-1.2.3.noarch.rpm', + :require => 'Package[xinetd]', + } + ).that_comes_before('Package[check_mk-agent]') + } + it { should contain_package('check_mk-agent').with( + { + :provider => 'rpm', + :source => '/workspace/check_mk-agent-1.2.3.noarch.rpm', + } + ) } end - it { should contain_class('check_mk::agent::install') } - it { should contain_package('xinetd') } - it { should contain_file('/workspace').with_ensure('directory') } - it { should contain_File('/workspace/check_mk-agent-1.2.3.noarch.rpm').with({ - :ensure => 'present', - :source => '/filestore/check_mk-agent-1.2.3.noarch.rpm', - :require => 'Package[xinetd]', - }).that_comes_before('Package[check_mk-agent]') - } - it { should contain_package('check_mk-agent').with({ - :provider => 'rpm', - :source => '/workspace/check_mk-agent-1.2.3.noarch.rpm', - }) - } end end From 0a7e295c69da8e47c5007679629ca8110edfb3f4 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Tue, 8 Mar 2016 14:55:32 +0100 Subject: [PATCH 48/65] Update files for version 0.7.0 --- Changelog | 3 +++ metadata.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index c20eb30..88eb98b 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,6 @@ +0.7.0: +* Rework of check_mk::agent classes, contributed by gerhardsam. + 0.6.2: * Add rspec tests contributed by gerhardsam. diff --git a/metadata.json b/metadata.json index fe2d303..b674cdf 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "gnubilafrance-check_mk", - "version": "0.6.2", + "version": "0.7.0", "author": "Baptiste Grenier ", "license": "Apache-2.0", "summary": "Check_MK installation and configuration", From e3f8280a299c18ca3b76129e1f07a4bb8176c83e Mon Sep 17 00:00:00 2001 From: Bas Grolleman Date: Tue, 25 Nov 2014 14:31:54 +0100 Subject: [PATCH 49/65] Adding check_mk::agent::mrpe to configure mrpe lines Cherry-picked from https://github.com/sanoma-technology/puppet-check_mk/commit/c1e94657f8a864c594fb5a177a76bb558cbe8f14 --- manifests/agent/mrpe.pp | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 manifests/agent/mrpe.pp diff --git a/manifests/agent/mrpe.pp b/manifests/agent/mrpe.pp new file mode 100644 index 0000000..c345250 --- /dev/null +++ b/manifests/agent/mrpe.pp @@ -0,0 +1,44 @@ +# +# Add entry to the mrpe.cfg file +# +### Parameters +# +### command +# +# The command to run +# +### Example +# +# ``` +# check_mk::agent::mrpe { 'Test': +# command => '/bin/true' +# } +# ``` +# +## Authors +# +# * Bas Grolleman +# +define check_mk::agent::mrpe ( + $command +) { + $mrpe_config_file = $::operatingsystem ? { + centos => '/etc/check-mk-agent/mrpe.cfg', + redhat => '/etc/check-mk-agent/mrpe.cfg', + default => undef + } + + if ( $mrpe_config_file ) { + if ! defined(Concat[$mrpe_config_file]) { + concat { $mrpe_config_file: + ensure => 'present'; + } + } + concat::fragment { $name: + target => $mrpe_config_file, + content => "${name} ${command}\n" + } + } else { + fail("Creating mrpe.cfg is unsupported for operatingsystem ${::operatingsystem}") + } +} From fd3bb452979938c3deb009c89d5b9827ad7327aa Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Mon, 29 Feb 2016 12:25:22 +0100 Subject: [PATCH 50/65] Add test for check_mk::agent::mrpe --- spec/defines/check_mk_agent_mrpe_spec.rb | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 spec/defines/check_mk_agent_mrpe_spec.rb diff --git a/spec/defines/check_mk_agent_mrpe_spec.rb b/spec/defines/check_mk_agent_mrpe_spec.rb new file mode 100644 index 0000000..d1f0c5d --- /dev/null +++ b/spec/defines/check_mk_agent_mrpe_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' +describe 'check_mk::agent::mrpe', :type => :define do + let :title do + 'mrpe' + end + context 'Unsupported OS' do + context 'with mandatory command' do + let :params do + {:command => 'command'} + end + it 'should fail' do + expect { catalogue }.to raise_error(Puppet::Error, /Creating mrpe.cfg is unsupported for operatingsystem/) + end + end + end + context 'RedHat Linux' do + let :facts do + { + :operatingsystem => 'redhat', + } + end + context 'with mandatory command' do + let :params do + {:command => 'command'} + end + it { should contain_check_mk__agent__mrpe('mrpe') } + it { should contain_concat('/etc/check-mk-agent/mrpe.cfg').with_ensure('present') } + it { should contain_concat__fragment('mrpe').with({ + :target => '/etc/check-mk-agent/mrpe.cfg', + :content => /^mrpe command\n$/, + }) + } + end + end +end From 22b38c145bf40325f6f77f46c2edf9d755ef72c6 Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Wed, 9 Mar 2016 09:09:22 +0100 Subject: [PATCH 51/65] Append mrpe-check suffix for concat-fragment This is done to avoid collisions in the catalog containing concat-fragments with the same name. --- manifests/agent/mrpe.pp | 4 ++-- spec/defines/check_mk_agent_mrpe_spec.rb | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifests/agent/mrpe.pp b/manifests/agent/mrpe.pp index c345250..17b4beb 100644 --- a/manifests/agent/mrpe.pp +++ b/manifests/agent/mrpe.pp @@ -31,10 +31,10 @@ if ( $mrpe_config_file ) { if ! defined(Concat[$mrpe_config_file]) { concat { $mrpe_config_file: - ensure => 'present'; + ensure => 'present' } } - concat::fragment { $name: + concat::fragment { "${name}-mrpe-check": target => $mrpe_config_file, content => "${name} ${command}\n" } diff --git a/spec/defines/check_mk_agent_mrpe_spec.rb b/spec/defines/check_mk_agent_mrpe_spec.rb index d1f0c5d..b911d0a 100644 --- a/spec/defines/check_mk_agent_mrpe_spec.rb +++ b/spec/defines/check_mk_agent_mrpe_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'check_mk::agent::mrpe', :type => :define do let :title do - 'mrpe' + 'checkname' end context 'Unsupported OS' do context 'with mandatory command' do @@ -23,11 +23,11 @@ let :params do {:command => 'command'} end - it { should contain_check_mk__agent__mrpe('mrpe') } + it { should contain_check_mk__agent__mrpe('checkname') } it { should contain_concat('/etc/check-mk-agent/mrpe.cfg').with_ensure('present') } - it { should contain_concat__fragment('mrpe').with({ + it { should contain_concat__fragment('checkname-mrpe-check').with({ :target => '/etc/check-mk-agent/mrpe.cfg', - :content => /^mrpe command\n$/, + :content => /^checkname command\n$/, }) } end From 2ebe420c6bb7e49726f8e25cbe3eb6e4d370509b Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Tue, 8 Mar 2016 09:59:22 +0100 Subject: [PATCH 52/65] Add parameter to create check_mk::agent::mrpe resources --- manifests/agent.pp | 3 +++ spec/classes/check_mk_agent_spec.rb | 29 +++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/manifests/agent.pp b/manifests/agent.pp index 9b2e33f..3a50356 100644 --- a/manifests/agent.pp +++ b/manifests/agent.pp @@ -9,7 +9,9 @@ $version = undef, $workspace = '/root/check_mk', $package = undef, + $mrpe_checks = {}, ) { + validate_hash($mrpe_checks) include check_mk::agent::install include check_mk::agent::config include check_mk::agent::service @@ -18,4 +20,5 @@ @@check_mk::host { $::fqdn: host_tags => $host_tags, } + create_resources('check_mk::agent::mrpe', $mrpe_checks) } diff --git a/spec/classes/check_mk_agent_spec.rb b/spec/classes/check_mk_agent_spec.rb index 26bb33f..6d08a4d 100644 --- a/spec/classes/check_mk_agent_spec.rb +++ b/spec/classes/check_mk_agent_spec.rb @@ -3,9 +3,9 @@ context 'Redhat Linux' do let :facts do { - :kernel => 'Linux', + :kernel => 'Linux', :operatingsystem => 'Redhat', - :osfamily => 'Redhat', + :osfamily => 'Redhat', } end context 'with defaults for all parameters' do @@ -14,5 +14,30 @@ it { should contain_class('check_mk::agent::config') } it { should contain_class('check_mk::agent::service') } end + context 'with mrpe_checks' do + context 'not a hash' do + let :params do + { + :mrpe_checks => 'not_a_hash', + } + end + it 'should fail' do + expect { catalogue }.to raise_error(Puppet::Error, /\"not_a_hash\" is not a Hash./) + end + end + context 'defined correctly' do + let :params do + { + :mrpe_checks => { + 'check1' => {'command' => 'command1'}, + 'check2' => {'command' => 'command2'}, + } + } + end + it { should contain_class('check_mk::agent') } + it { should contain_check_mk__agent__mrpe('check1').with_command('command1') } + it { should contain_check_mk__agent__mrpe('check2').with_command('command2') } + end + end end end From 166ce4db0ae8b962fee96883a58257e19ec27372 Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Wed, 9 Mar 2016 10:40:47 +0100 Subject: [PATCH 53/65] Update documentation to explain parameter check_mk::agent::mrpe_checks --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2b8b51e..9b755a7 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,8 @@ Only required if a filestore is used. *workspace*: The directory to use to store files used during installation. Default: '/root/check_mk' +*mrpe_checks*: Specifies a hash of check_mk::agent::mrpe resources to create. Default: {} + ## Host groups and tags By default check_mk puts all hosts into a group called 'check_mk' but where you From 9056328622ad1927a852a91184f0ea2441e92f67 Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Wed, 9 Mar 2016 10:44:58 +0100 Subject: [PATCH 54/65] Add missing comma at EOL --- manifests/agent/mrpe.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/agent/mrpe.pp b/manifests/agent/mrpe.pp index 17b4beb..6697a4e 100644 --- a/manifests/agent/mrpe.pp +++ b/manifests/agent/mrpe.pp @@ -20,7 +20,7 @@ # * Bas Grolleman # define check_mk::agent::mrpe ( - $command + $command, ) { $mrpe_config_file = $::operatingsystem ? { centos => '/etc/check-mk-agent/mrpe.cfg', From c10b5348f2e5fdde22bb99f2afa48435a5445f03 Mon Sep 17 00:00:00 2001 From: Sebastian Gerhards Date: Wed, 9 Mar 2016 11:16:59 +0100 Subject: [PATCH 55/65] Drop support for ruby 1.8.7 rake (11.0.1) does not working with ruby-versions older than 1.9.3. --- .travis.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index ad552c1..95fdfaf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,11 +17,6 @@ script: - puppet --version - bundle exec rake validate lint spec matrix: - include: - - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 3.7.0" RSPEC_GEM_VERSION="< 3.2.0" - - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 3.8.0" RSPEC_GEM_VERSION="< 3.2.0" exclude: - rvm: 2.2 env: PUPPET_GEM_VERSION="~> 3.7.0" From dafde6d21dccd5f746331c1ff89de043f5ed7536 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Mon, 14 Mar 2016 09:55:35 +0100 Subject: [PATCH 56/65] check_mk::agent::mrpe: add missing at EOL --- manifests/agent/mrpe.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/agent/mrpe.pp b/manifests/agent/mrpe.pp index 6697a4e..eb0c80f 100644 --- a/manifests/agent/mrpe.pp +++ b/manifests/agent/mrpe.pp @@ -25,18 +25,18 @@ $mrpe_config_file = $::operatingsystem ? { centos => '/etc/check-mk-agent/mrpe.cfg', redhat => '/etc/check-mk-agent/mrpe.cfg', - default => undef + default => undef, } if ( $mrpe_config_file ) { if ! defined(Concat[$mrpe_config_file]) { concat { $mrpe_config_file: - ensure => 'present' + ensure => 'present', } } concat::fragment { "${name}-mrpe-check": target => $mrpe_config_file, - content => "${name} ${command}\n" + content => "${name} ${command}\n", } } else { fail("Creating mrpe.cfg is unsupported for operatingsystem ${::operatingsystem}") From 53d6994ec6e2cabb1c4dcd2da2b014011f90f151 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Mon, 14 Mar 2016 09:57:24 +0100 Subject: [PATCH 57/65] metadata.json: bump version --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index b674cdf..bd549c5 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "gnubilafrance-check_mk", - "version": "0.7.0", + "version": "0.7.1", "author": "Baptiste Grenier ", "license": "Apache-2.0", "summary": "Check_MK installation and configuration", From d5829458cf765a04f935c0e209d94d0ac32b19a0 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Mon, 14 Mar 2016 09:58:24 +0100 Subject: [PATCH 58/65] Changelog: add entry for 0.7.1 --- Changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Changelog b/Changelog index 88eb98b..107bf9b 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,6 @@ +0.7.1: +* Add check_mk::agent::mrpe, code from Bas Grolleman contributed by gerhardsam. + 0.7.0: * Rework of check_mk::agent classes, contributed by gerhardsam. From 256dc4a40c063f1839be0eea4bf1d53e2e5e94a9 Mon Sep 17 00:00:00 2001 From: Jeroen Hooyberghs Date: Tue, 5 Apr 2016 09:01:26 +0200 Subject: [PATCH 59/65] move params for init.pp to params.pp and allow override of check_mk service name and httpd service name --- manifests/init.pp | 16 ++++++++++------ manifests/params.pp | 14 ++++++++++++++ manifests/service.pp | 11 +++++++---- 3 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 manifests/params.pp diff --git a/manifests/init.pp b/manifests/init.pp index 24e4e0d..c654527 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,9 +1,11 @@ class check_mk ( - $filestore = undef, - $host_groups = undef, - $package = 'omd-0.56', - $site = 'monitoring', - $workspace = '/root/check_mk', + $checkmk_service = $checkmk::params::checkmk_service, + $filestore = $checkmk::params::filestore + $host_groups = $checkmk::params::host_groups, + $httpd_service = $checkmk::params::httpd_service, + $package = $checkmk::params::package, + $site = $checkmk::params::site, + $workspace = $checkmk::params::workspace, ) { class { 'check_mk::install': filestore => $filestore, @@ -17,6 +19,8 @@ require => Class['check_mk::install'], } class { 'check_mk::service': - require => Class['check_mk::config'], + checmk_service => $checkmk_service, + httpd_service => $httpd_service, + require => Class['check_mk::config'], } } diff --git a/manifests/params.pp b/manifests/params.pp new file mode 100644 index 0000000..b3e0356 --- /dev/null +++ b/manifests/params.pp @@ -0,0 +1,14 @@ +class check_mk::params { + # general settings + $checkmk_service = 'omd' + + # OS specific + case $::osfamily { + 'RedHat': { + $httpd_service = 'httpd' + } + 'Debian': { + $httpd_service = 'apache2' + } + } +} diff --git a/manifests/service.pp b/manifests/service.pp index 4b31df9..0016b43 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -1,6 +1,9 @@ -class check_mk::service { - if ! defined(Service[httpd]) { - service { 'httpd': +class check_mk::service ( + $checkmk_service, + $httpd_service, +) { + if ! defined(Service[$httpd_service]) { + service { "$httpd_service": ensure => 'running', enable => true, } @@ -11,7 +14,7 @@ enable => true, } } - service { 'omd': + service { $service: ensure => 'running', enable => true, } From feee8aa993973c8372384c217a1beec5be39af79 Mon Sep 17 00:00:00 2001 From: Jeroen Hooyberghs Date: Tue, 5 Apr 2016 09:26:01 +0200 Subject: [PATCH 60/65] set some defaults --- manifests/init.pp | 19 ++++++++++--------- manifests/install.pp | 4 ++-- manifests/params.pp | 10 ++++++++-- manifests/service.pp | 2 +- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index c654527..aaa1bd9 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,12 +1,13 @@ class check_mk ( - $checkmk_service = $checkmk::params::checkmk_service, - $filestore = $checkmk::params::filestore - $host_groups = $checkmk::params::host_groups, - $httpd_service = $checkmk::params::httpd_service, - $package = $checkmk::params::package, - $site = $checkmk::params::site, - $workspace = $checkmk::params::workspace, -) { + $checkmk_service = $check_mk::params::checkmk_service, + $filestore = undef, + $host_groups = undef, + $httpd_service = $check_mk::params::httpd_service, + $package = $check_mk::params::package, + $site = $check_mk::params::site, + $workspace = $check_mk::params::workspace, +) inherits check_mk::params { + class { 'check_mk::install': filestore => $filestore, package => $package, @@ -19,7 +20,7 @@ require => Class['check_mk::install'], } class { 'check_mk::service': - checmk_service => $checkmk_service, + checkmk_service => $checkmk_service, httpd_service => $httpd_service, require => Class['check_mk::config'], } diff --git a/manifests/install.pp b/manifests/install.pp index 97f7efa..1943508 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -1,6 +1,6 @@ class check_mk::install ( - $filestore, - $package, + $filestore = undef, + $package = undef, $site, $workspace, ) { diff --git a/manifests/params.pp b/manifests/params.pp index b3e0356..edd6028 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,8 +1,14 @@ class check_mk::params { - # general settings + + # common variables $checkmk_service = 'omd' + $package = 'omd-0.56' + $filestore = undef + $host_groups= undef + $site = 'monitoring' + $workspace = '/root/check_mk' - # OS specific + # OS specific variables case $::osfamily { 'RedHat': { $httpd_service = 'httpd' diff --git a/manifests/service.pp b/manifests/service.pp index 0016b43..f21bd51 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -14,7 +14,7 @@ enable => true, } } - service { $service: + service { $checkmk_service: ensure => 'running', enable => true, } From 58b06fd1944226423489175e34877033259a05c1 Mon Sep 17 00:00:00 2001 From: Jeroen Hooyberghs Date: Tue, 5 Apr 2016 10:17:12 +0200 Subject: [PATCH 61/65] use params for filestore and host_groups --- manifests/init.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index aaa1bd9..acab396 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,7 +1,7 @@ class check_mk ( $checkmk_service = $check_mk::params::checkmk_service, - $filestore = undef, - $host_groups = undef, + $filestore = $check_mk::params::filestore, + $host_groups = $check_mk::params::host_groups, $httpd_service = $check_mk::params::httpd_service, $package = $check_mk::params::package, $site = $check_mk::params::site, From f9972d08c71ddb38eafb90f0763d132b53d5b1ed Mon Sep 17 00:00:00 2001 From: Frederic Wou Date: Mon, 12 Jun 2017 09:39:22 +0200 Subject: [PATCH 62/65] "concat::fragment" no longer supports "ensure" --- manifests/config.pp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 957cb89..23f99ea 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -76,10 +76,14 @@ } } # local config is in /omd/sites/${site}/etc/check_mk/main.mk.local and is appended - concat::fragment { 'check_mk-local-config': - ensure => "${etc_dir}/check_mk/main.mk.local", + file { "${etc_dir}/check_mk/all_hosts_static": + ensure => file, + } + + concat::fragment { 'all-hosts-static': + source => "${etc_dir}/check_mk/all_hosts_static", target => "${etc_dir}/check_mk/main.mk", - order => 99, + order => 18, } # re-read config if it changes exec { 'check_mk-refresh': From 50864810ea9cad3a180866675068a4bbd5f5b082 Mon Sep 17 00:00:00 2001 From: Frederic Wou Date: Mon, 12 Jun 2017 10:11:35 +0200 Subject: [PATCH 63/65] avoid \file" duplicate resource --- manifests/config.pp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 23f99ea..4765bb1 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -76,10 +76,6 @@ } } # local config is in /omd/sites/${site}/etc/check_mk/main.mk.local and is appended - file { "${etc_dir}/check_mk/all_hosts_static": - ensure => file, - } - concat::fragment { 'all-hosts-static': source => "${etc_dir}/check_mk/all_hosts_static", target => "${etc_dir}/check_mk/main.mk", From dfd114b1956697d884f240b448ec139a4fb9de8f Mon Sep 17 00:00:00 2001 From: Frederic Wou Date: Mon, 12 Jun 2017 11:05:40 +0200 Subject: [PATCH 64/65] module \puppetlabs-concat" release "4.0.0" is now supported --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index bd549c5..f08e1e2 100644 --- a/metadata.json +++ b/metadata.json @@ -38,7 +38,7 @@ ], "dependencies": [ - { "name": "puppetlabs/concat", "version_requirement": ">= 1.0.0 <2.0.0" }, + { "name": "puppetlabs/concat", "version_requirement": ">= 1.0.0 <5.0.0" }, { "name": "puppetlabs/stdlib", "version_requirement": ">= 2.3.0 <5.0.0" } ] } From 8c1038f46449e00718392584144e44e3183b6e42 Mon Sep 17 00:00:00 2001 From: Frederic Wou Date: Thu, 15 Jun 2017 15:46:40 +0200 Subject: [PATCH 65/65] "config.pp" updated for "puppetlabs-concat" release 4.0.0 compatibility --- manifests/config.pp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 4765bb1..328f3d9 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -28,7 +28,7 @@ concat { "${etc_dir}/check_mk/main.mk": owner => 'root', group => 'root', - mode => '0644', + mode => 'u=rw,go=r', notify => Exec['check_mk-refresh'], } # all_hosts @@ -48,7 +48,7 @@ } # local list of hosts is in /omd/sites/${site}/etc/check_mk/all_hosts_static and is appended concat::fragment { 'all-hosts-static': - ensure => "${etc_dir}/check_mk/all_hosts_static", + source => "${etc_dir}/check_mk/all_hosts_static", target => "${etc_dir}/check_mk/main.mk", order => 18, } @@ -76,10 +76,16 @@ } } # local config is in /omd/sites/${site}/etc/check_mk/main.mk.local and is appended - concat::fragment { 'all-hosts-static': - source => "${etc_dir}/check_mk/all_hosts_static", + file { "${etc_dir}/check_mk/main.mk.local": + ensure => file, + owner => 'root', + group => 'root', + mode => 'u=rw,go=r', + } + concat::fragment { 'check_mk-local-config': + source => "${etc_dir}/check_mk/main.mk.local", target => "${etc_dir}/check_mk/main.mk", - order => 18, + order => 99, } # re-read config if it changes exec { 'check_mk-refresh':