Skip to content

Instantly share code, notes, and snippets.

View fnichol's full-sized avatar

Fletcher Nichol fnichol

View GitHub Profile
#!/usr/bin/env ruby
#^syntax detection
site 'http://community.opscode.com/api/v1'
cookbooks = Dir.glob(File.join('site-cookbooks/*/metadata.*')).map{ |file| File.dirname(file) }
cookbooks.each do |cb|
cookbook File.basename(cb), :path => cb
end
@danielsdeleo
danielsdeleo / apps.md
Created July 31, 2014 19:37
How to Run Custom Apps in ChefDK

Firstly, the primary apps in ChefDK use executables generated by appbundler:

  • chef (chef-client/knife/etc.)
  • berks
  • chef-dk (the chef tool)
  • TK

The appbundler code is here: https://github.com/opscode/appbundler/ and the README explains what it does and why. You can see the executables that appbundler generates in /opt/chefdk/bin (there are other executables in there, but the executables for the primary apps are the appbundler ones).

The primary apps in ChefDK all live in the "apps" directory, in /opt/chefdk/embedded/apps.

@sgoings
sgoings / gist:703966
Created November 17, 2010 20:04
Rspec Tests for SCP upload transfer performance
require 'net/scp'
describe Net::SCP do
def analyze(filename)
file_size = (File.size(filename)/(1024*1024))
puts "Starting transfer of #{filename}"
start_time = Time.now
yield filename
duration = Time.now - start_time
@mm53bar
mm53bar / application_controller.rb
Created December 23, 2010 20:31
Code to roll your own authentication!
class ApplicationController < ActionController::Base
include AuthenticateUser
before_filter :authenticate_user!
end
#
# Cookbook Name:: workstation
# Recipe:: default
#
# Copyright 2010, Joshua Timberman
#
# 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
#
@rcreasey
rcreasey / solo_data_bags.rb
Created May 12, 2011 05:21
Using data bags with chef-solo
From: Brian Akins < brian@akins.org>
To: chef < chef@lists.opscode.com>
Subject: [chef] Data bag implementation for chef-solo
Date: Tue, 1 Feb 2011 10:42:05 -0500
We often use chef-solo for quick testing, etc. This is our extremely simple implementation of data bags for chef-solo. Add "data_bag_path /some/dir/data_bags" to your solo.rb and add this into your libraries:
if Chef::Config[:solo]
class Chef
module Mixin
module Language
@fnichol
fnichol / knife.rb
Created September 17, 2011 19:26
My Generic Chef knife.rb
### Chef Solo
#
#
### Opscode Hosted Chef Server
#
# export KNIFE_USER="jdoe"
# export KNIFE_ORGNAME="acmeco"
#
# * Your Opscode client key should be at `~/.chef.d/opscode-jdoe.pem`.
# * Your Opscode validation key should be at `~/.chef.d/opscode-acmeco-validator.pem`.
@fnichol
fnichol / README.md
Created November 21, 2011 16:41 — forked from xiplias/esca.rb
Campfire script for Pomodoro

Description

Simple [Campfire][campfire_app] notifier for the [Pomodoro app][pomodoro_app], based off [xiplias][xiplias]'s [gist][parent_gist].

The script reads a JSON file to match a leading pomodoro tag with a Campfire account. In the example file there is a campfire account with tag called "wco". Any pomodoros starting with "wco-", "wco_", "wco," will use the "wco" campfire account. If no campfire account exists with the leading tag, nothing will be broadcast.

@mperham
mperham / gist:1831203
Created February 14, 2012 22:39
Campfire deploy announcements
# Put this at the bottom of your config/deploy.rb
# Requires config file ~/.campfire.yml with your API token from
# your Campfire "My Info" page:
#
# token: lkjsadfsaduoi1u31oui3eh1kj2h
# roomid: 123456
# subdomain: acmeco
class Room
attr_accessor :config
@iafonov
iafonov / gist:3349101
Created August 14, 2012 13:07
Chef git templates

Chef git templates

Chef should allow creating cookbooks and chef-repo using templates. It should maintain the ability to create artifacts offline but a special switch could be supplied to knife wich will tell it to clone the remote repository rather than create a hardcoded structure.

Use cases:

knife chef-repo create --template https://github.com/fnichol/chef-bootstrap-repo knife cookbook create ntpd --template https://github.com/test/cookbook-with-minitest-and-berkshelf

Basically knife should clone the repository into folder and remove .git directory.