Skip to content

Instantly share code, notes, and snippets.

View jtimberman's full-sized avatar
🚀

Joshua Timberman jtimberman

🚀
View GitHub Profile
@jtimberman
jtimberman / cookbook_check.rb
Created May 3, 2012 18:06
Check the cookbooks are frozen and specified in non development environments
if node.chef_environment != 'development'
cookbooks = {}
node.cookbook_collection.values.each {|c| cookbooks[c.name.to_s] = c.version.to_s }
# See https://github.com/danryan/spice
r = gem_package "spice" do
version "0.8.0"
end
r.run_action(:install)
@jtimberman
jtimberman / client.rb
Created March 2, 2012 17:58 — forked from fnichol/macosx_bootstrap.sh
Mac OS X 10.7 (Lion) Bootstrapping
ssl_verify_mode :verify_peer
ssl_ca_file CA_FILE
log_level :info
log_location STDOUT
chef_server_url 'SERVER_URL'
validation_client_name 'ORGNAME-validator'
node_name 'NODE_NAME'
base_dir = "#{ENV['HOME']}/.chef"
@jtimberman
jtimberman / rename-node.rb
Created March 2, 2012 07:47 — forked from mpasternacki/rename-node.rb
A knife exec script to change Chef node's name.
#!./bin/knife exec
# A knife exec script to change chef node's name, preserving all the attributes.
#
# Usage: knife exec rename-node.rb old-name new-name
#
# Script retrieves the Node object, changes its 'name' attribute,
# creates new Node object with updated name and rest of attributes
# untouched. Then it deletes old Node and Client objects from
# database, and logs into the server to update it:
@jtimberman
jtimberman / chef-ec2.rake
Created September 7, 2011 03:24 — forked from apsoto/chef-ec2.rake
Chef EC2 Node Cleanup task
namespace :ec2 do
# setup chef config
# assumes this file is sibling to .chef dir, ex: CHEF_REPO/tasks
config = File.join(File.dirname(__FILE__), '..', '.chef', 'knife.rb')
Chef::Config.from_file(config)
require 'active_support'
require 'aws'
desc 'Delete any ec2-based chef nodes that no longer exist'
(require 'chef)
(resource :file "/tmp/foo"
:owner "cb"
:action :create)
(resource :file (concatenate 'string "/tmp/" (node-attributes :hostname) "-made-with-lisp")
:action :create)
;; or
@jtimberman
jtimberman / gist:1129051
Created August 6, 2011 05:45 — forked from anonymous/gist:1128513
centos 5.5 bootstrap
bash -c '
<%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
if [ ! -f /usr/bin/chef-client ]; then
wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %>http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh epel-release-5-4.noarch.rpm
wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %>-O /etc/yum.repos.d/aegisco-testing.repo http://testing.aegisco.com/el5/aegisco-testing.repo
yum install -y rubygems rubygem-chef
run_context.resource_collection.each do |r|
r.source_line =~ /cookbooks\/(.+?)\/recipes\/(.+)\.rb:.+/
cookbook_name = $1
recipe_part = $2.gsub('/', "::")
recipe_name = "#{cookbook_name}::#{recipe_part}"
if node[:isolation][:recipes].include?(recipe_name) || node[:isolation][:cookbooks].include?(cookbook_name)
Chef::Log.info("Setting #{r.to_s} to ignore failure, via the isolation cookbook")
r.ignore_failure(true)
end
include_recipe "collectd"
class ChefCollectdPluginReportHandler < Chef::Handler
def report
Chef::Log.info('Running collectd hander')
node[:last_success_time] = Time.now.to_f
node[:error_count_since_success] = 0
node.save
end
end
@jtimberman
jtimberman / http-twiddle.el
Created May 19, 2011 22:55 — forked from skeptomai/http-twiddle.el
Sending signed requests to the Opscode Platform with Emacs and http-twiddle-mode
;;; http-twiddle.el -- send & twiddle & resend HTTP requests
;; This program belongs to the public domain.
;; Author: Luke Gorrie <luke@synap.se>
;; Maintainer: Hasan Veldstra <h@vidiowiki.com>
;; Created: 1 Feb 2006
;; Adapted-By: Hasan Veldstra
;; Adapted-By: Christopher Brown <cb@opscode.com>
;; Version: 1.0
{
"chef": {
"url": "http://localhost:4000",
"webui_enabled": true,
"init_style": "init",
"path": "/var/lib/chef",
"run_path": "/var/run/chef",
"cache_path": "/var/cache/chef",
"backup_path": "/var/lib/chef/backup"
},