Skip to content

Instantly share code, notes, and snippets.

@handyman5
handyman5 / add_to_cobbler.py
Created Mar 19, 2012
Use of the Cobbler API
View add_to_cobbler.py
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 / ceph.pp
Created Aug 24, 2012
Using Puppet to configure ceph.conf with Augeas and the Samba lens
View ceph.pp
augeas { "ceph.conf":
lens => "Samba.lns",
incl => "/etc/ceph/ceph.conf",
changes => [
"set target[. = '${name}'] '${name}'",
"set target[. = '${name}']/${key} '${value}'",
]
}
@handyman5
handyman5 / ds_downloader.py
Created Feb 17, 2012
Daily Show downloader
View ds_downloader.py
#!/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 Oct 25, 2011
Search for a filename in all git branches
View git-find.sh
#!/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 Oct 13, 2011
Custom fact for figuring out which Ganglia grid a given host goes in
View grid.rb
#!/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
View show-out-of-date.sh
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