Skip to content

Instantly share code, notes, and snippets.

View hh's full-sized avatar

Hippie Hacker hh

View GitHub Profile
@jtimberman
jtimberman / rename-node.rb
Created March 2, 2012 07:47 — forked from mpasternacki/rename-node.rb
A knife exec script to change Chef node's name.
#!./bin/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:
@apsoto
apsoto / chef-ec2.rake
Created September 5, 2011 05:20
Chef EC2 Node Cleanup task
namespace :ec2 do
# setup chef config
#
config = File.join(File.dirname(__FILE__), '..', '.chef', 'knife.rb')
Chef::Config.from_file(config)
load_gem_or_report(%w{aws})
desc 'Delete any ec2-based chef nodes that no longer exist'
task :cleanup_nodes do
@charles-dyfis-net
charles-dyfis-net / definition.rb
Created July 24, 2011 19:33
CentOS-6.0 (i386) + RBEL Chef veewee definition
Veewee::Session.declare( {
:cpu_count => '1', :memory_size=> '384',
:disk_size => '10140', :disk_format => 'VDI',
:os_type_id => 'RedHat',
:iso_file => "CentOS-6.0-i386-bin-DVD.iso", :iso_src => "", :iso_md5 => "d7e57d6edaca1556d5bad2fa88602309", :iso_download_timeout => 1000,
:boot_wait => "10",:boot_cmd_sequence => ['<Esc>', 'linux text ks=http://%IP%:%PORT%/ks.cfg<Enter>'],
:kickstart_port => "7122", :kickstart_timeout => 10000,:kickstart_file => "ks.cfg",
:ssh_login_timeout => "100",:ssh_user => "vagrant", :ssh_password => "vagrant",:ssh_key => "",
:ssh_host_port => "7222", :ssh_guest_port => "22",
:sudo_cmd => "echo '%p'|sudo -S sh '%f'",
z = 3 * 0x41662d2d * 123750872726249
o = []
puts z.to_s(16)
while z != 0
# let's eat through z one byte at a time
l = z >>4 &0xf #shift right then AND with 16 to get the character
r = z &0xf #just AND with 16 to get the XORed with l position in the array
o[r^l]=(l + 97).chr #put the character in the correct spot in the array
@someara
someara / gist:673693
Created November 12, 2010 03:40
chef hostname
bash -c '
echo <%= @config[:chef_node_name] %> > /tmp/chef_node_name
cat /tmp/chef_node_name | cut -d. -f1 > /tmp/proper_hostname
cat /tmp/chef_node_name | cut -d. -f2 | tr -d "\n" > /tmp/proper_dnsdomainname
echo -n "." >> /tmp/proper_dnsdomainname
cat /tmp/chef_node_name | cut -d. -f3 >> /tmp/proper_dnsdomainname
IPV4ADDR=`ip addr | grep eth0 | grep "inet " | cut -d " " -f 6 | cut -d \/ -f 1`
#!/usr/bin/env ruby
def find_deps(cookbook_dir)
nel = Hash.new { |h, k| h[k] = [] }
Dir.glob("#{cookbook_dir}/*/").each do |r|
deps_for(r, nel)
end
nel
end