Skip to content

Instantly share code, notes, and snippets.


Joshua Timberman jtimberman

View GitHub Profile
jtimberman / knife.rb
Created Feb 1, 2012
Commented knife.rb for all the things
View knife.rb
# Knife Configuration File.
# This is a Ruby DSL to set configuration parameters for Knife's
# general options. The default location for this file is
# ~/.chef/knife.rb. If multiple Chef repositories are used,
# per-repository configuration files can be created. A per repository
# configuration file must be .chef/knife.rb in the base directory of
# the Chef repository. For example,
# ~/Development/chef-repo/.chef/knife.rb
View .zshrc
# Joshua Timberman <>
# My .zshrc, modified from:
# $Id: .zshrc,v 1.1 2006/04/19 22:08:04 adam Exp $
# Adam's zshrc - <>
# Stolen entirely from --
# Andy's zshrc <>
jtimberman / ec2_client.rb
Created Mar 2, 2010
generate user_data.json with knife, launch instance with it and magic!
View ec2_client.rb
# Author:: Adam Jacob <>
# Author:: Joshua Timberman <>
# Copyright 2009-2010, Opscode, Inc
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
jtimberman / knife.rb
Created Oct 3, 2011
First stab at a knife.rb with comments for all the various knife plugins we publish
View knife.rb
log_level :info
log_location STDOUT
node_name ENV['USER']
client_key "#{ENV['HOME']}/.chef/#{ENV['USER']}.pem"
validation_client_name 'chef-validator'
validation_key '/etc/chef/validation.pem'
chef_server_url 'http://localhost:4000'
cache_type 'BasicFile'
cache_options( :path => "#{ENV['HOME']}/.chef/checksums" )
cookbook_path [ '/var/chef/cookbooks' ]
jtimberman / command line
Created Oct 31, 2009 — forked from auxesis/command line
shell script testing with cucumber
View command line
bin/cucumber --require features/ features/example-script.feature
jtimberman / client.rb
Created Mar 2, 2012 — forked from fnichol/
Mac OS X 10.7 (Lion) Bootstrapping
View client.rb
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 / default_spec.rb
Created May 10, 2013
this is cookbooks/java/spec/default_spec.rb. Then install the chefspec gem and run rspec. (yay!)
View default_spec.rb
require 'chefspec'
describe 'java::default' do
let (:chef_run) {'java::default') }
it 'should include the openjdk recipe by default' do
chef_run.should include_recipe 'java::openjdk'
context 'windows' do
let(:chef_run) do
jtimberman /
Created May 8, 2020
Reminder that Chef has an rich set of data and an API

Did you know that every time the chef-client runs, it knows what time it is, and it stores that value as a node attribute, ohai_time? Did you know that you can use this value for searching a Chef Infra Server? It's a Unix Epoch!

For example, let's look for the nodes that were updated in the last 10-15 minutes:

now=$(date +%s)
range_start=$(expr $now - 900)
range_end=$(expr $now - 600)

knife search node "ohai_time:[$range_start TO $range_end]" -a ohai_time -F json


You'll need to have a system running that is accessible through a DNS record. It should have access to the public Habitat depot, so it can download the required packages.

You'll need to register an OAuth application for GitHub. You need the client ID and client secret that are created for the application later in this guide. Your system needs to have access to so that it can authenticate.

Your system also needs to have an FQDN that can be resolved, for example This will be used in your OAuth application's "Authorization Callback URL." For this example, use The /#/sign-in is required.

Operating System

jtimberman / default.rb
Created Jun 7, 2010
Chef version checking in recipes
View default.rb
# access chef's version constant directly
if Chef::VERSION.to_f >= 0.8
# 0.8+ only features here
# node attribute, requires ohai version 0.5.4:
if node.chef_packages.chef.version.to_f >= 0.8
# 0.8+ only features here