Dec 22, 2011

Simple EC2 Configuration

Over the last few years I've used different approaches to scripting the configuration of my EC2 servers. Recently I discarded a more sophisticated approach for a very simple system.  This is all pretty obvious and I'm sure you'll notice that I stole this directly from RVM but it's working out so well for me I feel compelled to share anyway.

I created a public repository of scripts on Github.  Then, like RVM, I take advantage of the fact that Github allows access to the raw content of the master branch through a fixed url.  This allows me to execute commands like the one below which will run my script for installing the Passenger gem and Apache module:

sudo su -c "bash < <(curl -s https://raw.github.com/mgreenly/aws/master/shared/passenger.sh)" -

Then I combine that with a strict set of conventions; for example I always use Ubuntu so all of my scripts assume they are being executed as the ubuntu user.  This can make some of the scripts a bit tougher to write, for example when you have to sudo su to become postgres to execute database commands, but it makes it easy to execute one script after another in a chain right from your initial login.

This approach may not compare to using tools like Chef or Puppet but I'm finding I really like the simplicity of it.

No comments: