Skip to content

Instantly share code, notes, and snippets.

@ahamid ahamid/restorecon.rb
Created Jun 27, 2012

Embed
What would you like to do?
chef restorecon helper
libraries/restorecon.rb
def restorecon_cmd(path)
%Q(restorecon "#{path}")
end
# restores selinux label for path
def restorecon(path)
execute restorecon_cmd(path) do
action :nothing
end
if block_given?
res = yield path
res && res.notifies(:run, resources(:execute => restorecon_cmd(path)), :immediately)
end
end
def notify_restorecon(path)
# todo: can't the particular restorecon resource just be generated dynamically?
# looks ugly :/ http://comments.gmane.org/gmane.comp.sysutils.chef.user/1982
notifies :run, resources(:execute => restorecon_cmd(path)), :immediately
end
...
restorecon '/etc/smartd.conf' do |path|
cookbook_file path do
source path
owner "root"
group "root"
mode "0644"
notifies :restart, "service[smartd]"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.