Created
June 27, 2012 22:30
-
-
Save ahamid/3007309 to your computer and use it in GitHub Desktop.
chef restorecon helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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