Skip to content

Instantly share code, notes, and snippets.

View cwjohnston's full-sized avatar

Cameron Johnston cwjohnston

View GitHub Profile
service_link 'apache' do
version [node[:apache][:version], node[:apache][:worker]].join('-')
end
directory "/etc/httpd" do
owner "root"
group "root"
mode 0755
action :create
not_if { File.exists?('/etc/httpd') }
@peplin
peplin / recipe.rb
Created July 10, 2010 01:30
S3 File Resource for Chef
# Source accepts the protocol s3:// with the host as the bucket
# access_key_id and secret_access_key are just that
s3_file "/var/bulk/the_file.tar.gz" do
source "s3://your.bucket/the_file.tar.gz"
access_key_id your_key
secret_access_key your_secret
owner "root"
group "root"
mode 0644
end
@jtimberman
jtimberman / gist:548261
Created August 24, 2010 20:32
preseed.cfg for automated installations with chef from apt.opscode.com
# This is the entire preseed config file used on an example Lucid system. See the preseed
# documentation for more information on the options here. This will use US English by default.
#
# https://help.ubuntu.com/10.04/installation-guide/amd64/preseed-contents.html
#
# This preseed will automatically install Ubuntu 10.04 with default options. Understand what
# it is doing before you use it.
#
# Boot Options line:
#
@eykd
eykd / pycache.py
Created October 26, 2010 15:06
A simple script for caching packages on S3 and building simple HTML indices.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""pycache -- cache a python package from PyPI on S3.
A simple script to collect a cache of packages locally and sync them up to an S3 bucket, using directories as namespaces so that different projects can have different dependencies.
This is just about the simplest thing that could possibly work.
"""
import warnings
warnings.filterwarnings('ignore')
@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
@mpasternacki
mpasternacki / update_dns.rake
Created February 1, 2011 13:36
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'}
@tnine
tnine / ebs_raid.rb
Created April 27, 2011 03:03
Ebs raid mounting. Links to this jira issue http://tickets.opscode.com/browse/CHEF-2275
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
# 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
#
@fujin
fujin / ebs_raid6_provider.rb
Created May 8, 2011 03:20
aws_ebs_raid6 lwrp
include Chef::Mixin::Command
action :create do
size = new_resource.size
volumes = new_resource.volumes.times.map{|i| (i == 0 ? "/dev/sdf" : "/dev/sdf#{i}") }
setra = new_resource.blockdev_setra
volume_group = new_resource.volume_group
logical_volume = new_resource.name
mdadm_device = new_resource.mdadm_device
mount_point = new_resource.mount_point
@nstielau
nstielau / set_environment.rb
Created May 9, 2011 00:04
A Knife plugin to set node environment
## Knife plugin to set node environment
# See http://wiki.opscode.com/display/chef/Environments
#
## Install
# Place in .chef/plugins/knife/set_environment.rb
#
## Usage
# Nick-Stielaus-MacBook-Pro:chef-repo nstielau$ knife node set_environment mynode.net my_env
# Looking for mynode.net
# Setting environment to my_env
@nevans
nevans / cidr_to_netmask.rb
Created June 3, 2011 17:19
Just a simple CIDR to netmask conversion
def unpack_ip(packed_ip)
octets = []
4.times do
octet = packed_ip & 0xFF
octets.unshift(octet.to_s)
packed_ip = packed_ip >> 8
end
ip = octets.join('.')
end