Skip to content

Instantly share code, notes, and snippets.

View binamov's full-sized avatar

Bakh Inamov binamov

  • Google Cloud
  • SF Bay Area
View GitHub Profile
#!/usr/bin/env ruby
def find_deps(cookbook_dir)
nel = Hash.new { |h, k| h[k] = [] }
Dir.glob("#{cookbook_dir}/*/").each do |r|
deps_for(r, nel)
end
nel
end
@webframp
webframp / reposplit.sh
Created December 15, 2011 03:37
Bash script to split multi-cookbook repo into individual git repos, retaining history, and uploads to github
#!/bin/bash
for cookbook_dir in `ls community-cookbooks`; do
if [ $cookbook_dir != 'readme.md' ]; then
REPO=chef-$cookbook_dir
git clone --no-hardlinks ./community-cookbooks/ $REPO
SAVEDIR=`pwd`
cd $REPO
git filter-branch --subdirectory-filter $cookbook_dir HEAD -- --all --prune-empty
git reset --hard
@scarolan
scarolan / user_data.ps1
Last active December 22, 2015 10:19
Powershell script to be used with the AWS user_data field, to prepare Windows instances for bootstrapping with the knife tool.
<powershell>
# Set the administrator password
$ComputerName = $env:COMPUTERNAME
$user = [adsi]"WinNT://$ComputerName/Administrator,user"
$user.setpassword("******")
# Get the instance ready for our bootstrapper, commands courtesy of Julian Dunn
winrm quickconfig -q
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="300"}'
powershell_script "Install IIS" do
code "add-windowsfeature Web-Server"
action :run
end
service "w3svc" do
action [:enable, :start ]
end
# cookbook_file "c:\\inetpub\\wwwroot\\Default.htm" do
"[System Access]" | out-file c:\delete.cfg
"PasswordComplexity = 0" | out-file c:\delete.cfg -append
"[Version]" | out-file c:\delete.cfg -append
'signature="$CHICAGO$"' | out-file c:\delete.cfg -append
secedit /configure /db C:\Windows\security\new.sdb /cfg c:\delete.cfg /areas SECURITYPOLICY
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@jehiah
jehiah / notify.sh
Created January 19, 2014 21:45
email notify at system boot time
#!/bin/bash
#
# *************************************************
# chkconfig: 2345 99 99
# description: notify email address on system boot.
# *************************************************
# Installing:
# 1) save as /etc/rc.d/init.d/notify
# 2) set the desired email address in "MAILADD" variable
# 3) chmod a+w /etc/rc.d/init.d/notify
@charlesjohnson
charlesjohnson / gemrc.erb
Last active August 29, 2015 14:05
Use a .gemrc file with Omnibus chef-client
:sources:
- http://<%= node['gem_file']['host'] %>:<%= node['gem_file']['port'] %>/

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().

@charlesjohnson
charlesjohnson / Kitchen.yml driver stanza.yml
Created October 23, 2014 19:28
Use something other than omnibus to install Chef Client
---
driver:
name: vagrant
provision_command: rpm -ihv uri://to.chef.rpm
require_chef_omnibus: false