Puppet Class: psick::sysctl

Defined in:
manifests/sysctl.pp

Overview

This class manages sysctl It uses duritong-sysctl module Hiera data should be in this format: psick::sysctl::settings_hash:

net.ipv4.tcp_keepalive_time: 900
net.ipv4.conf.default.arp_filter: 1

Parameters:

  • settings_hash (Hash) (defaults to: {})
  • settings_auto_conf_hash (Hash) (defaults to: {})
  • module (String) (defaults to: 'psick')
  • template (String) (defaults to: 'psick/generic/inifile.erb')
  • target_file (String) (defaults to: '/etc/sysctl.conf')
  • manage (Boolean) (defaults to: $psick::manage)
  • noop_manage (Boolean) (defaults to: $psick::noop_manage)
  • noop_value (Boolean) (defaults to: $psick::noop_value)


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

class psick::sysctl (
  Hash            $settings_hash           = {},
  Hash            $settings_auto_conf_hash = {},
  String          $module                  = 'psick',
  String          $template                = 'psick/generic/inifile.erb',
  String          $target_file             = '/etc/sysctl.conf',

  Boolean          $manage               = $psick::manage,
  Boolean          $noop_manage          = $psick::noop_manage,
  Boolean          $noop_value           = $psick::noop_value,

) {
  if $manage {
    if $noop_manage {
      noop($noop_value)
    }
    $all_settings = $settings_auto_conf_hash + $settings_hash

    if $all_settings != {} {
      if $module == 'psick' {
        $parameters = $all_settings
        file { $target_file:
          content => psick::template($template,$parameters),
          notify  => Exec['psick refresh sysctl'],
        }
        exec { 'psick refresh sysctl':
          refreshonly => true,
          command     => 'sysctl -p /etc/sysctl.conf',
        }
      } else {
        $all_settings.each |$k,$v| {
          case $module {
            'psick': {
              psick::sysctl::set { $k: value => $v }
            }
            'duritong': {
              sysctl::value { $k: value => $v }
            }
            'thias': {
              sysctl { $k: value => $v }
            }
            'herculesteam': {
              sysctl { $k: value => $v }
            }
            default: {
              notify { "sysctl ${module} module not supported. Can't set sysctl ${k}":
                message => "Module ${module} not currently not supported. Feel free to contribute to its integration!",
              }
            }
          }
        }
      }
    }
  }
}