Fabtools - Tomcat - fast provisioning

April 25, 2014 by johny

As every other developer I’m a fun of easy developer life. I wish all open source projects could be build right away without any previous database or ldap mocking setup. Just fire it right away! That is why I like Vagrant so much.

Vagrant with puppet manifests [chef|ansible|bash] might help to completely separate your local development environment from office network. From now on you can work from the basement without network connection - is’t that sweet? (You might just need to mock company’s ldap server).

The main benefit of Vagranfile (Vagrant’s setup file) is that you can keep it as a code in your favorite VCS. Each team member will build his own local developement environment from scratch. You don’t need to distribute huge .vmdk files anymore.

Fabric is great python tool that helps you to automate many tedious tasks: copy files from one to another host, link, create users, replace configurations etc.

Fabtools is a natural extension of Fabric possibilities. The idea behind it - is comparable to that from puppet and chef. It might be considered as another provisioner.

In current 0.18 release of fabtools you are be able to find tomcat module which will help you to automatically provision virtual machine on you computer with apache tomcat server within few minutes.

You might need to install

sudo apt-get install python-pip
  1. Vagrant
  2. Oracle VirtualBox
  3. Fabric
  4. Fabtools

last two you on ubuntu can simply type in terminal:

pip install fabric
pip install fabtools

Example

All you have to do is to create fabfile.py in your directory with vagranfile. For apache tomcat server you need java first.

from fabtools import require, tomcat
from fabtools.vagrant import vagrant

@task
def provision():
    require.oracle_jdk.installed(version='7u55-b13')
    require.tomcat.installed('7.0.53')

or go and clone my github repo, navigate to tomcat and:

fab vagrant provision
vagrant ssh

As puppet manifest, fabtools fabfiles might be reused to provision remote boxes.

Reusing fabfile.py to provision remote box:

When having fabfile already built for your local dev box you can then reuse it for automation of provisioning remote boxes. You can define your hosts in fabfile or you can just call

fab -H <user>@<hostname>:<sshPort> provision

Above command will install java and apache tomcat on any <hostname> with one bash call.


© 2017 | Hugo