Skip to content

Instantly share code, notes, and snippets.

View gondoi's full-sized avatar
🏠
Working from home

BK Box gondoi

🏠
Working from home
View GitHub Profile
[Tue, 04 Jan 2011 20:39:33 +0000] ERROR: Re-raising exception: NameError - uninitialized constant Sys
/tmp/chef-solo/cookbooks/rackspace/libraries/proctable.rb:25:in `getProcPid'
/tmp/chef-solo/cookbooks/rackspace/definitions/proc.rb:26:in `block in from_file'
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/mixin/recipe_definition_dsl_core.rb:50:in `instance_eval'
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/mixin/recipe_definition_dsl_core.rb:50:in `method_missing'
/tmp/chef-solo/cookbooks/rackspace/recipes/mckick.rb:16:in `from_file'
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/mixin/from_file.rb:30:in `instance_eval'
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/mixin/from_file.rb:30:in `from_file'
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/cookbook_version.rb:337:in `load_recipe'
/opt/ruby/lib/ruby/gems/chef-0.9.8/lib/chef/mixin/language_include_recipe.rb:40:in `block in include_recipe'
@gondoi
gondoi / library_proctable.rb
Created January 4, 2011 22:32
attempting to add gem
begin
require 'sys/proctable'
rescue LoadError
Chef::Log.warn("Missing gem 'sys-proctable'")
end
require 'timeout'
module Rackspace
def self.getProcPid(name)
class File
def flocked? &block
status = flock LOCK_EX|LOCK_NB
case status
when false
return true
when 0
begin
block ? block.call : false
ensure
@gondoi
gondoi / flocked.rb
Created January 13, 2011 19:42
function to check for a read or write lock
require 'fcntl'
class File
def flocked? &block
flockstruct = [Fcntl::F_RDLCK, 0, 0, 0, 0].pack("ssqqi")
fcntl Fcntl::F_GETLK, flockstruct
status = flockstruct.unpack("ssqqi")[0]
case status
when Fcntl::F_UNLCK
return false
@gondoi
gondoi / monkey.rb
Created January 18, 2011 17:49
monkey patch for apt lock files
require 'chef/provider/package/apt'
class Chef
class Provider
class Package
class Apt
class Safe < Chef::Provider::Package::Apt
def install_package(name, version)
Rackspace::Locks.wait_on_lock(new_resource.timeout)
run_command_with_systems_locale(
@gondoi
gondoi / ck.rb
Created January 26, 2011 16:31
install repo then package
execute "yum check-update" do
action :nothing
end
template "/etc/yum.repos.d/cloudkick.repo" do
mode "0644"
source "cloudkick.repo.erb"
notifies :run, resources(:execute => "yum check-update"), :immediately
end
@gondoi
gondoi / attribute.rb
Created August 2, 2011 16:19
grab kernel version
default[:kernel][:newinstall] = "default"
@gondoi
gondoi / attributes.rb
Created August 4, 2011 17:21
nil or not to nil
default[:username][:password] = nil
@gondoi
gondoi / chef.py
Created March 27, 2012 02:23
pychef pseudo code
from pychef import Node
n = Node.init("foo")
n["mysql"]["tunable"]["key_buffer_size"] = "64M"
# or
attributes = { "mysql" : { "tunable" : { "key_buffer_size" : "64M" } } }
n.add_override(attributes)
run_list = "role[bigrole], recipe[chef-client::service]"
@gondoi
gondoi / error.out
Created June 27, 2012 19:44
httplib errors
Creating debian-6.0.1-i686/chef-full-0.10.10-1-debian-6.0.1-i686.sh on Cloud Files
Traceback (most recent call last):
File "shearline.py", line 21, in <module>
cf_object.send(item)
File "/Library/Python/2.7/site-packages/cloudfiles/utils.py", line 45, in decorator
return f(*args, **kwargs)
File "/Library/Python/2.7/site-packages/cloudfiles/storage_object.py", line 509, in send
http.send(chunk)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 773, in send
self.sock.sendall(data)