Skip to content

Instantly share code, notes, and snippets.

@handyman5
handyman5 / ceph.pp
Created August 24, 2012 17:18
Using Puppet to configure ceph.conf with Augeas and the Samba lens
augeas { "ceph.conf":
lens => "Samba.lns",
incl => "/etc/ceph/ceph.conf",
changes => [
"set target[. = '${name}'] '${name}'",
"set target[. = '${name}']/${key} '${value}'",
]
}
@handyman5
handyman5 / add_to_cobbler.py
Created March 19, 2012 19:54
Use of the Cobbler API
cobbler_api = ServerProxy("http://cobbler/cobbler_api")
token = cobbler_api.login("USERNAME", "PASSWORD")
asset_list = ["server01", "server02"]
for system in asset_list:
print "Managing system %s" % system
print "System name is %s" % a
try:
handle = cobbler_api.get_system_handle(a, token)
@handyman5
handyman5 / ds_downloader.py
Created February 17, 2012 01:07
Daily Show downloader
#!/usr/bin/python
#
# Notes
# -----
# This script depends on rtmpdump and mythnettv; specify their paths in the global variables below.
# If you don't need mythnettv support, leave it undefined (MYTHNETTV="") and the script will skip that step
# svn update -r275 # rtmpdump
#
import re,threading
@handyman5
handyman5 / git-find.sh
Created October 25, 2011 16:28
Search for a filename in all git branches
#!/bin/bash
#LOC=refs/remotes/origin
LOC=refs/heads
for branch in `git for-each-ref --format="%(refname)" $LOC`; do
found=$(git ls-tree -r --name-only $branch | grep "$1")
if [ $? -eq 0 ]; then
echo ${branch#$LOC/}:
for f in $found; do
@handyman5
handyman5 / grid.rb
Created October 13, 2011 08:51
Custom fact for figuring out which Ganglia grid a given host goes in
#!/usr/bin/ruby
# grid.rb
def find_grid(hostname)
grid = "admin"
if hostname =~ (/^(build|launch|util)\d{1,4}/)
grid = $1
elsif hostname =~ (/^www\d{1,4}/)
grid = "web"
end
for hb in `git branch -r | egrep -v "(modules|HEAD|>)" | cut -f2 -d/`; do for rm in `git branch -r | grep modules | cut -f3 -d/`; do r=`git rev-list -n1 remotes/origin/modules/$rm`; m=`git log --oneline remotes/origin/$hb -- modules/${rm}/manifests/init.pp | head -n1 | awk '{print $1}'`; if [[ -n "$m" ]]; then k=`git rev-list -n1 --parents $m | awk '{print $3}'`; if [[ "$r" != "$k" && -n "$k" ]]; then echo $hb $rm; git log --oneline $k..$r | while read z; do echo -n " $z"; echo; done; fi; fi; done; done