Skip to content

Instantly share code, notes, and snippets.

@elebertus
Created November 8, 2012 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elebertus/4036273 to your computer and use it in GitHub Desktop.
Save elebertus/4036273 to your computer and use it in GitHub Desktop.
action :start_stop do
begin
@new_resource.start_service(node[:service_status][:state])
rescue
Chef::Log.warn("----------")
Chef::Log.warn("Application default state is missing. Defaulting to start the service. If this cluster or service should not automatically start defined node[:service_status][:state]")
Chef::Log.warn("----------")
@new_resource.start_service("start")
@new_resource.env_state("start")
end
begin
@new_resource.start_service("#{node[:some_application][:"#{@new_resource.name}"][:state]}")
rescue
Chef::Log.warn("----------")
Chef::Log.warn("Node override state is missing. Using environment service state settings. Define node[:some_application][:#{@new_resource.name}][:state] if you need to control a single node's state")
Chef::Log.warn("----------")
@new_resource.node_state(@new_resource.env_state)
end
if @new_resource.start_service == "start"
service "#{@new_resource.name}" do
action :start
end
elsif @new_resource.start_service == "stop"
service "#{@new_resource.name}" do
action :stop
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment