aboutsummaryrefslogtreecommitdiff
path: root/manifests/subsystem/sysctl.pp
blob: 1df0348636a0b2c081b0783ff5e94a4d00d7018a (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
class nodo::subsystem::sysctl {
  # Root exploit fix, see http://wiki.debian.org/mmap_min_addr
  # Maybe this can be remove in the future or included in a sysctl puppet module
  file { "/etc/sysctl.d/mmap_min_addr.conf":
    owner   => "root",
    group   => "root",
    mode    => 0644,
    ensure  => present,
    content => "vm.mmap_min_addr = 4096\n",
  }

  # See http://www.linux-vserver.org/Frequently_Asked_Questions
  file { "/etc/sysctl.d/net.ipv4.conf.all.promote_secondaries.conf":
    owner   => "root",
    group   => "root",
    mode    => 0644,
    ensure  => present,
    content => "net.ipv4.conf.all.promote_secondaries = 1\n",
  }

  exec { "/etc/init.d/procps restart":
    subscribe   => File["/etc/sysctl.d/mmap_min_addr.conf", "/etc/sysctl.d/net.ipv4.conf.all.promote_secondaries.conf"],
    refreshonly => true,
  }

  $printk_levels = '3 4 1 3'

  file { "/etc/sysctl.d/kernel.printk.conf":
    owner   => "root",
    group   => "root",
    mode    => 0644,
    ensure  => present,
    content => "kernel.printk = ${printk_levels}\n",
  }

  exec { "/bin/echo '${printk_levels}' > /proc/sys/kernel/printk":
    subscribe   => File["/etc/sysctl.d/kernel.printk.conf"],
    refreshonly => true,
  }
}

class sysctl::appliance($kernel_panic = hiera('nodo::sysctl::appliance', '20')) {
  file { "/etc/sysctl.d/kernel.panic.conf":
    owner   => "root",
    group   => "root",
    mode    => 0644,
    ensure  => present,
    content => "kernel.panic = ${kernel_panic}\n",
  }

  exec { "/bin/echo '${kernel_panic}' > /proc/sys/kernel/panic":
    subscribe   => File["/etc/sysctl.d/kernel.panic.conf"],
    refreshonly => true,
  }
}