Skip to content

Instantly share code, notes, and snippets.

A Quick Tour of A Chef Client Run Internals

Dan DeLeo appeared on the FoodFightShow some time ago to walk through "what a Chef run really does". I expanded on these remarks in my personal investigation.

/usr/bin/chef-client

  • bin/chef-client creates a new Chef::Application::Client (subclass of Chef::Application which sets up common things like loggers across chef-client, chef-solo, knife, etc.) then jump to:

  • lib/chef/client.rb

  • application classes create a new Chef::Client object, which calls initialize().

#!/usr/bin/env ruby
require 'rubygems'
require 'chef/knife'
Chef::Config.from_file(File.join(Chef::Knife.chef_config_dir, 'knife.rb'))
rest = Chef::REST.new(Chef::Config[:chef_server_url])
Chef::Node.list.each do |node|
%w{read update delete grant}.each do |perm|
@stephenlauck
stephenlauck / joyent-smartos.erb
Created June 26, 2012 22:57 — forked from benjaminws/joyent-smartos.erb
joyent-smartos.erb
# shove this in ~/.chef/bootstrap/joyent-smartos.erb
# run knife bootstrap <hostname> -d joyent-smartos
# works with joyent images:
# 01b2c898-945f-11e1-a523-af1afbe22822 smartos 1.6.3 smartos smartmachine
# f9e4be48-9466-11e1-bc41-9f993f5dff36 smartos64 1.6.3 smartos smartmachine
bash -c '
if [ ! -f /opt/local/bin/chef-client ]; then
pkgin -f update
pkgin -y install gcc-compiler gcc-runtime gcc-tools scmgit-base scmgit-docs gmake ruby193-base ruby193-yajl-ruby