Your personal kitty, or “How to install Tomcat using Vagrant & Chef”

cat

In a previous post I wrote about how to create new local environments very easy, and for that example I was using a LAMP environment, however sometimes you have to work with Java, so, for those cases you can use the same tools: Vagrant, Virtualbox, Puppet or Chef.

For this example we are going to install a new Tomcat 8 RC2 server, using Java 7, very easily using Chef.

If you are not yet using DevEnv, create your project and download it.

$ mkdir project_one
$ cd project_one

$ git clone https://github.com/bbh/devenv.git
$ cd devenv

$ git submodule init
$ git submodule update
$ cd ../

Create your Vagrantfile

$ vi Vagrantfile

Use this configuration for your Vagrantfile (change the IP address if you need to)

Vagrant::Config.run do |config|
 config.vm.define :tomcat do |tom|
  tom.vm.box = "centos64"
  tom.vm.box_url = "http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130731.box"
  tom.vm.network :hostonly, "192.168.30.10"
  tom.vm.provision :chef_solo do |chef|
   chef.cookbooks_path = "devenv/chef/cookbooks"
   chef.run_list = [ "recipe[tomcat::default]" ]
  end
 end
end

Start your vagrant

$ vagrant up tomcat

And that’s it, now you can access your new Tomcat server using

$ vagrant ssh tomcat

And access it via web using http://192.168.30.10:8080/ (or the IP address previously chosen)

Now you have a functional Tomcat to deploy your projects without affecting your local environment. Enjoy!

Basilio Briceño

DevOps evangelist, SoftwareLibre activist, sometimes speaker & eclectic metalhead.

3 comments

  1. Sandeep Rai   •  

    Hi Bailio,
    I am trying to checkout the project above but run into an error when trying to update
    Looks like something from submodule has not been committed that is referenced by parent project.
    Below is the output

    $ git submodule update
    fatal: reference is not a tree: a77285ea955929ce06a2d60ebfa32de07f36c5f0
    Unable to checkout ‘a77285ea955929ce06a2d60ebfa32de07f36c5f0′ in submodule path
    ‘puppet/modules/apt’

  2. Vinicius Santana   •  

    Thank you!! This works fine for me. It was a great first step for this long jorny

  3. Manuel Loayza   •  

    Cloning into ‘puppet/modules/apt’…
    Username for ‘https://github.com': mloayzagahona@gmail.com
    Password for ‘https://mloayzagahona@gmail.com@github.com':
    remote: Repository not found.
    fatal: repository ‘https://github.com/camptocamp/puppet-apt.git/’ not found
    Clone of ‘git://github.com/camptocamp/puppet-apt.git’ into submodule path ‘puppet/modules/apt’ failed

Leave a Reply to Vinicius Santana Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>