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
@gondoi
gondoi / install.sh
Created July 25, 2012 17:08
random host choice
hostlist=("http://chef.rckspc.com" "http://s3.amazonaws.com")
# Get command line arguments
while getopts sarv: opt
do
case "$opt" in
v) version="$OPTARG";;
s) use_shell=1;;
a) test -n "$host" && echo "Host already set to ${host}" || host="${hostlist[1]}";;
r) test -n "$host" && echo "Host already set to ${host}" || host="${hostlist[0]}";;
@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)
@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 / attributes.rb
Created August 4, 2011 17:21
nil or not to nil
default[:username][:password] = nil
@gondoi
gondoi / attribute.rb
Created August 2, 2011 16:19
grab kernel version
default[:kernel][:newinstall] = "default"
@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 / 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 / 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
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 / 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)