Skip to content

Instantly share code, notes, and snippets.

@zuazo
Last active August 29, 2015 14:07
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 zuazo/623d1cfcdc2ab2e00356 to your computer and use it in GitHub Desktop.
Save zuazo/623d1cfcdc2ab2e00356 to your computer and use it in GitHub Desktop.
Chef examples for recipe_block and recipe_fork implementations
def recipe_block_run(&block)
@run_context.resource_collection = Chef::ResourceCollection.new
instance_eval(&block)
Chef::Runner.new(@run_context).converge
end
def recipe_block(description, &block)
recipe = self
ruby_block "recipe_block[#{description}]" do
block do
recipe.instance_eval(&block)
end
end
end
def recipe_fork(description, &block)
block_body = proc do
fork { recipe_block_run(&block) }
end
recipe_block(description, &block_body)
end
recipe_block 'Recipe block test' do
# put your chef resources here
execute 'echo Recipe block test'
end
recipe_fork 'Recipe fork test' do
# put your chef resources here
execute 'echo Recipe fork test'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment