Skip to content

Instantly share code, notes, and snippets.

@ranjib
Last active August 29, 2015 14:02
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 ranjib/d3133353ad5a45b16723 to your computer and use it in GitHub Desktop.
Save ranjib/d3133353ad5a45b16723 to your computer and use it in GitHub Desktop.
# stage 0 build your chef gears
require 'chef'
def run_chef(client, item)
client.node.run_list.reset!
client.node.run_list << item
run_context = Chef::RunContext.new(client.node, {}, client.events)
runner = Chef::Runner.new(run_context)
runner.converge
end
Chef::Config.from_file '/etc/chef/client.rb'
client = Chef::Client.new
client.run_ohai
client.load_node
client.build_node
# stage 1 do one set of chef run with recipe foo
run_chef(client, 'recipe[foo]')
# stage 2 do one set of chef run with recipe bar
run_chef(client, 'recipe[bar]')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment