Skip to content

Instantly share code, notes, and snippets.

View whiteley's full-sized avatar

Matt Whiteley whiteley

View GitHub Profile
#!/usr/bin/env knife exec
# A knife exec script to change chef node's name, preserving all the attributes.
#
# Usage: knife exec rename-node.rb old-name new-name
#
# Script retrieves the Node object, changes its 'name' attribute,
# creates new Node object with updated name and rest of attributes
# untouched. Then it deletes old Node and Client objects from
# database, and logs into the server to update it:
import os
import pprint
import fnmatch
import time
import subprocess
def find_services_needing_restart():
services = {}
pids = [ f for f in os.listdir('/proc') if f.isdigit() and os.path.isdir(os.path.join('/proc', f)) ]
@whiteley
whiteley / create_mcf.sh
Last active December 13, 2015 18:18 — forked from drnic/create_mcf.sh
#!/usr/bin/env bash
set -e # exit immediately if a simple command exits with a non-zero status
set -u # report the usage of uninitialized variables
STEMCELLS_DIR=${STEMCELLS_DIR:-/var/vcap/store/stemcells}
RELEASES_DIR=${REPOS_DIR:-/var/vcap/store/releases}
REPOS_DIR=${REPOS_DIR:-/var/vcap/store/repos}
CF_RELEASE_BRANCH=${CF_RELEASE_BRANCH:-staging}
@whiteley
whiteley / gist:4053040
Created November 10, 2012 23:59 — forked from grantr/gist:1105416
Chef mysql master/slave recipes
## mysql::master
ruby_block "store_mysql_master_status" do
block do
node.set[:mysql][:master] = true
m = Mysql.new("localhost", "root", node[:mysql][:server_root_password])
m.query("show master status") do |row|
row.each_hash do |h|
node.set[:mysql][:master_file] = h['File']
node.set[:mysql][:master_position] = h['Position']
end
@whiteley
whiteley / add-image-cloud-config.txt
Created November 3, 2012 03:17 — forked from smoser/add-image-cloud-config.txt
user-data script for easy usage of cloud-publish-ubuntu.
#!/bin/sh
#
# This is a user-data script that launches an instance, and then sets
# it up to be able to publish a daily or released build as easy as
# possible. use:
# euca-run-instances <some-ami> --user-data-file <this file> --key mykey
#
# Then, copy credentials to the instance and read 'README'
#
# gist: https://gist.github.com/1231973
@whiteley
whiteley / spaceutil.c
Created May 3, 2012 23:22 — forked from camillol/spaceutil.c
Two ways of messing with spaces
#include <unistd.h>
#include <CoreServices/CoreServices.h>
#include <ApplicationServices/ApplicationServices.h>
typedef int CGSConnection;
extern OSStatus CGSGetWorkspace(const CGSConnection cid, int *workspace);
extern OSStatus CGSSetWorkspace(const CGSConnection cid, int workspace);
extern CGSConnection _CGSDefaultConnection(void);
int get_space_id(void);
@whiteley
whiteley / gist:1190230
Created September 2, 2011 23:50 — forked from voodootikigod/gist:1155790
PyCodeConf Ticket Give-away
Day job: System Architect at WordStream
Favorite Python project: Fabric
Favorite Conference: WWDC
Python Experience Level: intermediate