The term ‘cloud‘ is bandied about quite readily these days. To my mind there is one operating system that can actually be called a ‘cloud operating system‘ – SmartOS. I’ll dedicate another post to the differences that distinguish SmartOS from other OS in this ‘cloud’ space, but for now, take my word for it 🙂

I’m going to be setting up a medium sized infrastructure based on Joyentsmartmachines‘ – which you can think of as non-Global zones (for those from the Solaris world).

So, let’s get started.

First, we create our smartmachine – I’ve opted for a 2vCPU and 2GB machine for now, I can easily resize as required in the future thanks to SmartOS. Once I’ve logged in I make sure my base OS is up to date:

pkgin -fy update && pkgin -fy upgrade

This should pull down anything needs upgrading and leave you with a nice new smartmachine ready to roll.

Now, handily the chaps at Joyent have provided a quick guide to install CFEngine which I’ll be basing this tutorial around at this stage. It’s pretty basic but it get’s you to a good place to move forward from. Bear in mind that it seems to be geared toward installing a Global Zone within the Joyent SDC product.

First we need to install some pre-req’s using the pkgin installation system on smartmachines:

pkgin in gcc47 gmake tokyocabinet openssl pcre
export PATH=/opt/local/bin:/opt/local/sbin:/opt/local/gcc47/bin:$PATH

With those out of the way, let’s get the latest source and get it built:

cd /tmp
curl -k -o cfengine-3.5.1.tar.gz ''
gtar xfvz cfengine-3.5.1.tar.gz

This next step strays from the Joyent tutorial as we specify the working directory for CFEngine3 – a good idea IMHO.

cd cfengine-3.5.1

Whilst compiling this for ouselves, one of my engineers found a small bug as documented in – follow the advice therein for the fix.

Now issue the following command – all on one line:

CPPFLAGS="-I/opt/local/include" LDFLAGS="-L/opt/local/lib -R/opt/local/lib" ./configure --prefix=/opt/sfw/cfengine3 --enable-static --with-workdir=/var/cfengine

Now make and install CFEngine3

gmake install

You need to give it’s default policy files. These would normally live in /var/cfengine/masterfiles but with the source install, they get dumped in /opt/cfengine3/share/CoreBase – so go ahead and

cp -R /opt/sfw/cfengine3/share/CoreBase/* /opt/sfw/cfengine3/var/cfengine/masterfiles/

Now take a look in /opt/sfw/cfengine3/var/cfengine/masterfiles/ and in particular at the ‘acl => slist‘ clause.

Make sure that includes the network or IP of the install machine itself. Once you’re happy with that clause we can go ahead and bootstrap :

/opt/sfw/cfengine3/bin/cf-agent --bootstrap XXX.XXX.XXX.XXX

If no errors occur you will get a ‘Bootstrap completed’ message and you’re away!

That’s it – you’ve installed and got the hub to bootstrap.

Now comes the hard bits – the configuration!