-
Notifications
You must be signed in to change notification settings - Fork 45
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
Helpers should be in a cookbook-specific module #22
Comments
The first part I agree with - I merged this when I wasn't that familiar with Ruby, and I will seperate to a different module. action :add do
escaped_file_spec = Regexp.escape(new_resource.file_spec)
execute "selinux-fcontext-#{new_resource.secontext}-add" do
extend SELinuxPolicy::Helpers
command lazy { "/usr/sbin/semanage fcontext -a -t #{new_resource.secontext} '#{new_resource.file_spec}' && #{restorecon(new_resource.file_spec)}" }
not_if "/usr/sbin/semanage fcontext -l | grep -P '#{escaped_file_spec}\s.*\ssystem_u:object_r:#{new_resource.secontext}:s0'>/dev/null"
only_if {use_selinux}
end
end |
That doesn't help the situation with the install recipe though. Calling ::Chef::Recipe.send(:include, SELinuxPolicy::Helpers)
include_recipe 'selinux_policy::install' if use_selinux Not quite as nice but you can see this technique referenced here. Using extend SELinuxPolicy::Helpers
include_recipe 'selinux_policy::install' if use_selinux |
I thought you were talking about how I'm using it in my own recipe. I now think you're referring to how you're utilizing it in your own recipes. |
I was referring to how you are using it in your providers but also how it could be used in recipes for other cookbooks. I'll submit a pull request later to ensure we're on the same page. |
Great :)
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I think it is bad practise to define methods directly in
Chef::Provider
. You should define them in a module specific to this cookbook and then include them in the providers. It would also allow community cookbook writers to put this in their recipes.They wouldn't want to include the install recipe unconditionally. If they don't include it at all, the resources will break when SELinux is enabled but the packages are missing.
The text was updated successfully, but these errors were encountered: