Skip to content

Instantly share code, notes, and snippets.

@cliffdickerson
cliffdickerson / build_chef_0.8
Created January 20, 2010 02:00 — forked from jasherai/build_chef_0.8
Chef .8 on ec2
# ec2 ami-1515f67c
sudo sed -i 's/universe/multiverse universe/' /etc/apt/sources.list
sudo apt-get update
sudo apt-get install -y ruby ruby1.8-dev libopenssl-ruby1.8 rdoc ri irb build-essential wget ssl-cert rubygems git-core rake librspec-ruby libxml-ruby thin couchdb
sudo gem sources -a http://gems.opscode.com
sudo gem sources -a http://gemcutter.org # for nanite
sudo gem install cucumber merb-core nanite jeweler uuidtools json --no-ri --no-rdoc
mkdir ~/src
cd ~/src
git clone git://github.com/opscode/chef.git
@cliffdickerson
cliffdickerson / shef.rb
Created January 20, 2010 17:03 — forked from danielsdeleo/shef.rb
Shef - chef in irb
$ bin/shef
Loading Node Data
Ohai2u!
chef > recipe
=> :recipe
chef:recipe > file "/tmp/foo"
=> #<Chef::Resource::File:0x1c3cd2c @provider=nil, @not_if=nil, @params={}, @recipe_name=nil, @action="create", @source_line="/Users/danielsdeleo/ruby/shef/(irb) line 2", @actions={}, @ignore_failure=false, @name="/tmp/foo", @cookbook_name=nil, @enclosing_provider=nil, @resource_name=:file, @before=nil, @supports={}, @backup=5, @allowed_actions=[:nothing, :create, :delete, :touch, :create_if_missing], @path="/tmp/foo", @only_if=nil, @noop=nil, @updated=false, @node=eigenstate.local, @collection=#<Chef::ResourceCollection:0x1c4f328 @insert_after_idx=nil, @resources=[#<Chef::Resource::File:0x1c3cd2c ...>], @resources_by_name={"file[/tmp/foo]"=>0}>>
chef:recipe > run_chef
[Tue, 03 Nov 2009 22:16:27 -0700] DEBUG: Processing file[/tmp/foo]
[Tue, 03 Nov 2009 22:16:27 -0700] DEBUG: file[/tmp/foo] using Chef::Provider::File
@cliffdickerson
cliffdickerson / gist:282007
Created January 20, 2010 17:07
chef client requirments
abstract (1.0.0)
amqp (0.6.5)
chef (0.8.0)
deep_merge (0.1.0)
erubis (2.6.5)
eventmachine (0.12.10)
extlib (0.9.13)
json (1.1.9)
mixlib-authentication (1.0.0)
mixlib-cli (1.0.4)
user "dbcache" do
action :create
comment "cache"
home "/home/dbcache"
supports :managed_home => true
system true
end
FATAL: Failed to read the private key /home/deploy/Documents/chef-repo/.chef/deploy.pem: #<Errno::ENOENT: No such file or directory - /home/deploy/Documents/chef-repo/.chef/deploy.pem>, /Library/Ruby/Gems/1.8/gems/chef-0.9.8/lib/chef/rest/auth_credentials.rb:59:in `read'/Library/Ruby/Gems/1.8/gems/chef-0.9.8/lib/chef/rest/auth_credentials.rb:59:in `load_signing_key'/Library/Ruby/Gems/1.8/gems/chef-0.9.8/lib/chef/rest/auth_credentials.rb:33:in `initialize'/Library/Ruby/Gems/1.8/gems/chef-0.9.8/lib/chef/rest.rb:48:in `new'/Library/Ruby/Gems/1.8/gems/chef-0.9.8/lib/chef/rest.rb:48:in `initialize'/Library/Ruby/Gems/1.8/gems/chef-0.9.8/lib/chef/role.rb:83:in `new'/Library/Ruby/Gems/1.8/gems/chef-0.9.8/lib/chef/role.rb:83:in `chef_server_rest'/Library/Ruby/Gems/1.8/gems/chef-0.9.8/lib/chef/role.rb:227:in `save'/Library/Ruby/Gems/1.8/gems/chef-0.9.8/lib/chef/knife/role_from_file.rb:32:in `run'/Library/Ruby/Gems/1.8/gems/chef-0.9.8/lib/chef/knife.rb:127:in `run'/Library/Ruby/Gems/1.8/gems/chef-0.9.8/lib/chef/applicat
net-ssh (2.0.23, 2.0.4, 1.1.4)
net-ssh-gateway (1.0.0)
net-ssh-multi (1.0.1)
calculon:chef-repo cdickerson$ knife ssh "role:base" uptime
/Users/cdickerson/.gem/ruby/1.8/gems/net-ssh-2.0.23/lib/net/ssh/transport/session.rb:65:in `initialize': getaddrinfo: nodename nor servname provided, or not known (SocketError)
from /Library/Ruby/Gems/1.8/gems/net-ssh-multi-1.0.1/lib/net/ssh/multi/session_actions.rb:37:in `join'
from /Library/Ruby/Gems/1.8/gems/net-ssh-multi-1.0.1/lib/net/ssh/multi/session_actions.rb:37:in `sessions'
from /Library/Ruby/Gems/1.8/gems/net-ssh-multi-1.0.1/lib/net/ssh/multi/session_actions.rb:37:in `each'
from /Library/Ruby/Gems/1.8/gems/net-ssh-multi-1.0.1/lib/net/ssh/multi/session_actions.rb:37:in `sessions'
calculon:chef-repo cdickerson$ knife search node "role:base" -a fqdn
{
"total": 3,
"rows": [
{
"fqdn": "coherence01",
"id": "coherence01"
},
{
"fqdn": "activemq01",
$ knife ssh -x root "role:base" tmux
/Library/Ruby/Gems/1.8/gems/chef-0.9.8/lib/chef/knife/ssh.rb:230:in `exec': No such file or directory - tmux attach-session -t knife (Errno::ENOENT)
from /Library/Ruby/Gems/1.8/gems/chef-0.9.8/lib/chef/knife/ssh.rb:230:in `tmux'
from /Library/Ruby/Gems/1.8/gems/chef-0.9.8/lib/chef/knife/ssh.rb:260:in `run'
from /Library/Ruby/Gems/1.8/gems/chef-0.9.8/lib/chef/knife.rb:127:in `run'
from /Library/Ruby/Gems/1.8/gems/chef-0.9.8/lib/chef/application/knife.rb:118:in `run'
from /Library/Ruby/Gems/1.8/gems/chef-0.9.8/bin/knife:25
from /usr/bin/knife:19:in `load'
from /usr/bin/knife:19
** Role env_sandcastle1
{
"name": "env_sandcastle1",
"default_attributes": {
"cluster": "sandcastle1"
},
"json_class": "Chef::Role",
"run_list": [
"recipe[base::default]",
"recipe[java::default]"
role :libs, "root@tomcat01", "root@coherence01"
role :db, "root@mysql01"
task :search_libs, :roles => :libs do
run "ls -x1 /usr/lib |grep -i lib"
end
task :count_libs, :roles => :libs do
run "ls -x1 /usr/lib |wc -l"
end