Skip to content

Instantly share code, notes, and snippets.

View hh's full-sized avatar

Hippie Hacker hh

View GitHub Profile
@hh
hh / chef-server-ubuntu-natty-userdata.sh
Created July 7, 2011 07:33
Chef Server setup for Ubuntu 11.04/natty on Amazon ec2
#!/bin/bash
#ec2-run-instances --user-data-file chefserver-ec2-userdata.sh -g chef-server --key mykey -t m1.large --instance-initiated-shutdown-behavior terminate ami-1aad5273 | grep INSTANCE | INSTANCE=`cut -f 2` | xargs -I XXX ec2-create-tags XXX --tag Name=chefserver ; sleep 60 ; ec2-describe-instances $INSTANCE | grep INSTANCE | grep running | echo ssh ubuntu@`cut -f 4`
# ami-1aad5273 - ubuntu 11.04 64bit server ebs
# ami-2cc83145 - alestic ubunt 10.04 LTS 32bit server ebs
# ami-2ec83147 - alestic ubunt 10.04 LTS 64bit server ebs
# ami-8e1fece7 - amazon 64 bit ebs
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
set -e -x
# START CHEF BOOSTRAP
@hh
hh / myattempt.sh
Created July 8, 2011 18:59
chef 0.10.2 + knife 0.5.56 doesn't seem to work on 411009282317/RightImage_CentOS_5.4_x64_v5.6.28_EBS
After adding aegisco and updating, there appears to be package conflicts for all the ruby-1.8.7 vs ruby-1.8.5 packages.
$ gem list | grep knife\\\|chef
chef (0.10.2)
knife-ec2 (0.5.6)
#using this ami:
# http://thecloudmarket.com/image/ami-4a24d623--rightimage-centos-5-4-x64-v5-6-28-ebs#/details
$ knife ec2 server create --availability-zone us-east-1a --identity-file ~/mysshkey.pem --image ami-4a24d623 --distro centos5-gems --flavor t1.micro --region us-east-1 --ssh-user root --ssh-key mysshkey -N newserver -V -G servergroup_1,servergroup_1
@hh
hh / chef-client.debug.log
Created July 9, 2011 19:49
chef-client run, logs from server and client... server gives confusing responses
$ chef-client -l debug
[Sat, 09 Jul 2011 19:23:37 +0000] INFO: *** Chef 0.10.2 ***
[Sat, 09 Jul 2011 19:23:37 +0000] DEBUG: Loading plugin os
[Sat, 09 Jul 2011 19:23:37 +0000] DEBUG: Loading plugin kernel
[Sat, 09 Jul 2011 19:23:37 +0000] DEBUG: Loading plugin ruby
[Sat, 09 Jul 2011 19:23:37 +0000] DEBUG: Loading plugin languages
[Sat, 09 Jul 2011 19:23:37 +0000] DEBUG: ---- Begin ruby -e "require 'rbconfig'; puts %Q(platform=#{RUBY_PLATFORM},version=#{RUBY_VERSION},release_date=#{RUBY_RELEASE_DATE},target=#{::Config::CONFIG['target']},target_cpu=#{::Config::CONFIG['target_cpu']},target_vendor=#{::Config::CONFIG['target_vendor']},target_os=#{::Config::CONFIG['target_os']},host=#{::Config::CONFIG['host']},host_cpu=#{::Config::CONFIG['host_cpu']},host_os=#{::Config::CONFIG['host_os']},host_vendor=#{::Config::CONFIG['host_vendor']},bin_dir=#{::Config::CONFIG['bindir']},ruby_bin=#{::File.join(::Config::CONFIG['bindir'], ::Config::CONFIG['ruby_install_name'])},)" STDOUT ----
[Sat, 09 Jul 2011 19:23:37 +0000] DEBUG
@hh
hh / rake log
Created July 25, 2011 04:36
knife-ec2 + databag_dump_load breaks
When I have https://gist.github.com/368740 put in tasks/databag_dump_load.rake AND I use a knife.rb that includes knife[:aws_*] = 'foo' ala http://rubydoc.info/gems/knife-ec2/0.5.6/file/README.rdoc I get errors.
It's interesting that I'm even running rake with --trace and I don't get a stacktrace...
rake --trace
(in /chef-repo)
ERROR: You have an error in your config file /chef-repo/.chef/knife.rb
NoMethodError: undefined method `[]=' for #<Chef::Knife:0x110e7e8>
/home/chris/clients/fanestra/aws/chef-repo/.chef/knife.rb:16:in `from_file'
/home/chris/clients/fanestra/aws/chef-repo/.chef/knife.rb:16:in `from_file'
@hh
hh / rom.etherboot.org down
Created August 5, 2011 18:46
rom.etherboot.org port 80 is down affecting making my own boot.kernel.org.
I'd like to find a way to construct those images from original sources and not depend on the etherboot.org blobs.
$ git clone git://git.etherboot.org/scm/people/pravin/BKO.git
$ cd BKO/install_help
$ ./download_initramfs_images_http.sh
downloading dsl initramfs
--2011-08-06 06:43:17-- http://rom.etherboot.org/share/pravin/BKO///bko/live/dsl/minirt24.gz
Resolving rom.etherboot.org... 140.211.167.171
Connecting to rom.etherboot.org|140.211.167.171|:80... failed: Connection refused.
require 'chef/mixin/shell_out'
require 'chef/log'
require 'chef/provider'
include Chef::Mixin::ShellOut
def action_run
opts = {}
if sentinel_file = @new_resource.creates
if ::File.exists?(sentinel_file)
@hh
hh / remote_file_timestamp_check.rb
Created August 9, 2011 20:42
A remote_file resource that doesn't get downloaded unless the source is newer than the local file
remote_file '/tmp/foo' do
source "http://remote/foo"
action :nothing
end
http_request "HEAD http://remote/foo" do
message ""
url "http://remote/foo"
action :head
if ::File.exists?('/tmp/foo')
@hh
hh / bootstrap.json
Created August 10, 2011 05:26
chef-solo boostrap json
{
"chef_server": {
"server_url": "http://breeze.local:4000",
"webui_enabled": true,
"init_style": "init",
"ssl_req": "/C=NZ/ST=Bay of Plenty/L=Tauranga/O=PassionEngine.org/OU=DevOps/CN=chef.server/[email protected]"
},
"apache": {
"listen_ports": [ "80", "443" ],
"contact": "[email protected]",
@hh
hh / unattended error
Created August 29, 2011 18:11
Unexpected Array at end of list of hashes?
If I comment out https://github.com/passionengine/ii/blob/master/site-cookbooks/unattended/recipes/default.rb#L141 I get the following error
[Tue, 30 Aug 2011 06:08:48 +1200] FATAL: Saving node information to /var/cache/chef/failed-run-data.json
[Tue, 30 Aug 2011 06:08:48 +1200] ERROR: Exception handlers complete
[Tue, 30 Aug 2011 06:08:48 +1200] DEBUG: Re-raising exception: TypeError - Symbol as array index
/var/cache/chef/cookbooks/unattended/recipes/default.rb:142:in `[]'
/var/cache/chef/cookbooks/unattended/recipes/default.rb:142:in `from_file'
/var/cache/chef/cookbooks/unattended/recipes/default.rb:139:in `each'
@hh
hh / chef-client -l debug
Created August 30, 2011 00:02
More debugging
DEBUG: Processing remote_file[DP_Bluetooth_wnt5_x86-32_910.torrent from http://driverpacks.net/driverpacks/windows/xp/x86/bluetooth/9.10/download/torrent] on breeze.local
INFO: Processing remote_file[DP_Bluetooth_wnt5_x86-32_910.torrent from http://driverpacks.net/driverpacks/windows/xp/x86/bluetooth/9.10/download/torrent] action create (unattended::default line 149)
DEBUG: Skipping remote_file[DP_Bluetooth_wnt5_x86-32_910.torrent from http://driverpacks.net/driverpacks/windows/xp/x86/bluetooth/9.10/download/torrent] due to not_if
DEBUG: Processing transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Bluetooth_wnt5_x86-32_910.7z] on breeze.local
INFO: Processing transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Bluetooth_wnt5_x86-32_910.7z] action create (unattended::default line 158)
DEBUG: Caching a copy of torrent file /var/cache/chef/unattended/torrents/DP_Bluetooth_wnt5_x86-32_910.torrent at /var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent