Last active
August 29, 2015 14:07
-
-
Save zuazo/623d1cfcdc2ab2e00356 to your computer and use it in GitHub Desktop.
Chef examples for recipe_block and recipe_fork implementations
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
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