Skip to content

Instantly share code, notes, and snippets.

View fujin's full-sized avatar

AJ Christensen fujin

  • Rotorua, New Zealand
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
@jtimberman
jtimberman / gist:639638
Created October 21, 2010 23:56 — forked from btm/gist:639581
different ways to get interface IPs
$ grep 'node\[:network\]\[:interfaces\].' \#chef.log
10:15 < mkent_> node[:network][:interfaces][:eth1][:addresses]
22:24 <+Damm> msf, just pulling in the node[:network][:interfaces] attributes
20:44 < randybias> node[:network][:interfaces][:eth0][:addresses]
09:13 < sinBot> so fujin if I wanted to use that in an erb template, it'd be <%= @node[:network][:interfaces]["en1"]["addresses"].select{address}.flatten.to_str %> ?
12:27 < cwj> if i have an ipv4 ip address set on eth0, will it always be in @node[:network][:interfaces][:eth0][1] ?
02:19 < pluesch0r> however, i don't seem to be able to access @node[:network][:interfaces]... from inside the attributes file.
19:52 <@jtimberman> or node[:network][:interfaces][:eth0][:addresses][0]
20:09 < seryl> well, it's searchable. I'm trying the @node[:network][:interfaces][:eth0][:addresses][0] route, but getting blanks right now, playing around with it in chef solo
20:29 < kallistec> pp node[:network][:interfaces].current_attribute
#!/usr/bin/env ruby
require 'rubygems'
require 'chef'
require 'chef/client'
require 'chef/run_context'
Chef::Config[:solo] = true
Chef::Config[:log_level] = :info
Chef::Log.level(:info)
@fujin
fujin / chef.rb
Created October 30, 2010 02:09
this one gets monkeypatched into a library. I called mine cookbooks/libsonian/libraries/signed_url.rb & chef.rb
class Chef
class Provider
class RemoteS3File < Chef::Provider::RemoteFile
def load_current_resource
super
%w{bucket object_name aws_access_key_id aws_secret_access_key}.map do |attribute|
Chef::Application.fatal! "remote_s3_file: required attr: #{attribute} is nil", -92 if
@new_resource.send(attribute.to_sym).nil?
end
Vagrant::Config.run do |global_config|
aptdir = (ENV['APTCACHE'] or "#{ENV['HOME']}/aptcache/")
checkout = (ENV['COOKBOOKS'] or "#{ENV['HOME']}/openstack-cookbooks")
ip_prefix = (ENV['IP_PREFIX'] or "192.168.76.")
mac_prefix = (ENV['MAC_PREFIX'] or "080027076")
fixed = (ENV['FIXED'] or "10.0.76.0/24")
global_config.vm.define :chef do |config|
suffix = "100"
ip = "#{ip_prefix}#{suffix}"
config.vm.box = "base"
@skeptomai
skeptomai / http-twiddle.el
Created May 19, 2011 21:37
Sending signed requests to the Opscode Platform with Emacs and http-twiddle-mode
;;; http-twiddle.el -- send & twiddle & resend HTTP requests
;; This program belongs to the public domain.
;; Author: Luke Gorrie <[email protected]>
;; Maintainer: Hasan Veldstra <[email protected]>
;; Created: 1 Feb 2006
;; Adapted-By: Hasan Veldstra
;; Adapted-By: Christopher Brown <[email protected]>
;; Version: 1.0
@jtimberman
jtimberman / gist:1040853
Created June 22, 2011 19:07
Ohai plugin to return semantic reference attributes for network addresses
# This might not work on newer (than 0.10.6) versions of Chef.
# Thanks for pointing to my new gist, spkane :)
# https://gist.github.com/1040543
require 'rubygems'
require 'ohai'
o = Ohai::System.new()
o.all_plugins
@rottenbytes
rottenbytes / graphdeps.rb
Created September 6, 2011 07:23
Graph your cookbooks deps
#!/usr/bin/env ruby
cbdir=ARGV[0]
output = "./deps.dot"
puts "Running on #{cbdir}..."
cb_meta = Dir.glob("#{cbdir}/*/metadata.rb")
fp=File.open(output,"w")
@fujin
fujin / graphdeps.rb
Created November 29, 2011 02:41 — forked from rottenbytes/graphdeps.rb
Graph your cookbooks deps
#!/usr/bin/env ruby
cbdir=ARGV[0]
output = "./deps.dot"
puts "Running on #{cbdir}..."
cb_meta = Dir.glob("#{cbdir}/*/metadata.rb")
fp=File.open(output,"w")
@danielsdeleo
danielsdeleo / gist:3063064
Created July 6, 2012 22:17
Knife Role Tree example output
ddeleo@boltzmann chef git:(master)> bin/knife role tree $node_name
top level
|-role[preprod]
| |-recipe[network]
| |-recipe[splunk42]
|-role[mysql-master]
| |-role[base]
| | |-role[platform-annoyances]
| | | |-recipe[platform-specific]
| | | |-recipe[selinux::disabled]