Skip to content

Instantly share code, notes, and snippets.

View apsoto's full-sized avatar

Alex Soto apsoto

  • San Francisco, CA
View GitHub Profile
@apsoto
apsoto / .autotest
Created October 24, 2011 23:12 — forked from alainravet/.autotest
~/autotest config file
#autotest configuration
#
require 'redgreen/autotest'
require 'autotest/timestamp'
# ####################
# GROWL CONFIG
# ####################
@apsoto
apsoto / rspec-syntax-cheat-sheet.rb
Created October 19, 2011 22:25 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@apsoto
apsoto / ebs_raid.rb
Created September 2, 2011 06:34 — forked from tnine/ebs_raid.rb
ebs raid chef code
include Opscode::Aws::Ec2
# Auto locates and attached ebs devices based on the data bag they reside in. The following test cases need to be performed. Currently limited to 15 drives for the raid due to the drive mount point seek iteration logic. This could be fixed to include more than 15 mount points.
# Create multiple resources with new node: PASS
#
# Re-attach multiple resources after a reboot: PASS
#
# Create resources across 2 runs. First run creates first raid set, second run re-attaches then creates: PASS
#
@apsoto
apsoto / knife cli without the cli.rb
Created April 11, 2011 03:41 — forked from hedgehog/knife cli without the cli.rb
Use Knife without shelling out
class KnifeCliTemplate
include Mixlib::CLI
end
data = {...}
KnifeCliTemplate.option(:config_file, :long => '--file FILE', :default => '/etc/chef/knife.rb')
KnifeCliTemplate.option(:no_editor, :long => "--no-editor", :boolean => true)
args = ['client', 'create', data[:name], '--file', data[:file], '--no-editor' ]
args << '--admin' if data[:admin]
::Chef::Knife.run(args,KnifeCliTemplate.options)
@apsoto
apsoto / base.rb
Created March 7, 2011 18:11 — forked from jtimberman/base.rb
a sample base chef role
name "base"
description "Baseline configuration for all systems."
run_list(
"recipe[ohai]",
"recipe[chef-client::delete_validation]",
"recipe[chef-client]",
"recipe[zsh]",
"recipe[git]",
"recipe[users]",
@apsoto
apsoto / update_dns.rake
Created February 1, 2011 16:29 — forked from mpasternacki/update_dns.rake
Rake task to update Amazon Route53 DNS from by Chef node search
# -*- ruby -*-
# Needs following parameters configured in rake.rb:
# DNS_DOMAIN: domain for which to set entries, including trailing dot
# (e.g. "example.com.")
# DNS_ATTRIBUTE: attribute containing hostname to CNAME to, defaults
# to 'fqdn'; for EC2, use "ec2.public_hostname"
# DNS_ENTRIES: hash mapping hostname to node search query,
# e.g. {'buildbot' => 'recipes:buildbot', 'monitoring' =>
# 'roles:monitoring'}
@apsoto
apsoto / opscode-backup.rb
Created December 2, 2010 06:26 — forked from adamhjk/opscode-backup.rb
Chef Attributes Backup: recipes are in VCS, but attributes aren't....
require 'chef'
require 'chef/node'
class Opscode
class Backup
attr_accessor :backup_dir
def initialize(backup_dir, config_file)
@backup_dir = backup_dir
Chef::Config.from_file(config_file)
@apsoto
apsoto / chef check for checkins
Created November 8, 2010 22:50 — forked from paulchoi/chef check for checkins
Script that notifies what chef nodes have not 'checked in' within a certain time period
#!/usr/bin/ruby
# lists hosts whose chef-client hasn't checked in with the server for a while
# how many seconds before we alert
threshold = 3600
# requires that your user account is set up for Chef's "knife" utility
me = ENV["USER"]
@apsoto
apsoto / aws_cf_invalidate.rb
Created October 28, 2010 18:05 — forked from objectoriented/aws_cf_invalidate.rb
simple script to invalidate a list of Amazon Cloudfront files
#! /usr/bin/env ruby
#
require 'rubygems'
require 'hmac-sha1' # on OS X: sudo gem install ruby-hmac
require 'net/https'
require 'base64'
#
# CHANGE ME: S3 access credentials go here, along with CloudFront Distribution ID
#
@apsoto
apsoto / update_cache.rake
Created August 4, 2010 20:53 — forked from mdkent/update_cache.rake
Sync Chef Cookbooks and Roles with Server
#
# Tasks to keep your repository in sync with your Chef Server
#
# Author:: Matthew Kent (<mkent@magoazul.com>)
# Copyright:: Copyright (c) 2010 Matthew Kent
# 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