Skip to content

Instantly share code, notes, and snippets.

@btm
btm / 1-README.txt
Created Nov 9, 2015
chef bootstrap template to use old ohai hostname plugin via custom plugins
View 1-README.txt
This bootstrap template will download the old ohai hostname plugin from github and use it as a custom plugin on bootstrap.
https://github.com/chef/ohai/issues/420
USE:
1. download and place chef-full-old-hostname.erb in ~/.chef/bootstrap/ on your workstation
2. pass "--bootstrap-template chef-full-old-hostname" to your knife bootstrap command
This requires Ohai 8.6.0+, which should be included in Chef 12.4.2+
@btm
btm / report.md
Last active Aug 29, 2015
Chef Client 12.1.0 release post-mortem
View report.md

Post-mortem Report

Post-mortem Facilitator: Bryan McLellan

  1. Failure Happens. Mistakes Happen. This is a blameless Post Mortem.
  2. We assume everyone participating in the project wants to do a good job.
  3. We will not focus on the past events as they pertain to "could've", "should've", etc.
  4. All follow up action items must be actionable and have a participating individuals commitment to implement, design, or otherwise achieve them.

Description

@btm
btm / gist:7cb421f5fe7d1003083a
Created Mar 18, 2015
Chef Postmortem Template
View gist:7cb421f5fe7d1003083a
# INCIDENT DATE - INCIDENT TYPE
## Meeting
#### Waiving meetings
In some cases the IC might determine that a PM meeting for the incident isn't needed.
If the IC decides to waive the meeting please replace the `Meeting` section with a
note indicating the meeting has been waived (example: `Meeting waived: Paul Mooring`)
@btm
btm / wua.rb
Created Oct 27, 2014
Determine if a KB is installed via win32ole on ruby
View wua.rb
# Author:: Bryan McLellan <btm@loftninjas.org>
# Copyright:: Copyright 2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@btm
btm / btm-dsm.log
Last active Aug 29, 2015
DISM API in Ruby via FFI
View btm-dsm.log
From 32bit run:
2014-10-24 16:31:54, Info DISM API: PID=8872 TID=8096 DismApi.dll: - DismInitializeInternal
2014-10-24 16:31:54, Info DISM API: PID=8872 TID=8096 DismApi.dll: <----- Starting DismApi.dll session -----> - DismInitializeInternal
2014-10-24 16:31:54, Info DISM API: PID=8872 TID=8096 DismApi.dll: - DismInitializeInternal
2014-10-24 16:31:54, Info DISM API: PID=8872 TID=8096 DismApi.dll: Version 6.3.9600.17031 - DismInitializeInternal
2014-10-24 16:31:54, Info DISM API: PID=8872 TID=8096 DismApi.dll: Parent process command line: "C:\opscode\chef\embedded\bin\ruby.exe" dism.rb - DismInitializeInter nal
2014-10-24 16:31:54, Info DISM API: PID=8872 TID=8096 Enter DismInitializeInternal - DismInitializeInternal
2014-10-24 16:31:54, Info DISM API: PID=8872 TID=8096 Input parameters: Log
@btm
btm / kb.rb
Last active Aug 29, 2015
Use ruby to search Windows Updates for KB2918614
View kb.rb
require 'rubygems'
require 'win32ole'
kb = "KB2918614"
start_time = Time.now
puts "Starting search for #{kb} at #{start_time}"
update_session = WIN32OLE.new("Microsoft.Update.Session")
update_searcher = update_session.CreateUpdateSearcher
update_searcher.Search('IsHidden=1 and IsInstalled=1')
View gist:7be7c484b8d8ce737441
# Test DNS on Windows
wmi = WmiLite::Wmi.new
host = wmi.first_of('Win32_ComputerSystem')
hostname = "#{host['name']}"
machinename = "#{host['name']}"
x = 0
while x < 10
View output.txt
PS C:\ruby> chef-apply package.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* log[lolwut ruby] action write (skipped due to only_if)
PS C:\ruby> vim .\package.rb
PS C:\ruby> chef-apply package.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* log[lolwut ruby] action write
PS C:\ruby> chef-apply package.rb -l info
[2014-06-26T13:16:07-04:00] INFO: Run List is []
[2014-06-26T13:16:07-04:00] INFO: Run List expands to []
View mdadm.rb
Ohai.plugin(:Mdadm) do
provides 'mdadm'
def create_raid_device_mash(stdout)
device_mash = Mash.new
device_mash[:device_counts] = Mash.new
stdout.each do |line|
case line
when /Version\s+: ([0-9.]+)/
device_mash[:version] = Regexp.last_match[1].to_f
@btm
btm / gist:9532345
Last active Aug 29, 2015
Cookbook Namspacing
View gist:9532345
I wrote this on 2010-10-01, and I've been passing it around as the entry to my opinion on why we need namespacing on the community site. Maybe it's a terrible argument since we haven't implemented it yet, but it's a lot of words that I can save myself from typing over again.
I thought there were tickets or mailing list posts with opposition to namespacing, but I can't find them. Drop them in the comments if you know of any please.
Bryan McLellan <btm@loftninjas.org>
###
Earlier in the week we had a meeting (you guys rock) at HQ about
cookbook workflow and one of the subjects we discussed heavily was
cookbook namespace on the cookbook site. At the end of the meeting I
You can’t perform that action at this time.