Thursday, June 21, 2012

Weird string encoding issue with ruby net-ldap lib ( 0.3.1 )


Getting this error:

#

The fix was to enable some invalid encoding checks, so here is the original line ( ~23 net-ldap-0.3.1/lib/net/ber/core_ext/string.rb ):

self.encode('UTF-8').force_encoding('ASCII-8BIT')

After some playing around I found that this works rather well:

self.encode('UTF-8', invalid: :replace, undef: :replace, replace: '' ).force_encoding('ASCII-8BIT')

I couldn't find the git source for the 0.3.1 build, so I just downloaded the gem, and created a new repo.

You can download the gem from here:
https://docs.google.com/open?id=0Bwcyw39lMxDSODdpNTdObHk4bXc

I'm going to try to see if I can get this pushed upstream.

Monday, April 9, 2012

Why use git?

After some serious face time with git and a neat little addon called 'git flow' I've come up with my elevator pitch for using git:

  1. Git is designed to get out of your way and let your development awesomeness shine.
  2. Git is fast, mainly because things like history and checkpoints are all stored locally.  Combined with it's compression bits it's actually much faster then most.
  3. Used with 'git flow' it can make complicated branching strategies and bug fix methodologies a breeze in big orgs with many developers across a disparate geographical area.
We use git here @hpcloud, and I can tell you it's amazing to see what these developers and engineers have done with it.

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'