Skip to content

Instantly share code, notes, and snippets.

@spheromak
Created December 9, 2014 20:13
Show Gist options
  • Save spheromak/6ee97d558c2598ca86bc to your computer and use it in GitHub Desktop.
Save spheromak/6ee97d558c2598ca86bc to your computer and use it in GitHub Desktop.
# create_service builds a service resource we can notify in the given context
def create_service(context=nil)
ctx ||= @run_context
begin # this avoids resource cloning/recreation
ctx.resource_collection.find( "service[#{new_resource.name}]" )
rescue Chef::Exceptions::ResourceNotFound
Chef::Log.info 'Creating service resource'
s = Chef::Resource::Service.new(new_resource.name, ctx)
s.action :nothing
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment