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 / gist:1174606
Created August 26, 2011 22:43
knife cookbooks site install apt
$ knife cookbook site install apt -V
Installing apt to ./cookbooks
Checking out the master branch.
Creating pristine copy branch chef-vendor-apt
Downloading apt from the cookbooks site at version 1.1.2 to ./cookbooks/apt.tar.gz
Cookbook saved: ./cookbooks/apt.tar.gz
Removing pre-existing version.
Uncompressing apt version ./cookbooks.
ERROR: Chef::Exceptions::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of tar zxvf ./cookbooks/apt.tar.gz ----
@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 / gist:788873
Created January 20, 2011 22:53
activemq runit variant
runit_service "activemq" do
env({'ACTIVEMQ_OPTS' => '-Xmx4096M' })
end
@apsoto
apsoto / gist:787162
Created January 20, 2011 00:14
ohai java info
o.data[:languages][:java]
=> {"runtime"=>{"name"=>"Java(TM) SE Runtime Environment", "build"=>"1.6.0_22-b04"}, "version"=>"1.6.0_22"}
irb(main):016:0>
@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 / knife-config.staging.rb
Created November 22, 2010 19:21
Managing different chef environments using git branches
log_level :debug
log_location STDOUT
validation_client_name 'channels-staging-validator'
validation_key './.chef/channels-staging-validator.pem'
chef_server_url 'https://api.opscode.com/organizations/channels-staging'
cache_options( :path => './.chef/channels-staging-checksums' )
@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
#