Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add $selinux_ignore_defaults parameter with default value true #1043

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wbclark
Copy link
Contributor

@wbclark wbclark commented Apr 22, 2022

The idea is that foreman::selinux_ignore_defaults: true can be used for initial install so that the system will determine security context for files at the time they are created, and foreman::selinux_ignore_defaults: false can be used on subsequent runs to remediate drift from the already installed policy.

This allows foreman-installer to eliminate hooks/pre/32-install_selinux_packages.rb.

The one case this doesn't adequately cover would be the case where foreman-selinux package is updated by this module with changes to the policy. This would be solved for foreman_maintain users by having foreman_maintain run the installer with foreman::selinux_ignore_defaults: false since packages would always be updated prior to the installer running.

Do not lookup default security context for file resources in catalogue compilation and attempt to manage them; instead defer context lookups to the system itself when the files are actually created. Useful during initial installs, because Puppet can install packages like foreman-selinux which modify the security policy after the context lookups were performed, which breaks idempotence. This can
 be disabled after the initial install, to allow Puppet to remedy drift in security context.
Since the module now has an option to run without managing file security
context, this workaround is not needed.
Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder about this approach. On the one hand, it does allow an initial install to pass. On the other, it can't rectify labels if they are incorrect.

A further enhancement to this could be to introduce a custom fact that checks if foreman-selinux is installed. Something like foreman_selinux_installed. Then you use selinux_ignore_defaults => !facts['foreman_selinux_installed']. In the initial run it'll avoid setting labels while in the future it rectifies contexts on managed files.

Thoughts on this?

Comment on lines +319 to +323
if $facts['os']['selinux']['enabled'] {
File {
selinux_ignore_defaults => $foreman::selinux_ignore_defaults,
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm against this. It's way too broad and magic. Pretty sure this affects the whole catalog, not just the files created by this module.

Instead, can we set the property everywhere? It's more verbose, but also easier to follow.

Comment on lines -5 to -11
# Needed for idempotency when SELinux is enabled
if $foreman::repo::configure_scl_repo {
package { 'rh-redis5-redis':
ensure => installed,
require => Class['foreman::repo'],
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've dropped EL7 so this should no longer be needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants