Puppet Class: smokeping::config

Defined in:
manifests/config.pp

Summary

Manage SmokePing configuration

Overview



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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'manifests/config.pp', line 2

class smokeping::config {
  assert_private()

  $mode          = $smokeping::mode
  $master_url    = $smokeping::master_url
  $slave_name    = $smokeping::slave_name
  $master_name   = $smokeping::master_name

  # General config
  $owner          = $smokeping::owner
  $contact        = $smokeping::contact
  $mailhost       = $smokeping::mailhost
  $cgiurl         = $smokeping::cgiurl
  $syslogfacility = $smokeping::syslogfacility
  $syslogpriority = $smokeping::syslogpriority
  $daemon_user    = $smokeping::daemon_user
  $daemon_group   = $smokeping::daemon_group

  # The owner of the image files (written by the webserver)
  $webserver_user  = $smokeping::webserver_user
  $webserver_group = $smokeping::webserver_group

  # Probes
  $probes = $smokeping::probes

  # Alerts
  $alerts_to   = $smokeping::alerts_to
  $alerts_from = $smokeping::alerts_from
  $alerts      = $smokeping::alerts

  # Pathnames
  $path_sendmail  = $smokeping::path_sendmail
  $path_imgcache  = $smokeping::path_imgcache
  $path_imgurl    = $smokeping::path_imgurl
  $path_datadir   = $smokeping::path_datadir
  $path_piddir    = $smokeping::path_piddir
  $path_smokemail = $smokeping::path_smokemail
  $path_tmail     = $smokeping::path_tmail

  File {
    owner => root,
    group => root,
    mode  => '0644',
  }

  file { '/etc/smokeping/config.d':
    ensure  => directory,
    recurse => true,
    purge   => true,
    force   => true,
  }

  -> file {
    '/etc/smokeping/config':
      content => template('smokeping/config.erb');
    '/etc/smokeping/config.d/Alerts':
      content => template('smokeping/alerts.erb');
    '/etc/smokeping/config.d/Database':
      content => template('smokeping/database.erb');
    '/etc/smokeping/config.d/General':
      content => template('smokeping/general.erb');
    '/etc/smokeping/config.d/pathnames':
      content => template('smokeping/pathnames.erb');
    '/etc/smokeping/config.d/Presentation':
      content => template('smokeping/presentation.erb');
    '/etc/smokeping/config.d/Probes':
      content => template('smokeping/probes.erb');
  }

  ## mode specific
  case $mode {
    'slave': {
      smokeping::slave { $smokeping::slave_name:
        location     => $smokeping::slave_location,
        display_name => pick($smokeping::slave_display_name, $facts['networking']['hostname']),
        color        => pick($smokeping::slave_color, fqdn_rand(0xffffff)),
      }

      $dropin = @("EOT")
        [Service]
        ExecStart=
        ExecStart=/usr/sbin/smokeping --master-url=${smokeping::master_url} --cache-dir=${smokeping::path_datadir} --shared-secret=${smokeping::shared_secret} --slave-name=${smokeping::slave_name} --pid-dir=/run/smokeping
        | EOT

      systemd::dropin_file { 'slave.conf':
        unit    => 'smokeping.service',
        content => $dropin,
      }
    }

    ## Master/Standalone configuration
    ## collect slaves if mode is master and create Targets
    ## if mode is standalone, just create targets...
    /^(master|standalone)$/: {
      if $mode == 'master' {
        # collect slaves
        File <<| tag == "smokeping-slave-${master_name}" |>>

        file { $smokeping::slave_dir:
          ensure => directory,
        }

        concat { '/etc/smokeping/config.d/Slaves':
          owner => root,
          group => root,
          mode  => '0644',
        }

        concat::fragment { 'slaves-header':
          target  => '/etc/smokeping/config.d/Slaves',
          order   => 10,
          content => "*** Slaves ***\nsecrets=${smokeping::slave_secrets}\n\n",
        }

        Concat::Fragment <<| tag == "smokeping-slave-${master_name}" |>>

        # collect shared secrets from slaves
        concat { $smokeping::slave_secrets:
          owner => $daemon_user,
          group => $webserver_group,
          mode  => '0640',
        }

        Concat::Fragment <<| tag == "smokeping-slave-secret-${master_name}" |>>
      } else {
        file { $smokeping::slave_secrets:
          ensure => file,
          owner  => $daemon_user,
          group  => $webserver_group,
          mode   => '0640',
        }
      }

      # create target definitions
      file { $smokeping::targets_dir:
        ensure  => directory,
        recurse => true,
        purge   => true,
        force   => true,
      }

      concat { '/etc/smokeping/config.d/Targets':
        owner => root,
        group => root,
        mode  => '0644',
      }

      concat::fragment { 'targets-header':
        target  => '/etc/smokeping/config.d/Targets',
        order   => 10,
        content => epp("${module_name}/targets-header.epp"),
      }

      $smokeping::targets.each |$key, $value| {
        smokeping::target { $key:
          * => $value,
        }
      }
    }

    default: {
      fail("mode ${mode} unknown")
    }
  }
}