summaryrefslogtreecommitdiff
path: root/sitemodules/profiles/manifests/icinga2_common.pp
blob: 1703d2ba7ebe7e5be8fbb8e839097b82017a84e3 (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
# Class: profiles::icinga2_common
# ===============================
#
# Common configuration code for Icinga2 agent and master setups.
#
# This manifest is meant to be included from other manifests.
#
# Parameters
# ----------
#
# @param ca_certificate         Icinga2 CA certificate content
#
# Examples
# --------
#
# @example
#   include profiles::icinga2_common
#
# Authors
# -------
#
# Jan Dittberner <jandd@cacert.org>
#
# Copyright
# ---------
#
# Copyright 2019 Jan Dittberner
class profiles::icinga2_common (
  String $ca_certificate,
) {
  if $::lsbdistcodename == 'stretch' {
    apt::pin { 'icinga2_backports':
      packages => [
        'icinga2',
        'icinga2-bin',
        'icinga2-common',
        'icinga2-doc',
        'icinga2-ido-pgsql',
        'libicinga2',
      ],
      priority => 500,
      release  => 'stretch-backports',
    }
    Apt::Pin['icinga2_backports'] -> Package <| name == 'icinga2' or name == 'icinga2-ido-pgsql' |>
  }
  package { 'icinga2':
    ensure => latest,
  }
  file { '/etc/icinga2/pki':
    ensure  => directory,
    owner   => 'nagios',
    group   => 'nagios',
    mode    => '0700',
    require => Package['icinga2'],
  }
  file { '/etc/icinga2/pki/ca.crt':
    ensure  => file,
    content => $ca_certificate,
    owner   => 'nagios',
    group   => 'nagios',
    mode    => '0644',
    require => File['/etc/icinga2/pki'],
  }
}