Puppet Class: selinux
- Defined in:
- manifests/init.pp
Summary
Manage SELinuxOverview
This module manages the SELinux configuration file.
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 |
# File 'manifests/init.pp', line 36
class selinux (
Pattern[/^enforcing|permissive|disabled$/] $mode = 'enforcing',
Pattern[/^targeted|strict$/] $type = 'targeted',
Variant[Undef, Enum['0','1'], Integer[0,1]] $setlocaldefs = undef,
Stdlib::Absolutepath $config_file = '/etc/selinux/config',
Boolean $policytools = false,
) {
# selinux allows you to set the system to permissive or enforcing while
# disabling completely requires a reboot. We set to permissive here when the
# desired level is disabled, since it has the similar effect of ignoring
# selinux and we do not have to force a reboot.
if $mode == 'permissive' or $mode == 'disabled' {
exec { 'set_permissive_mode':
command => 'setenforce Permissive',
unless => 'getenforce | grep -ie permissive -e disabled',
path => '/bin:/usr/bin:/sbin:/usr/sbin',
}
if $policytools == true {
Package['policycoreutils-python'] {
before +> Exec['set_permissive_mode'],
}
}
}
if $mode == 'enforcing' {
exec { 'set_enforcing_mode':
command => 'setenforce Enforcing',
unless => 'getenforce | grep -i enforcing',
path => '/bin:/usr/bin:/sbin:/usr/sbin',
}
if $policytools == true {
Package['policycoreutils-python'] {
before +> Exec['set_enforcing_mode'],
}
}
}
file { 'selinux_config':
ensure => 'file',
path => $config_file,
owner => 'root',
group => 'root',
mode => '0644',
content => template('selinux/config.erb'),
}
# Provide the semanage command to allow permanent configuration of the selinux
# policy. This allows the restorecon command to restore policy to a specified
# default.
if $policytools == true {
package { 'policycoreutils-python':
ensure => installed,
}
}
}
|