Guest User

Untitled

a guest
Jun 19th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. require 'rubygems'
  4. require 'chef'
  5. require 'chef/client'
  6. require 'chef/run_context'
  7.  
  8. Chef::Config[:solo] = true
  9. Chef::Config[:log_level] = :info
  10. Chef::Log.level(:info)
  11. client = Chef::Client.new
  12. client.run_ohai
  13. client.build_node
  14.  
  15. run_context = Chef::RunContext.new(client.node,
  16. Chef::CookbookCollection.new(Chef::CookbookLoader.new))
  17.  
  18. # Use resources directly
  19. Chef::Resource::Execute.new("echo foo", run_context).run_action(:run)
  20.  
  21. # Build a recipe programatically, and execute it
  22. recipe = Chef::Recipe.new("adhoc", "default", run_context)
  23. recipe.instance_eval <<-EOH
  24. execute "echo bar"
  25. EOH
  26. Chef::Runner.new(run_context).converge
Add Comment
Please, Sign In to add comment