Skip to content

Instantly share code, notes, and snippets.

@adamhjk
Created November 25, 2009 20:16
Show Gist options
  • Save adamhjk/242998 to your computer and use it in GitHub Desktop.
Save adamhjk/242998 to your computer and use it in GitHub Desktop.
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