@darph writes here. Rarely.

R(?)ex on OS X

Holy Complete And Utter Lack Of Updates, Batman!

I've started using R(?)ex to manage a couple of servers that I maintain. R(?)ex (Remote EXecution) is a "Deployment & Configuration Management" tool, similar to Puppet, Chef, Ansible or Salt, but written in Perl. I like it, because it is an extremely simple, yet powerful tool. There's no daemon or external server required, no YAML-based DSL to fight and no extensive dependencies to install - every distribution that I had to touch had Perl. A few optional dependencies (crypto-libraries to generate passwords) can be installed with Rex itself.

The fact that Perl is syntactically close to Ruby is also helpful (you just keep adding dollars and semicolons until it works). And it's just code.

OS X ships with Perl 5.18, but without its package manager CPAN. In this article I will explain how I installed a newer version of Perl using Perlbrew and got Rex installed and ready to roll. Perlbrew itself is a version manager not unlike rbenv.

By default Perlbrew follows standard Perl conventions and installs perl into ~/perl5, a location which sticks out like a sore thumb. I wanted it to install to ~/.perl5, just as rbenv does with ~/.rbenv. To do this add the following to your ~/.bash_profile.

# ~/.bash_profile
export PERLBREW_ROOT="$HOME/.perl5/perlbrew"

if [ -f $PERLBREW_ROOT/etc/bashrc ]; then
  source $PERLBREW_ROOT/etc/bashrc

Reload your config, then install perlbrew itself:

$ source ~/.bash_profile
$ curl -L http://install.perlbrew.pl | bash
$ source ~/.bash_profile # again to load it

Perlbrew is now ready to install the latest stable version of Perl. --switch will cause Perlbrew to immediately activate newly installed version. The -j flag will cause Perlbrew to utilize all available cores, but it will still take a while, so go grab a cold one while it's brewing:

$ perlbrew install -j `sysctl -n hw.physicalcpu` --switch stable

Once this is done, you can check that it successfully switched to this version:

$ perlbrew use
Currently using perl-5.22.1

Perl's package manager is CPAN, and we'll use that to install R(?)ex and its (local) dependencies, but we need to install it first:

$ curl -L https://cpanmin.us | perl - App::cpanminus
$ cpanm Rex

If all went well, we should be good to start managing our servers:

$ rex -v
(R)?ex 1.3.3
$ rexify myfirstserver

More soon!™