-
-
Save griggheo/654102 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'chef' | |
require 'chef/client' | |
require 'chef/run_context' | |
Chef::Config[:solo] = true | |
Chef::Config[:log_level] = :info | |
Chef::Log.level(:info) | |
client = Chef::Client.new | |
client.run_ohai | |
client.build_node | |
run_context = Chef::RunContext.new(client.node, Chef::CookbookCollection.new(Chef::CookbookLoader.new)) | |
# Use resources directly | |
Chef::Resource::Execute.new("echo foo", run_context).run_action(:run) | |
# Build a recipe programatically, and execute it | |
recipe = Chef::Recipe.new("adhoc", "default", run_context) | |
recipe.execute "echo bar" | |
recipe.package "mysql" do | |
action :uninstall | |
end | |
Chef::Runner.new(run_context).converge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment