Skip to content

Instantly share code, notes, and snippets.

View spheromak's full-sized avatar
🕵️‍♂️

Jesse Nelson spheromak

🕵️‍♂️
View GitHub Profile
"interfaces": {
"DATA Bond0": {
"mask": "255.255.255.240",
"ip": "10.33.82.84",
"bond": "mode=active-backup miimon=100 updelay=100",
"dev": "bond0"
},
"DATA Bond0-vip": {
@spheromak
spheromak / gist:942898
Created April 26, 2011 19:19
node dumper
Bin="$( readlink -f -- "${0%/*}" )"
# assum bin is in chef_repo so nodes goto ../nodes/*
if [ -d $Bin/../nodes/$node ] ; then
for node in `knife node list -F text | awk -F\" '{print $2}'` ; do
echo "dumping $node"
knife node show $node > $Bin/../nodes/$node.json
done
else
Yum installed and available lists don't have a version of package ruby-oci8
/var/cache/chef/file_cache/cookbooks/helpers/libraries/yum.rb:751:in `load_current_resource'
/usr/local/chef/chef-bundle/ruby/1.9.1/gems/chef-0.9.16/lib/chef/resource.rb:394:in `run_action'
/usr/local/chef/chef-bundle/ruby/1.9.1/gems/chef-0.9.16/lib/chef/runner.rb:53:in `run_action'
/usr/local/chef/chef-bundle/ruby/1.9.1/gems/chef-0.9.16/lib/chef/runner.rb:89:in `block (2 levels) in converge'
/usr/local/chef/chef-bundle/ruby/1.9.1/gems/chef-0.9.16/lib/chef/runner.rb:89:in `each'
/usr/local/chef/chef-bundle/ruby/1.9.1/gems/chef-0.9.16/lib/chef/runner.rb:89:in `block in converge'
/usr/local/chef/chef-bundle/ruby/1.9.1/gems/chef-0.9.16/lib/chef/resource_collection.rb:94:in `block in execute_each_resource'
/usr/local/chef/chef-bundle/ruby/1.9.1/gems/chef-0.9.16/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
/usr/local/chef/chef-bundle/ruby/1.9.1/gems/chef-0.9.16/lib/chef/resource_collection/stepable_iterator.rb:116:in `ca
# is this damn thing already mounted ?
def is_mounted?(device)
check_mount = Chef::ShellOut.new("mount | grep -q '#{device}'")
check_mount.run_command
return true if 0 == check_mount.status
# might as well follow the link like mount does
# recursion is fun
return is_mounted?(Pathname.new(device).realpath.to_s) if File.symlink?(device)
@spheromak
spheromak / ostype.sh
Created July 10, 2011 02:51
OSTYPE Code example
#!/bin/bash
# ^^ yes this isn't os independent
case "$OSTYPE" in
solaris*) echo "SOLARIS" ;;
darwin*) echo "OSX" ;;
linux*) echo "LINUX" ;;
bsd*) echo "BSD" ;;
*) echo "unknown: $OSTYPE" ;;
@spheromak
spheromak / rev.rb
Created July 10, 2011 04:38
rev unix cmd in ruby
#!/usr/bin/env ruby
ARGF.each_line { |e| puts e.chomp.reverse }
@spheromak
spheromak / xen.rb
Created August 11, 2011 19:03
fake a platform in a recipe
Chef::Platform.platforms[:xenserver] = {
:default => {
:service => Chef::Provider::Service::Redhat,
:cron => Chef::Provider::Cron,
:package => Chef::Provider::Package::Yum,
:mdadm => Chef::Provider::Mdadm
}
}
@spheromak
spheromak / recipe.rb
Created September 10, 2011 03:55
ldirectord pub-sub (needs to be abstracted)
package "heartbeat-ldirectord" do
action :install
end
lb = node[:heartbeat][:cluster]
# find all nodes that think they belong to a service
#
@spheromak
spheromak / register_chef.py
Created January 21, 2012 08:56 — forked from Farzy/register_chef.py
Cobler module for Chef
"""
(C) 2010 Pragmatic Source
Farzad FARID <[email protected]>
register_chef.py: Register the server being installed on the Chef server
We assume that the 'knife' is installed locally on the Cobbler server.
Check https://fedorahosted.org/cobbler/wiki/CobblerTriggers for
documentation on Cobbler's triggers and API.
@spheromak
spheromak / cookbook_check.rb
Created March 17, 2012 03:19
Check the cookbooks are frozen and specified in non development environments
if node.chef_environment != 'development'
cookbooks = {}
node.cookbook_collection.values.each {|c| cookbooks[c.name.to_s] = c.version.to_s }
# See https://github.com/danryan/spice
r = gem_package "spice" do
version "0.8.0"
end
r.run_action(:install)