Wednesday, March 28, 2012

"Why git?" series.

Many moons ago a colleague lamented a story to me that went something like this:

SysEngGuy: I asked DeveloperGuy why we should switch to git
Me: Cool, what was his answer?
SysEngGuy: He said it was better, but when I asked him why he just kept saying "because it's better"
Me: But why is it better?
SysEngGuy: Exactly, why would I be compelled to move to something else "just because."

Even if git is super awesome ( which I now know it is ) you can't expect people to switch over unless you sell them on the idea.  Especially when you're dealing with a SysEngGuy that is deeply entrenched in whatever happens to be the "current" way of doing things.

I'm starting a series of posts answering the question of "why is git better?"  My goal here is to both answer the question, and hopefully in doing so, solidify my understanding of git in general.

Tuesday, March 27, 2012

Groovy little script to bootstrap a chef server

This is a groovy little script I wrote to bootstrap a chef-server using a HPCloud node.


#!/bin/bash
##
# Install everything required to get chef-server up

TARGET_IPADDR="15.185.181.148"

SSH_KEY_FILE="/home/krogebry/.ssh/keys/KSONSoftware.pem"

## Fix that idiotic byobu garbage
ssh -i ${SSH_KEY_FILE} ubuntu@${TARGET_IPADDR} 'byobu-disable'

## Fix the ssh behavior so the box is actually usable
ssh -i ${SSH_KEY_FILE} ubuntu@${TARGET_IPADDR} 'sudo cp /home/ubuntu/.ssh/authorized_keys /root/.ssh/'

## Fix that idiotic byobu garbage ( this time for root )
ssh -i ${SSH_KEY_FILE} root@${TARGET_IPADDR} 'byobu-disable'

## Install some packages
ssh -i ${SSH_KEY_FILE} root@${TARGET_IPADDR} 'apt-get update -y'
ssh -i ${SSH_KEY_FILE} root@${TARGET_IPADDR} 'apt-get install -y libgecode-dev g++ make libyaml-dev libssl-dev'
ssh -i ${SSH_KEY_FILE} root@${TARGET_IPADDR} 'apt-get install -y ruby1.9.1 rubygems1.8'

## Fixing ruby
ssh -i ${SSH_KEY_FILE} root@${TARGET_IPADDR} 'update-alternatives --set ruby /usr/bin/ruby1.9.1'

## Update gems
ssh -i ${SSH_KEY_FILE} root@${TARGET_IPADDR} 'gem update'

## Install chef server
ssh -i ${SSH_KEY_FILE} root@${TARGET_IPADDR} 'gem install chef-server json'

## Configure chef
ssh -i ${SSH_KEY_FILE} root@${TARGET_IPADDR} 'mkdir /etc/chef ; ln -s /var/lib/gems/1.8/ /var/lib/gems/1.9.1 ; mkdir /root/.chef'

## Send up some chef-solo bootstrapping bits
scp -i ${SSH_KEY_FILE} files/server/solo.rb root@${TARGET_IPADDR}:/etc/chef
scp -i ${SSH_KEY_FILE} files/server/chef.json root@${TARGET_IPADDR}:/root/
scp -i ${SSH_KEY_FILE} files/server/chef.init root@${TARGET_IPADDR}:/etc/init.d/chef-server
scp -i ${SSH_KEY_FILE} files/server/chef-expander.init root@${TARGET_IPADDR}:/etc/init.d/chef-expander
scp -i ${SSH_KEY_FILE} files/server/chef-solr.init root@${TARGET_IPADDR}:/etc/init.d/chef-solr
scp -i ${SSH_KEY_FILE} files/server/knife.rb root@${TARGET_IPADDR}:/root/.chef/

## Bootstrap chef-server
ssh -i ${SSH_KEY_FILE} root@${TARGET_IPADDR} 'chef-solo -c /etc/chef/solo.rb -j ~/chef.json -r http://s3.amazonaws.com/chef-solo/bootstrap-latest.tar.gz'