This class manages SELinux.
metadata.json
This module will configure SELinux and/or deploy SELinux based modules to running system.
Previously, module building always used the refpolicy framework. The default module builder is now 'simple', which uses only checkmodule. Not all features are supported with this builder.
To build modules using the refpolicy framework like previous versions did, specify the 'refpolicy' builder either explicitly per module or globally via the main class
The interfaces to the various helper manifests has been changed to be more in line with Puppet file resource naming conventions.
You will need to update your manifests to use the new parameter names.
The selinux::restorecond manifest to manage the restorecond service no longer exists
selinux_python_command
fact is now deprecated and will be removed in
version 4 of the module.semanage fcontext
(what selinux::fcontext
does) the order is important. If you add /my/folder before /my/folder/subfolder
only /my/folder will match (limitation of SELinux). There is no such limitation
to file-contexts defined in SELinux modules. (GH-121)selinux_port
provider may misbehave if the title does not correspond to
the format it expects. Users should use the selinux::port
define instead except
when purging resourcesGenerated puppet strings documentation with examples is available in the REFERENCE.md
It's also included in the docs/ folder as simple html pages.
include selinux
This will include the module and allow you to use the provided defined types, but will not modify existing SELinux settings on the system.
class { selinux:
mode => 'enforcing',
type => 'targeted',
}
This will include the module and manage the SELinux mode (possible values are
enforcing
, permissive
, and disabled
) and enforcement type (possible values
are targeted
, minimum
, and mls
). Note that disabling SELinux requires a reboot
to fully take effect. It will run in permissive
mode until then.
selinux::module { 'resnet-puppet':
ensure => 'present',
source_te => 'puppet:///modules/site_puppet/site-puppet.te',
source_fc => 'puppet:///modules/site_puppet/site-puppet.fc',
source_if => 'puppet:///modules/site_puppet/site-puppet.if',
builder => 'refpolicy'
}
selinux::module { 'resnet-puppet':
ensure => 'present',
source_pp => 'puppet:///modules/site_puppet/site-puppet.pp',
}
Note that pre-compiled policy packages may not work reliably across all RHEL / CentOS releases. It's up to you as the user to test that your packages load properly.
selinux::boolean { 'puppetagent_manage_all_files': }
boolean
- Set seboolean valuesfcontext
- Define fcontext types and equals valuesmodule
- Manage an SELinux modulepermissive
- Set a context to permissive
.port
- Set selinux port context policiessemanage
requires --noreload
while in disabled mode when
adding or changing something--list
operations work./test-acceptance-with-vagrant
The fact values might be unexpected while in disabled mode. One could expect
the config_mode to be set, but only the boolean enabled
is set.
The most important facts:
Fact | Mode: disabled | Mode: permissive | Mode: enforcing |
---|---|---|---|
$facts['os']['selinux']['enabled'] |
false | true | true |
$facts['os']['selinux']['config_mode'] |
undef | Value of SELINUX in /etc/selinux/config | Value of SELINUX in /etc/selinux/config |
$facts['os']['selinux']['current_mode'] |
undef | Value of getenforce downcased |
Value of getenforce downcased |