Configure Jenkins and Tomcat using Puppet on Vagrant

Posted by ex3v on Programmers See other posts from Programmers or by ex3v
Published on 2014-08-22T19:41:46Z Indexed on 2014/08/23 10:34 UTC
Read the original article Hit count: 388

I'm playing with setting up my first Spring + jenkins + Tomcat CI dev environment. For now it's just a test/fun phase, but in the near future I'll be starting new project with my coworkers. That's the reason that I want development environment virtualized and exactly te same on every development machine, as well as on production server.

I choosen to use Vagrant and to try to write puppet scripts that not only install everything, but also configure everything so each of us will have the same jenkins plugins, same jenkins and tomcat login and password, and literally after calling vagrant up we are ready to work.

What I managed to do so far is installation of stuff needed and port forwarding. My vagrantfile looks like this (comments stripped):

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.vm.box = "precise32"
  config.vm.box_url = "http://files.vagrantup.com/precise32.box"

  config.vm.network :forwarded_port, guest: 80, host: 8090
  config.vm.network :forwarded_port, guest: 8080, host: 8091

  config.vm.network :private_network, ip: "192.168.33.10"


    config.vm.provision :puppet do |puppet|
      puppet.manifests_path = "puppet/"
      puppet.manifest_file  = "default.pp"
      puppet.options = ['--verbose']
    end

end

And this is my puppet file:

Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ] }

class system-update {
  exec { 'apt-get update':
    command => 'apt-get update',
  }

  $sysPackages = [ "build-essential" ]
  package { $sysPackages:
    ensure => "installed",
    require => Exec['apt-get update'],
  }
}

class tomcat {
  package { "tomcat":
    ensure  => present,
    require => Class["system-update"],
  }

  service { "tomcat":
    ensure  => "running",
    require => Package["tomcat"],
  }

}

class jenkins {
  package { "jenkins":
    ensure => present,
    require => Class["system-update"],
  }

  service { "jenkins":
    ensure => "running",
    require => Package["jenkins"],
  }
}

include system-update
include tomcat
include jenkins

Now, when I hit vagrant provision and go to http://localhost:8091/ I can see jenkins running, so above script works good.

Next step is configurating jenkins and tomcat by extending above puppet scripts.

I'm pretty green when it comes to CI. After wandering around web I've found few tutorials about jenkins configuration (here's one of them). I really want to move configuration presented in this tutorial to puppet file, so when I spread my vagrantfile and puppet file between my coworkers, I will be sure that everyone has exactly te same setup. Unfortunately I'm also green about using puppet, I don't know how to do this. Any help will be apreciated.

© Programmers or respective owner

Related posts about Workflows

Related posts about continuous-integration