Created
November 25, 2009 20:16
-
-
Save adamhjk/242998 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
template "/etc/sysconfig/chef-client" do | |
.. | |
end | |
ruby_block "restart chef the redhat way" do | |
block do | |
r = Chef::REST.new(Chef::Config[:chef_server_url]) | |
safe_name = node.name.gsub(/\./, '_') | |
begin | |
r.put_rest("nodes/#{safe_name}", node) | |
rescue Net::HTTPServerException => e | |
if e.response.code == "404" | |
r.post_rest("nodes", node) | |
else | |
raise e | |
end | |
end | |
cid = fork | |
if cid # we're the parent | |
Chef::Log.fatal("Restarting!") | |
exit 0 | |
else # we're the child | |
sleep 10 | |
exec("/etc/init.d/chef-client start") | |
end | |
end | |
action :nothing | |
subscribes :create, resources(:template => "/etc/sysconfig/chef-client") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment