diff --git a/REFERENCE.md b/REFERENCE.md index 5315df17..a74ca5b8 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -28,6 +28,7 @@ _Private Classes_ **Resource types** +* [`selinux_clear_context_cache`](#selinux_clear_context_cache): A simple metaresource type that invalidates the SELinux default file context cache when refreshed * [`selinux_fcontext`](#selinux_fcontext): Manage SELinux fcontext definitions. You should use selinux::fcontext instead of this directly. * [`selinux_fcontext_equivalence`](#selinux_fcontext_equivalence): Manage SELinux fcontext equivalence definitions. You should use selinux::fcontext instead of this directly. * [`selinux_permissive`](#selinux_permissive): Manage SELinux permissive types. @@ -629,6 +630,30 @@ Default value: `undef` ## Resource types +### selinux_clear_context_cache + +A simple metaresource type that invalidates the SELinux default file context cache when refreshed + +#### Examples + +##### Using the type + +```puppet +package {'foo': ensure => installed } +~> selinux_clear_context_cache {'clear the selinux cache after installing foo':} +-> Class['foo::config'] +``` + +#### Parameters + +The following parameters are available in the `selinux_clear_context_cache` type. + +##### `name` + +namevar + +Arbitary name of the resource instance. Only used for uniqueness. + ### selinux_fcontext Manage SELinux fcontext definitions. You should use selinux::fcontext instead of this directly. diff --git a/lib/puppet/type/selinux_clear_context_cache.rb b/lib/puppet/type/selinux_clear_context_cache.rb new file mode 100644 index 00000000..dbd99d05 --- /dev/null +++ b/lib/puppet/type/selinux_clear_context_cache.rb @@ -0,0 +1,25 @@ +require 'puppet/util/selinux' + +Puppet::Type.newtype(:selinux_clear_context_cache) do + desc <<-DOC + @summary + A simple metaresource type that invalidates the SELinux default file context cache when refreshed. + + @example Using the type + package {'foo': ensure => installed } + ~> selinux_clear_context_cache {'clear the selinux cache after installing foo':} + -> Class['foo::config'] + + DOC + newparam :name do + desc 'Arbitary name of the resource instance. Only used for uniqueness.' + isnamevar + end + + def refresh + return unless Puppet::Util::SELinux.selinux_support? + + Puppet.debug 'Clearing Selinux default file context cache' + Selinux.matchpathcon_fini + end +end