summaryrefslogtreecommitdiff
path: root/sitemodules/profiles/manifests/nrpe_agent.pp
blob: a2942b779fa5e9d5a1187c5517e42f55e5c3db60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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,
    enable => 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'],
  }
}