Skip to content

Instantly share code, notes, and snippets.

View miketheman's full-sized avatar
🌴
On vacation

Mike Fiedler miketheman

🌴
On vacation
View GitHub Profile
@miketheman
miketheman / knife-role-loader.rb
Created August 2, 2012 12:40
CHEF-3345 Repro
require 'chef/role'
# The gist files name role-* should be moved into a directory named 'roles'.
role_path = Chef::Config[:role_path] = "./roles"
Dir.glob(File.join(role_path, '*.{rb,json}')) do |role_file|
rolefilename = File.basename(role_file, File.extname(role_file))
role = Chef::Role.from_disk(rolefilename)
@miketheman
miketheman / shell
Created August 15, 2012 20:29
irb output, ref COOK-620
[vagrant@vcent62 ~]$ /opt/chef/embedded/bin/irb
irb(main):001:0> load 'chef-handler-datadog'
LoadError: no such file to load -- chef-handler-datadog
from (irb):1:in `load'
from (irb):1
from /opt/chef/embedded/bin/irb:12:in `<main>'
irb(main):002:0> load 'chef-handler-datadog.rb'
LoadError: no such file to load -- chef-handler-datadog.rb
from (irb):2:in `load'
from (irb):2
@miketheman
miketheman / Gemfile
Last active October 11, 2015 01:48
API-based addition of hooks to your repos
gem "octokit", "~> 1.24.0"
@miketheman
miketheman / fabfile.py
Created November 21, 2012 21:13
fabfile test
from fabric.api import task, run, hosts, sudo, cd, execute
from dogapi.fab import setup
from dogapi.fab import notify
setup(api_key = '<redacted>')
servers = ['root@ec2-50-xxxx.compute-1.amazonaws.com', 'root@ec2-54-xxxx.compute-1.amazonaws.com', 'root@ec2-107-xxxx.compute-1.amazonaws.com']
@notify
@task
@miketheman
miketheman / gist:4169770
Created November 29, 2012 15:24 — forked from grantr/gist:1105416
Chef mysql master/slave recipes
## mysql::master
ruby_block "store_mysql_master_status" do
block do
node.set[:mysql][:master] = true
m = Mysql.new("localhost", "root", node[:mysql][:server_root_password])
m.query("show master status") do |row|
row.each_hash do |h|
node.set[:mysql][:master_file] = h['File']
node.set[:mysql][:master_position] = h['Position']
end
@miketheman
miketheman / chef_10.12_output.txt
Created December 7, 2012 17:57
Reproduction for why-run failure for service resource
[2012-12-07T17:48:39+00:00] INFO: *** Chef 10.12.0 ***
[2012-12-07T17:48:39+00:00] INFO: Setting the run_list to ["recipe[test]"] from JSON
[2012-12-07T17:48:39+00:00] INFO: Run List is [recipe[test]]
[2012-12-07T17:48:39+00:00] INFO: Run List expands to [test]
[2012-12-07T17:48:39+00:00] INFO: Starting Chef Run for localhost
[2012-12-07T17:48:39+00:00] INFO: Running start handlers
[2012-12-07T17:48:39+00:00] INFO: Start handlers complete.
[2012-12-07T17:48:40+00:00] INFO: Processing service[truthiness] action start (test::default line 10)
[2012-12-07T17:48:40+00:00] INFO: Chef Run complete in 1.209708 seconds
[2012-12-07T17:48:40+00:00] INFO: Running report handlers
@miketheman
miketheman / extractor.rb
Created February 20, 2013 04:51
extract mailman member details to CSV
#!/usr/bin/env ruby
require 'csv'
require 'mechanize'
# Tested with Ruby 1.9.3, mechanize 2.5.1 against Mailman version 2.1.14-1
# NOTE: Many lists have a long memebrship list, and this is not currently
# written to accomodate that use case.
# A Mailman setting, `admin_member_chunksize` should allow you to set a longer
# list to be displayed - set it to a value higher to the total list members.
@miketheman
miketheman / stacktrace.out
Created March 22, 2013 05:09
FC003 testing fix errors out
/Users/michael/.rvm/gems/ruby-1.9.3-p385@gemset/bundler/gems/foodcritic-fc5cdf7095e3/lib/foodcritic/chef.rb:58:in `read': No such file or directory - /Users/michael/.rvm/gems/ruby-1.9.3-p385@gemset/bundler/gems/foodcritic-fc5cdf7095e3/lib/foodcritic/../../chef_dsl_metadata.json (Errno::ENOENT)
from /Users/michael/.rvm/gems/ruby-1.9.3-p385@gemset/bundler/gems/foodcritic-fc5cdf7095e3/lib/foodcritic/chef.rb:58:in `load_metadata'
from /Users/michael/.rvm/gems/ruby-1.9.3-p385@gemset/bundler/gems/foodcritic-fc5cdf7095e3/lib/foodcritic/chef.rb:7:in `chef_dsl_methods'
from /Users/michael/.rvm/gems/ruby-1.9.3-p385@gemset/bundler/gems/foodcritic-fc5cdf7095e3/lib/foodcritic/api.rb:399:in `node_method?'
from /Users/michael/.rvm/gems/ruby-1.9.3-p385@gemset/bundler/gems/foodcritic-fc5cdf7095e3/lib/foodcritic/api.rb:480:in `block in vivified_attribute_access'
from /Users/michael/.rvm/gems/ruby-1.9.3-p385@gemset/gems/nokogiri-1.5.6/lib/nokogiri/xml/node_set.rb:239:in `block in each'
from /Users/michael/.rvm/gems/ruby-
@miketheman
miketheman / clformat.rb
Created April 2, 2013 00:24
Auto-create formatted output for Chef Cookbook Changelog
#!/usr/bin/env ruby
require 'date'
require 'jiralicious'
require 'json'
require 'net/https'
require 'uri'
# couldn't quite figure out anonymous API search, so use some method to pass these in here.
username = "myusername"
@miketheman
miketheman / jammers.rb
Created April 10, 2013 10:04
WFTDA Rules calculation for jammers time to serve, according to Rule 7.3 http://wftda.com/rules/20130101/section/7.3
#!/usr/bin/env ruby
# seconds of penalty assignment
# you may pass these in on the commandline so:
# => ./jammers.rb 120 60
jammerA = ARGV[0] ? ARGV[0].to_i : 60
jammerB = ARGV[1] ? ARGV[1].to_i : 60
t = rand(0..jammerA) # => random number between 0 and the maximum time for jammerA