Puppet Class: librenms::config

Inherits:
librenms::params
Defined in:
manifests/config.pp

Overview

Class: librenms::config

Configure a virtual host for LibreNMS

Parameters:

  • system_user (String)
  • basedir (Any)
  • server_name (String)
  • admin_user (String)
  • admin_pass (String)
  • admin_email (String)
  • db_user (Any)
  • db_host (Any)
  • db_pass (Any)
  • poller_modules (Hash[String, Integer[0,1]])
  • poller_threads (Integer)
  • rrdtool_version (String)
  • extra_config_file (Optional[String]) (defaults to: undef)


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
# File 'manifests/config.pp', line 6

class librenms::config
(
    String  $system_user,
            $basedir,
    String  $server_name,
    String  $admin_user,
    String  $admin_pass,
    String  $admin_email,
            $db_user,
            $db_host,
            $db_pass,
    Hash[String, Integer[0,1]] $poller_modules,
    Integer $poller_threads,
    String  $rrdtool_version,
    Optional[String] $extra_config_file = undef,

) inherits librenms::params {
    File {
        ensure => 'present',
        mode   => '0755',
    }

    # Construct the poller module hash, with defaults coming from params.pp
    $l_poller_modules = merge($::librenms::params::default_poller_modules, $poller_modules)

    # The LibreNMS-specific rrdcached service will only work on systemd distros 
    # at the moment.
    if $::systemd {
        $rrdcached_line = "\$config['rrdcached'] = \"unix:/run/rrdcached.sock\";"
    } else {
        $rrdcached_line = '# rrdcached disabled by Puppet because this is not a systemd distro'
    }

    file { 'librenms-config.php':
        path    => "${basedir}/config.php",
        owner   => $system_user,
        group   => $system_user,
        content => template('librenms/config.php.erb'),
        require => Class['::librenms::install'],
    }

    Exec {
        user => $::os::params::adminuser,
        path => [ '/bin', '/sbin', '/usr/bin', '/usr/sbin', '/usr/local/bin', '/usr/local/sbin' ],
    }

    $build_base_php_require = File['librenms-config.php']

    exec { 'librenms-composer_wrapper.php':
        command => "php ${basedir}/scripts/composer_wrapper.php install --no-dev && touch ${basedir}/.composer_wrapper.php-ran",
        creates => "${basedir}/.composer_wrapper.php-ran",
        require => $build_base_php_require,
    }

    exec { 'librenms-build-base.php':
        command => "php ${basedir}/build-base.php && touch ${basedir}/.build-base.php-ran",
        creates => "${basedir}/.build-base.php-ran",
        require =>
        [
          $build_base_php_require,
          Exec['librenms-composer_wrapper.php'],
        ]
    }

    exec { 'librenms-adduser.php':
        command => "php ${basedir}/adduser.php ${admin_user} ${admin_pass} 10 ${admin_email} && touch ${basedir}/.adduser.php-ran",
        creates => "${basedir}/.adduser.php-ran",
        require => Exec['librenms-build-base.php'],
    }

    file { '/etc/cron.d/librenms':
      ensure  => 'present',
      source  => 'file:///opt/librenms/librenms.nonroot.cron',
      mode    => '0644',
      owner   => 'root',
      group   => 'root',
      require => Class['::librenms::install'],
    }
}