Add nrpe_agent profile and apply it for svn
authorJan Dittberner <jandd@cacert.org>
Wed, 21 Feb 2018 15:11:52 +0000 (16:11 +0100)
committerJan Dittberner <jandd@cacert.org>
Wed, 21 Feb 2018 15:11:52 +0000 (16:11 +0100)
hieradata/common.yaml
sitemodules/profiles/files/nrpe_agent/apt.cfg [new file with mode: 0644]
sitemodules/profiles/manifests/nrpe_agent.pp [new file with mode: 0644]
sitemodules/profiles/templates/nrpe_agent/nrpe_local.cfg.epp [new file with mode: 0644]
sitemodules/roles/manifests/svnserver.pp

index 965484e..da1b702 100644 (file)
@@ -30,3 +30,5 @@ profiles::base::users:
         name: default
         type: ssh-dss
         key: ENC[PKCS7,MIIDvQYJKoZIhvcNAQcDoIIDrjCCA6oCAQAxggEhMIIBHQIBADAFMAACAQEwDQYJKoZIhvcNAQEBBQAEggEAFlMnp5/GjTc9u6H7IlFvPb1OCGx+2EkijO0S0jqwIV3u4ZTCGrxxfQR99iW4o4ID1nvkXjecLJzcL+D158tmcnQrVHVJWRobZ+wGYtDRFge03Kh7uZXI+MPQ6ndc2TTRpYPz7XSDrzm2HCAL7vEogeORKsfE8bjAnNEkHy1V/lOixaLa1yYUid1erGKoOyYItBbwH6pMhejTIeLQ1i/er4sWafaiOOof7WsuahN/vYhWzcax17lBcsbPUH8kPcZWz04b+hPVForD2gPnUsL53IX1E/AfcZD1ulcfAPR4KrWEPH6jmM7bhgKnUDBxp2yMCXsm7apMwIiEOXf7rvGUczCCAn4GCSqGSIb3DQEHATAdBglghkgBZQMEASoEEABESUVzMYsINc6QIE29XoaAggJQXiYOQnw99VJuAsjD/jkYix6/+HR48YzmRO/8qX7UqAprAv1bJ3GNLzJe+ibhokFHuj5dk6dfXnAOwGeFrD180TR7BBDIkw1jBwX8p+8mQMeAKv5rF9B3041oGfrxvFrE7lBgYW6pGhaHmycP9/nPmoPYWT+V3OhViVZkhi+3j9MjHgPKa7kTRzbFYo4xmpjYtRN2E3Ftvg6zqgEGtlxlBet22ICNCj9CFoIrvRVP3NQue5sRbQj0KKih+KWfN4gT7GWqhIvKtzESp0vU/WbyDFfEbfON9jFVloo+ndGcLs1k0e3LUpu90lDZ450SWc+DbMi5YlWMN/CvWKzuVahw7gIYMP0Ug9a/7x8WQqi7ilmkqU2rmlVdcCgvTjx9R/5G+mVXsCJgud55o9d3aP9eBcaqRIQ/vTmhdNpbmKmfaga/w3GE59K0v3ovNGEv64XJtJDLaD7ZkrUpwjZyexGaSjNvYCLcQUZwLtQ4SB0nqbT/FGv9BnH9mFUcu4S2CM5Yy8RcBGZ8DKAKHRez+RyzNwhjQ01VS5IOvIuXNsYnVCzuZ/MQelxgk5fzAC5wYXrpj+COoQY8QhhKmjLxO0HD5MdhbUQ+Nnmid8vOs5s7MsV/jeKsSeM+sxmA3M1aDFy/0rZ2zS2XbMePd7iBNTB3LwAjzIwx3SJbNDAJ0CDEM5e9iWkWah17PqvzLufE0QCd5FgbS/RxW7PAXtHWHvcx0qg1MJZXl5DGWy0HcxcWMJHmLNSjmEgEGcuRTvwAK0whbQePKIvBBvY6Gaovs18EOw==]
