So, I just finished a course in London by these guys (www.opscode.com) which was awesome. They have a really cool platform that allows you to manage your infrastructure as code, by writing ‘recipes‘ and uploading them into ‘cookbooks‘ on the managed platform – defining amongst many other things ‘this is what I want my sever to look like’, and “these are the steps I need to take to make this environment 100% reproduceable with no deviation from its first incarnation to its last”.
You can then run one-liners to run up your entire infrastructure either locally with a tool like Vagrant or on a cloud provider like AWS EC2 and Rackspace. – If you havent already, grab yourself an account and give it a try, you can run up to 5 clients/nodes at no monthly cost.
As you may have guessed this relies on a successful install of Ruby and Ruby gems and Fog (amongst other gems) on a local machine or designated management server, to allow you to communicate with the platform.
This worked really well on OSX 10.5, but I had really bad problems after getting a newer Mac with 10.6.6 on it. I found that by default when I tried to install Ruby the newer OSX 10.6.6 compiler was automatically detecting that it was capable of comiling as x84_64, so was downloading/compiling/installing a 64bit version of Ruby.
I tried to do a fat Ruby install of that both supported x86_64 and i386 but this didnt seem to work properly in 10.6.6 at the moment.
In itself this wasnt a problem until I came to use some of the gems that I need to communicate with the Opscode platform, I still havent confirmed if this is due to them only working on i386 version of Ruby or some issue with running different architectures under RVM. However I found that some of the gems failed to work on the x86_64 version of Ruby, even if I then installed a 32bit version, I’m guessing this is something to do with symlinking inside RVM.
Anyway, I thought some other people might find the steps I had to take helpful and hopefully save them wasted time.
To start with I installed the latest version of Xcode available on the Apple Developer site.
then I installed Git and grabbed RVM which allows me to run multiple version of Ruby on the same machine.
I grabbed it from here, http://rvm.beginrescueend.com by running the following:
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-latest )
then I added this to my .bashrc
[[ -s “$HOME/.rvm/scripts/rvm” ]] && . “$HOME/.rvm/scripts/rvm”
and reloaded Terminal
Then I grabbed the iconv gem and made sure it was available for one of the later versions of Ruby.
rvm package install iconv
Once I had done this I was ready to actually install a version of Ruby that was happy to run all of the gems I needed for Chef and Vagrant. As you will see I did this by forcing the architecture of the Ruby install to be i386
rvm_archflags=”-arch i386″ CFLAGS=”-arch i386″ LDFLAGS=”-arch i386″ rvm install 1.9.2 -C –with-iconv-dir=$HOME/.rvm/usr –patch osx-arch-fix
If I didnt include iconv, it appeared that the build had worked, until I came to use “knife”, which gave me a horrible stack trace about it not being able to solve some things ruby was unhappy about.
Once I had finished with this a quick “rvm list” showed me that the 32bit install of ruby was successful =>ruby-1.9.2-p136 [ i386 ]
Then I installed Rubygems 1.3.7 and ran “gem install iconv” and “gem install chef”
“gem install net-ssh net-ssh-multi fog highline rb-appscript gem-man virtualbox vagrant”
So from this point on, assuming you have an Opscode account and all of the above, you can start doing stuff like:
"knife ec2 server create -i ami-id -G AWSdefaultsecuritygroup -Z AWSZONE --region AWSREGION -f m1.instancetype -S <ec2account> -I ec2account.pem -x ubuntu"
Or bring up a test environment following the simple instructions:
$ vagrant box add base http://files.vagrantup.com/lucid32.box $ vagrant init $ vagrant up $ vagrant ssh
Loads more really good info available at http://vagrantup.com
Hope you find it useful….