class Chef::Resource::SelinuxState
Public Instance Methods
node_selinux_restart()
click to toggle source
# File lib/chef/resource/selinux_state.rb, line 93 def node_selinux_restart unless new_resource.automatic_reboot Chef::Log.warn("SELinux state change to #{action} requires a manual reboot as SELinux is currently #{selinux_state} and automatic reboots are disabled.") return end outer_action = action reboot "selinux_state_change" do delay_mins 1 reason "SELinux state change to #{outer_action} from #{selinux_state}" action new_resource.automatic_reboot.is_a?(Symbol) ? new_resource.automatic_reboot : :reboot_now end end
render_selinux_template(action)
click to toggle source
# File lib/chef/resource/selinux_state.rb, line 74 def render_selinux_template(action) Chef::Log.warn("It is advised to set the configuration first to permissive to relabel the filesystem prior to enforcing.") if selinux_disabled? && action == :enforcing unless new_resource.automatic_reboot Chef::Log.warn("Changes from disabled require a reboot.") if selinux_disabled? && %i{enforcing permissive}.include?(action) Chef::Log.warn("Disabling selinux requires a reboot.") if (selinux_enforcing? || selinux_permissive?) && action == :disabled end template "#{action} selinux config" do path new_resource.config_file source debian? ? ::File.expand_path("selinux/selinux_debian.erb", __dir__) : ::File.expand_path("selinux/selinux_default.erb", __dir__) local true variables( selinux: action.to_s, selinuxtype: new_resource.policy ) end end
Private Instance Methods
default_policy_platform()
click to toggle source
Decide default policy platform based upon platform_family
@return [String] Policy platform name
# File lib/chef/resource/selinux_state.rb, line 156 def default_policy_platform case node["platform_family"] when "rhel", "fedora", "amazon" "targeted" when "debian" "default" end end