+profiles::nrpe_agent::allowed_hosts:
+  - 172.16.2.18
diff --git a/sitemodules/profiles/files/nrpe_agent/apt.cfg b/sitemodules/profiles/files/nrpe_agent/apt.cfg
new file mode 100644 (file)
index 0000000..7aa2887
--- /dev/null
@@ -0,0 +1,8 @@
+# THIS FILE IS MANAGED BY PUPPET, MANUAL CHANGES WILL BE OVERWRITTEN AT THE
+# NEXT PUPPET RUN.
+
+# 'check_apt' command definition
+command[check_apt]=/usr/lib/nagios/plugins/check_apt
+
+# 'check_apt_distupgrade' command definition
+command[check_apt_distupgrade]=/usr/lib/nagios/plugins/check_apt -d
diff --git a/sitemodules/profiles/manifests/nrpe_agent.pp b/sitemodules/profiles/manifests/nrpe_agent.pp
new file mode 100644 (file)
index 0000000..df7674d
--- /dev/null
@@ -0,0 +1,76 @@
+# Class: profiles::nrpe_agent
+# ===========================
+#
+# This class installs and configures the nrpe agent for remote monitoring.
+#
+# Parameters
+# ----------
+#
+# @param allowed_hosts list of allowed host IP addresses
+#
+# Examples
+# --------
+#
+# @example
+#   class roles::myhost {
+#     include profiles::nrpe_agent
+#   }
+#
+# Authors
+# -------
+#
+# Jan Dittberner <jandd@cacert.org>
+#
+# Copyright
+# ---------
+#
+# Copyright 2018 Jan Dittberner
+class profiles::nrpe_agent (
+   Array[String] $allowed_hosts,
+) {
+  package { 'nagios-nrpe-server':
+    ensure => latest,
+  }
+
+  package { 'monitoring-plugins-basic':
+    ensure => latest,
+  }
+
+  service { 'nagios-nrpe-server':
+    ensure  => running,
+    enabled => true,
+  }
+
+  file { '/etc/nagios/nrpe_local.cfg':
+    ensure  => file,
+    owner   => 'root',
+    group   => 'root',
+    mode    => '0644',
+    content => epp(
+      'profiles/nrpe_agent/nrpe_local.cfg.epp',
+      {
+        'allowed_hosts' => $allowed_hosts
+      }
+    ),
+    require => Package['nagios-nrpe-server'],
+    notify  => Service['nagios-nrpe-server'],
+  }
+
+  file { '/etc/nagios/nrpe.d':
+    ensure  => directory,
+    owner   => 'root',
+    group   => 'root',
+    mode    => '0755',
+    require => Package['nagios-nrpe-server'],
+  }
+
+  file { '/etc/nagios/nrpe.d/apt.cfg':
+    ensure  => file,
+    owner   => 'root',
+    group   => 'root',
+    mode    => '0644',
+    source  => 'puppet:///modules//profiles/nrpe_agent/apt.cfg',
+    require => [File['/etc/nagios/nrpe.d']],
+    notify  => Service['nagios-nrpe-server'],
+  }
+}
diff --git a/sitemodules/profiles/templates/nrpe_agent/nrpe_local.cfg.epp b/sitemodules/profiles/templates/nrpe_agent/nrpe_local.cfg.epp
new file mode 100644 (file)
index 0000000..04792b3
--- /dev/null
@@ -0,0 +1,6 @@
+<%- | Array[String] $allowed_hosts = undef |-%>
+# THIS FILE IS MANAGED BY PUPPET, MANUAL CHANGES WILL BE OVERWRITTEN AT THE
+# NEXT PUPPET RUN.
+
+# local nrpe configuration
+allowed_hosts=<%= $allowed_hosts.join(',') %>
index 64d4508..60a054f 100644 (file)
@@ -18,8 +18,9 @@
 # Copyright
 # ---------
 #
-# Copyright 2016 Jan Dittberner
+# Copyright 2016-2017 Jan Dittberner
 #
 class roles::svnserver {
   include profiles::base
+  include profiles::nrpe_agent
 }