bashinate

System provisioning using BASH (for Debian/Ubuntu based systems)

bashinate

System (single machine focused) provisioning tool using BASH scripting to install required system packages.

NOTE: Bashinate is most definitely a work in progress, and I would only recommend the truly fearless of heart even try using it now :)

Let's look at a simple example of how I personally use bashinate.

Firstly, get a linux box up and running (Ubuntu / Debian variants are probably best supported at the moment) to the point that you can ssh into the box.

For instance, if you are using vagrant to create a local development machine you might do something like:

vagrant init precise64 http://files.vagrantup.com/precise64.box
vagrant up
vagrant ssh

In my own use cases, I tend to run bashinate from the /opt folder so I can keep bashinate managed apps localized. By default, bashinate will place all code into a folder called /opt/local if running as root, or in the ~/.bashinate/install folder if running as a normal user.

So for the sake of convenience, lets head into the /opt folder and create a simple text recipe file there. Unsurprisingly I'm going to ask bashinate to install node and nginx for me:

# initialise versions 
use nginx 1.4.1
use node 0.10.20
 
# bootstrap www -> /opt/local/www 
clone https://bitbucket.org/DamonOehlman/nginx-bootstrap.git www
 
# install stuff based on defined versions (overrides will be accepted also) 
# NOTE: installs are localized (/opt/local/nginx/1.4.1 /opt/local/node/0.10.20) 
nginx
node
 
# install an npm package  
npm install -g deploy
 
# exec a command rather than running a scriptlet 
exec sudo -u git $NODE_PATH/bin/deploy init simple /home/git/projects/test
 
# install an upstart script for nginx 
upstart nginx
 
# restart the nginx service 
exec service nginx restart

NOTE: At present you need a trailing line for the input recipe to work.

Next, wget bashinate and make it executable:

[sudo] wget https://bitbucket.org/DamonOehlman/bashinate/raw/master/bashinate -O bashinate
[sudo] chmod a+x bashinate

Now, simply run bashinate and send your recipe to the stdin of bashinate. In my case, I'm going to run the command as root to ensure my applications get installed into /opt/local:

sudo ./bashinate < recipe

If everything is working, you should see a whole lot of console output and eventually bashinate will finish.

You should now have the following folders under /opt/local:

/opt/local/nginx/1.4.1/
/opt/local/node/0.10.15/

You will notice that both node and nginx have been installed into version specific directories. I believe this is important as it allows you to have two versions of system software present on the one machine and write your application startup scripts to suit.

  • I really should know more about BASH scripting. Implementing this is going to teach me more.
  • Other provisioning systems feel a little-bit heavyweight for my usual needs. I'm sure they have good reason to be, but I really just want a light-weight provisioning helper that still works well with Vagrant.

To install bashinate, you can use the following command in your home directory:

wget https://bitbucket.org/DamonOehlman/bashinate/raw/master/bashinate -O bashinate && chmod a+x bashinate

This will provide you the ability to run bashinate from the command-line:

./bashinate --version

If all is well bashinate should report a version number to you.

I recently needed to rebuild my desktop linux machine to match my shiny new laptop running XMonand and all the cool new things. For an "in anger" use case of bashinate, I decided that I would specify my system layout using bashinate and build the machine using only bashinate.

If you want to provision a system like mine, then you could run the following command on a fresh linux install (after installing bashinate as per the above instructions):

wget -O - https://bitbucket.org/DamonOehlman/bashinate/raw/master/examples/mysystem | ~/bashinate