Skip to content

Instantly share code, notes, and snippets.

View juliandunn's full-sized avatar

Julian C. Dunn juliandunn

View GitHub Profile
@juliandunn
juliandunn / default.rb
Created April 29, 2014 00:22
Illustration of stubbing other things, like guard expressions, in ChefSpec
service 'true_guard' do
action :start
only_if { File.exist?('/tmp/trueguard') }
end
service 'false_guard' do
action :start
not_if { File.exist?('/tmp/falseguard') }
end
@juliandunn
juliandunn / test-kitchen-generated-freebsd92-vagrantfile.txt
Created March 11, 2014 19:36
test-kitchen-generated Vagrantfile for FreeBSD
Vagrant.configure("2") do |c|
c.vm.box = "opscode-freebsd-9.2"
c.vm.box_url = "https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_freebsd-9.2_chef-provisionerless.box"
c.vm.hostname = "portsnap-freebsd-92.vagrantup.com"
c.vm.synced_folder ".", "/vagrant", disabled: true
c.vm.provider :virtualbox do |p|
p.customize ["modifyvm", :id, "--memory", "256"]
end
end
@juliandunn
juliandunn / kitchen-freebsd92-portsnap.txt
Created March 11, 2014 17:39
Proving that all the pieces work without Bash on FreeBSD.
This file has been truncated, but you can view the full file.
borkbork ~/devel/gh/juliandunn/freebsd (master *)$ kitchen test portsnap-freebsd-92 --destroy=never
-----> Starting Kitchen (v1.2.1)
-----> Cleaning up any prior instances of <portsnap-freebsd-92>
-----> Destroying <portsnap-freebsd-92>...
Finished destroying <portsnap-freebsd-92> (0m0.00s).
-----> Testing <portsnap-freebsd-92>
-----> Creating <portsnap-freebsd-92>...
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'opscode-freebsd-9.2'...
[default] Matching MAC address for NAT networking...
#!/usr/bin/ruby
require 'ruby_kml'
# http://www.boutell.com/zipcodes/
# read zipcodes.csv into hash, get lat/long for each zip
zipcodes = {}
File.open('zipcode.csv', 'r') do |file|
file.each_line do |line|
entry = line.gsub('"','').split(",")
#!/bin/bash
echo "First password prompt is for sudo"
# create the user
sudo dscl localhost -create /Local/Default/Users/amanda
sudo dscl localhost -create /Local/Default/Users/amanda RecordName amanda
sudo dscl localhost -create /Local/Default/Users/amanda UserShell /bin/bash
sudo dscl localhost -create /Local/Default/Users/amanda RealName "Amanda backup user"
sudo dscl localhost -create /Local/Default/Users/amanda UniqueID 5000
@juliandunn
juliandunn / test-kitchen-freebsd.txt
Created December 12, 2013 23:33
Test Kitchen works with FreeBSD!
borkbork ~/devel/gh/juliandunn/chef-client (fix-kitchen-yml)$ kitchen test config-freebsd-92
-----> Starting Kitchen (v1.1.1)
-----> Cleaning up any prior instances of <config-freebsd-92>
-----> Destroying <config-freebsd-92>...
Finished destroying <config-freebsd-92> (0m0.00s).
-----> Testing <config-freebsd-92>
-----> Creating <config-freebsd-92>...
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'opscode-freebsd-9.2'...
[default] Matching MAC address for NAT networking...
@juliandunn
juliandunn / json-gem-formatting-breakage.md
Last active December 31, 2015 01:29
json gem formatting breakage

Why is the JSON output in my knife commands suddenly all on one line?

A while ago, the output from my knife commands (e.g. "knife node edit" -- which you should never use in production, by the way) changed from something like this:

{
  "name": "i-27c2205f",
  "chef_environment": "_default",
  "normal": {
@juliandunn
juliandunn / fucking-json-gem.txt
Created December 11, 2013 17:20
Not this bullshit again
irb(main):001:0> require 'chefspec'
=> true
irb(main):002:0> require 'chefspec/berkshelf'
RuntimeError: Berkshelf not found! You must have the berkshelf installed on your system before requiring chefspec/berkshelf. Install berkshelf by running:
gem install berkshelf
or add Berkshelf to your Gemfile:
gem 'berkshelf'
borkbork ~/devel/gh/juliandunn/chef-client (fix-kitchen-yml *)$ kitchen test config-freebsd-92
-----> Starting Kitchen (v1.1.0)
-----> Cleaning up any prior instances of <config-freebsd-92>
-----> Destroying <config-freebsd-92>...
Finished destroying <config-freebsd-92> (0m0.00s).
-----> Testing <config-freebsd-92>
-----> Creating <config-freebsd-92>...
Bringing machine 'default' up with 'virtualbox' provider...
[default] Box 'opscode-freebsd-9.2' was not found. Fetching box from specified URL for
the provider 'virtualbox'. Note that if the URL does not have

recipes/default.rb

template 'C:\CURTIME.TXT' do
  source "curtime.txt.erb"
  action :create
  notifies :restart, "service[w32time]"
end