Created
April 15, 2011 13:59
-
-
Save jtimberman/921743 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
# Use Chef resources in an application via solo mode. | |
# Could also be configured in client mode, and then use a server. | |
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, nil) | |
p = Chef::Resource::Package.new("apache2", run_context) | |
p.run_action("create") | |
s = Chef::Resource::Service.new("apache2", run_context) | |
s.supports(:status => true) | |
s.run_action(:start) | |
f = Chef::Resource::File.new("/etc/apache2/apache2.conf", run_context) | |
f.owner("root") | |
f.group("root") | |
f.mode(0644) | |
f.run_action(:create) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment