Thursday, November 20, 2008

Puppet and Ralsh

I wrote about puppet and how we're starting to look into it at work a couple of days ago. Yesterday, I learned about an awesome little tool that puppet provides — ralsh, the Ruby Abstraction Layer SHell. To understand just how cool ralsh is, you need to know a little bit more about how puppet works. puppet allows you to describe how a server should 'look' using a declarative language (this is a hurdle a lot of people have problems with, but it's too big to go into here). It then provides the plumbing to enact those declarations on different kinds of servers (OS X, Solaris, Linux, etc.) using its 'Ruby Abstraction Layer'. This allows you to define something like:

user { 'postfix':
    ensure => 'present',
    uid => '51',
    comment => 'Postfix Daemon',
    gid => '51',
    home => '/var/spool/postfix',
    shell => '/bin/false'
}
Which says that you should have a user called postfix, defined as listed. If that user doesn't exist on a system where this is defined, puppet will do the right thing to add them for that kind of box. ralsh provides commandline access to this abstraction layer so that you can query the current configuration of the system, or modify that configuration. When used to query a system ralsh dumps out the current configuration in puppet's declarative language. For example:

$ ralsh service apache2
service { 'apache2':
    ensure => 'running',
    enable => 'false'
}
$
If you think about this for a minute, you'll see that it's a lot cooler than it first appears. Let's say you've got 15 servers that have been 'built' piecemeal. You're really not sure what's installed on them, or what's running there. Now, let's make a bad situation even worse, you need to build out a duplicate set of servers, only you're going to migrate from SLES to debian. ralsh suddenly looks like a great way to audit those servers and to provide a basic puppet configuration to build out the new ones. Don't expect this process to be perfect — debian and SLES name their packages differently enough, for example, that you're going to have to sort some things out by hand. It's a great way to start though. puppet and ralsh look like great tools to help you get out the door before five.

1 comment:

stochasticresonance said...

Ralsh makes me almost feel like a sysadmin...

We call it the 'Resource Abstraction Layer SHell', but we love Ruby enough to support the alternative acronymn.