Skip to content

Instantly share code, notes, and snippets.

View jbz's full-sized avatar

J.B. Zimmerman jbz

View GitHub Profile
domU-12-31-39-13-D8-C1% rsyslogd -v
rsyslogd 5.6.2, compiled with:
FEATURE_REGEXP: Yes
FEATURE_LARGEFILE: No
FEATURE_NETZIP (message compression): Yes
GSSAPI Kerberos 5 support: No
FEATURE_DEBUG (debug build, slow code): No
Atomic operations supported: Yes
Runtime Instrumentation (slow code): No
node[:apt][:repo].each do |repo|
apt_repository repo[:name]
uri repo[:uri]
distribution repo[:dist]
components repo[:component]
action :add
end
end
@jbz
jbz / On the client (default.rb in the cookbook)
Created June 22, 2011 15:14
Client/server config with chef
# Set attribute indicating munin role
node.set["munin"]["node"] = true
# Find available munin servers
available_servers = search(:node, "munin_server:true")
# Install munin plugins
munin_plugin "passenger_memory_stats"
munin_plugin "passenger_status"
@jbz
jbz / gist:1090107
Created July 18, 2011 17:28
Script to parse chef nodes by last-checkin-time
#!/usr/bin/ruby
#
# Filter hosts wose time since last checkin >= X
#
# usage: (process that outputs lines) | filterHosts.rb <#hrs>
# to prune hosts in opscode: knife status *:* | filterHosts.rb <#hrs> | xargs -I % knife node delete % -y
STDIN.each_line {|line|
#split the line by commas, strip whitespace, map to fields
@jbz
jbz / userdata.sh.erb
Created August 2, 2011 20:41
EC2 userdata.sh script to install Chef and register with Chef server
#!/bin/bash
# User data to configure a vanilla Ubuntu EC2 instance.
# Installs chef-client (with minimal dependencies),
# configures chef, and adds roles
test $UID == 0 || (echo "Error: must run as root"; exit 1)
######### STEP 1: OPERATING SYSTEM CONFIGURATION
BOOTLOG="/var/log/bootstrap.log"
@jbz
jbz / rsyslog::client.rb
Created August 8, 2011 18:06
rsyslog remote logging
# Recipe:: client
#
# Copyright 2010, Medidata Solutions Inc.
#
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@jbz
jbz / ebs_raid6_provider.rb
Created September 27, 2011 21:31 — forked from fujin/ebs_raid6_provider.rb
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
@jbz
jbz / ebs_raid.rb
Created September 27, 2011 21:31 — forked from tnine/ebs_raid.rb
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
#
@jbz
jbz / example attribs file
Created January 6, 2012 17:45
Setting up chef-client using userdata bootstrap scripts
{
"run_list": [
"recipe[chef-client::config]",
"recipe[chef-client::service]",
"recipe[chef-client::delete_validation]",
"recipe[runit]",
"role[locke-validation-app]"
],
"chef_client": {
"server_url": "https://api.opscode.com/organizations/mdsol",
@jbz
jbz / deploy_revision before_migrate
Created January 27, 2012 18:29
Bundler error inside deploy_revision before_migrate
before_migrate do
if app['main']['uses_bundler']
link "#{release_path}/vendor/bundle" do
to "#{app['main']['deploy_to']}/shared/vendor_bundle"
end
common_groups = %w{development test cucumber staging production}
execute "bundle install --deployment --without #{(common_groups -([app['main']['rails_env']])).join(' ')}" do
ignore_failure true
cwd release_path
environment ({'LANG' => 'en_US.UTF-8'})