Skip to content

Instantly share code, notes, and snippets.

@lusis
lusis / iptables-slack-notify-chef.rb
Created August 19, 2014 13:39
iptables-slack-notify-chef.rb
slack "iptables-rules-changed-#{node.name}" do
message "iptables.sav was updated on #{node.name}! This should be investigated"
icon_url node['chef_client']['handler']['slack']['icon_url']
channel node['chef_client']['handler']['slack']['channel']
username "Chef iptables notifier"
action :nothing
end
template "/etc/iptables.sav" do
owner "root"
#!/usr/bin/ruby
require 'rubygems'
require 'eventmachine'
$done = false
module FdWatcher
def notify_readable
puts "readable event"
begin
#!/usr/bin/ruby
arch, os = RUBY_PLATFORM.split('-')
if os =~ /^darwin/
SYS_poll = 230 # OSX 7 on linux x86_64, 168 on linux i386
# /usr/include/sys/poll.h
# Requestable events. If poll(2) finds any of these set, they are
# copied to revents on return.
POLLIN = 0x0001
#
# Author:: Joshua Timberman <opensource@housepub.org>
# Copyright:: Copyright (c) 2012, Joshua Timberman
# License:: Apache License, Version 2.0
#
# Ohai Plugin: external_ipaddress
#
# Save this to /etc/chef/ohai_plugins/external_ipaddress.rb, then run ohai with:
#
# ohai -d /etc/chef/ohai_plugins external_ipaddress
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
#! /usr/bin/ruby
require 'chef/config'
require 'chef/search/query'
require 'chef/log'
require 'time'
require 'getoptlong'
require "ohai"
RET = {
@fujin
fujin / 8_vol_ebs_stripeset.rb
Created November 24, 2010 21:48
automatic 8 vol ebs LVM2 stripe set (raid0). 256k chunks, 8-way stripe. 65k readahead.
include_recipe "aws"
include_recipe "lvm"
include_recipe "xfs"
esvg = node.elasticsearch.ebs.lvm.volume_group
eslv = node.elasticsearch.ebs.lvm.logical_volume
Chef::Log.info "ElasticSearch: setting up 8 100G EBS volumes"
aws = data_bag_item("aws", node.app_environment)
8.times do |d|
disk = (d == 0 ? "/dev/sdi" : "/dev/sdi#{d}")
#!/usr/bin/env ruby
require 'rubygems'
require 'chef'
require 'chef/client'
require 'chef/run_context'
Chef::Config[:solo] = true
Chef::Config[:log_level] = :info
Chef::Log.level(:info)
@jtimberman
jtimberman / README
Created October 28, 2010 14:09 — forked from kennethkalmer/README
Prototype mysql_grant provider for Chef
Prototype mysql_grant provider for Chef
---------------------------------------
Drop the two files into your mysql cookbook, and experiment with the following examples:
mysql_grant "kenneth" do
action :grant
username "root" # <- User with admin privs
password node[:mysql][:server_root_password]
# Actual grant details
@raggi
raggi / eventmachine_is_web_scale.rb
Created September 1, 2010 01:34
the secrets of the web scale sauce
require 'eventmachine'
EM.run do
SEKRET_SAUCE = EM.attach(
open(RUBY_PLATFORM =~ /mswin|mingw/ ? 'NUL:' : '/dev/null', 'w')
)
EM.start_server('0.0.0.0', 80, Module.new do
def post_init; proxy_incoming_to(SEKRET_SAUCE); end
end)
end