Puppet Class: tpm::ima
- Defined in:
- manifests/ima.pp
Overview
Sets up IMA kernel boot flags if they are not enabled, and mounts the securityfs when they are.
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 |
# File 'manifests/ima.pp', line 34
class tpm::ima (
Boolean $enable = true,
Boolean $manage_policy = false,
Stdlib::AbsolutePath $mount_dir = '/sys/kernel/security',
Boolean $ima_audit = true,
Tpm::Ima::Template $ima_template = 'ima-ng',
String $ima_hash = 'sha256',
Boolean $ima_tcb = true,
Integer $log_max_size = 30000000
){
if $enable {
if $facts['cmdline']['ima'] == 'on' {
mount { $mount_dir:
ensure => mounted,
atboot => true,
device => 'securityfs',
fstype => 'securityfs',
target => '/etc/fstab',
remounts => true,
options => 'defaults',
dump => '0',
pass => '0'
}
}
kernel_parameter { 'ima':
value => 'on',
bootmode => 'normal'
}
kernel_parameter { 'ima_audit':
value => $ima_audit,
bootmode => 'normal'
}
kernel_parameter { 'ima_template':
value => $ima_template,
bootmode => 'normal'
}
kernel_parameter { 'ima_hash':
value => $ima_hash,
bootmode => 'normal'
}
if $ima_tcb {
kernel_parameter { 'ima_tcb':
notify => Reboot_notify['ima_reboot']
}
}
# This feature will remain commented out until the generated policy
# can be safely imported. As of now, it makes the system read-only
# if $manage_policy {
# include '::tpm::ima::policy'
# }
if $facts['ima_log_size'] >= $log_max_size {
reboot_notify { 'ima_log':
reason => 'The IMA /sys/kernel/security/ima/ascii_runtime_measurements is filling up kernel memory. Please reboot to clear.'
}
}
}
else {
kernel_parameter { [ 'ima_tcb' ]:
ensure => 'absent',
notify => Reboot_notify['ima_reboot']
}
kernel_parameter { [ 'ima', 'ima_audit', 'ima_template', 'ima_hash' ]:
ensure => 'absent',
bootmode => 'normal'
}
}
reboot_notify { 'ima_reboot':
subscribe => [
Kernel_parameter['ima'],
Kernel_parameter['ima_audit'],
Kernel_parameter['ima_template'],
Kernel_parameter['ima_hash']
]
}
}
|