SlideShare a Scribd company logo
Continuous Delivery
with Maven, Puppet
and Tomcat


Carlos Sanchez
@csanchez
http://csanchez.org
http://maestrodev.com
@csanchez            Apache
                      Maven



 ASF                    Eclipse
Member                Foundation



          csanchez.org
         maestrodev.com
How we got here
Agile




         planning
  iterative development
  continuous integration
release soon, release often
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Fear of change
    Risky deployments
 It works on my machine!
        Siloisation
Dev Change vs. Ops stability
Individuals and interactions over processes and tools
Working software over comprehensive documentation
  Customer collaboration over contract negotiation
    Responding to change over following a plan
OPs requirements


Operating System
config files
packages installed
multi stage configurations
dev
QA
pre-production
production
Deployment


How do I deploy this?
documentation
manual steps
prone to errors
Cloud



How do I deploy this?
to hundreds of servers
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
DevOps
DevQaOps ?
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
DEV   QA   OPS
QA




DEV        OPS
Specs
Packages   DEV   PROD

Versions
Testability
DEV   QA
Metrics
Logs       DEV   PROD
Security
updates
is not about
the tools
but

how can I
implement IT
Tools can
enable change
in behavior
and eventually
change
culture
Patrick Debois
everyone is
intelligent
enough
every tool is
cloud enabled
every tool is DevOps(tm)
3 key concepts
Continuous
Delivery
Continuous
delivery
Infrastructure
as Code
it’s all been invented,
now it’s standardized
manifests
ruby-like
ERB templates
                exec { "maven-untar":
                  command => "tar xf /tmp/x.tgz",
                  cwd => "/opt",
                  creates => "/opt/apache-maven-${version}",
                  path => ["/bin"],
                } ->
                file { "/usr/bin/mvn":
                  ensure => link,
                  target => "/opt/apache-maven-${version}/bin/mvn",
                }
                file { "/usr/local/bin/mvn":
                  ensure => absent,
                  require => Exec["maven-untar"],
                }
                file { "$home/.mavenrc":
                  mode => "0600",
                  owner => $user,
                  content => template("maven/mavenrc.erb"),
                  require => User[$user],
                }
package { 'openssh-server':
                   ensure => present,
                 }




infrastructure
IS code
service { 'ntp':
  name      => 'ntpd',
  ensure    => running,
}




                      declarative model
                      state vs process
                      no scripting
Follow
development             new
best                  solutions
practices
tagging
branching
                         new
releasing             challenges
dev, QA, production
Self servicing
Infrastructure
always
available
virtualization & cloud
empower developers
reduce time-to-
market
devs buy-in
With great power
comes great
responsibility
Vagrant
empower developers
dev-ops collaboration
automation
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Vagrant
Vagrant



     Oracle VirtualBox cmdline automation
      Easy Puppet and Chef provisioning
  Keep VM configuration for different projects
Share boxes and configuration files across teams
         base box + configuration files
Vagrant base boxes




  www.vagrantbox.es


anywhere! just (big) files
using Vagrant


$ gem install vagrant
$ vagrant box add centos-6.0-x86_64 
      http://dl.dropbox.com/u/1627760/centos-6.0-x86_64.box

$   vagrant     init myproject
$   vagrant     up
$   vagrant     ssh
$   vagrant     suspend
$   vagrant     resume
$   vagrant     destroy
Vagrant
Vagrant::Config.run do |config|

  # Every Vagrant virtual environment requires a box to build off of.
  config.vm.box = "centos-6.0-x86_64"

  # The url from where the 'config.vm.box' box will be fetched
  config.vm.box_url = "http://dl.dropbox.com/u/1627760/centos-6.0-x86_64.box"

  # Boot with a GUI so you can see the screen. (Default is headless)
  #config.vm.boot_mode = :gui

  # Assign this VM to a host only network IP, allowing you to access it via the IP.
  # config.vm.network "33.33.33.10"

  # Forward a port from the guest to the host, which allows for outside
  # computers to access the VM, whereas host only networking does not.
  config.vm.forward_port "sonar", 9000, 19000

  # Enable provisioning with Puppet stand alone.
  config.vm.share_folder("templates", "/tmp/vagrant-puppet/templates", "templates")

  config.vm.provision :puppet do |puppet|
    puppet.manifest_file = "base.pp"
    puppet.module_path = "mymodules"
    puppet.options = ["--templatedir","/tmp/vagrant-puppet/templates"]
    puppet.options = "-v -d"
  end

end
manifests/base.pp




package { jdk:
  ensure => installed,
  name    => $operatingsystem ? {
     centOS => "java-1.6.0-openjdk-devel",
     Ubuntu => "openjdk-6-jdk",
     default => "jdk",
  },
}
Maven and Puppet
What am I doing to automate deployment



             Ant tasks plugin
              ssh commands
             Assembly plugin
                  Cargo
               Capistrano
What can I do to automate deployment


  Handle full deployment including infrastructure
           not just webapp deployment
    Help Ops with clear, automated manifests
  Ability to reproduce production environments
  in local box using Vagrant / VirtualBox / VMWare
        Use the right tool for the right job
Maven-Puppet module


          A Maven Puppet module


https://github.com/maestrodev/puppet-maven


    fetches Maven artifacts from the repo
        manages them with Puppet
          no more extra packaging
Installing Maven

$repo1 = {
  id => "myrepo",
  username => "myuser",
  password => "mypassword",
  url => "http://repo.acme.com",
}

# Install Maven
class { "maven::maven":
  version => "2.2.1",
} ->

# Create a settings.xml with the repo credentials
class { "maven::settings" :
  servers => [$repo1],
}
New Maven type




maven { "/tmp/maven-core-2.2.1.jar":
  id => "org.apache.maven:maven-core:jar:2.2.1",
  repos => ["http://repo1.maven.apache.org/maven2",
          "http://mirrors.ibiblio.org/pub/mirrors/maven2"],
}
New Maven type




maven { "/tmp/maven-core-2.2.1.jar":
  groupId => "org.apache.maven",
  artifactId => "maven-core",
  version => "2.2.1",
  packaging => "jar",
  repos => ["http://repo1.maven.apache.org/maven2",
          "http://mirrors.ibiblio.org/pub/mirrors/maven2"],
}
Examples
Infrastructure

                 QA           www
            httpd, tomcat,    httpd
               postgres
Jenkins
                             tomcat1
                              tomcat
Archiva

                               db
                             postgres
Tomcat cluster + postgres


      postgres database
          db.acme.com

       tomcat servers
        tomcat1.acme.com
        tomcat2.acme.com
               ...

            httpd
         www.acme.com
Puppet Modules required

                     bundle install && librarian-puppet install


mod 'puppetlabs/java', '0.1.6'
mod 'puppetlabs/apache', '0.4.0'
mod 'inkling/postgresql', '0.2.0'
mod 'puppetlabs/firewall', '0.0.4'
mod 'tomcat',
 :git => 'https://github.com/carlossg/puppet-tomcat.git',
 :ref => 'centos'
mod 'maestrodev/maven', '1.x'
mod 'stahnma/epel', '0.0.2'
mod 'maestrodev/avahi', '1.x'
mod 'acme', :path => 'mymodules/acme'
mymodules/acme/manifests/db_node.pp


class 'acme::db_node' {

    class { "postgresql::server" :
      config_hash => {
         'postgres_password' => 'postgres'
      }
    } ->
    postgresql::db{ "appfuse":
      user      => "appfuse",
      password => "appfuse",
      grant     => "all",
    }
}
mymodules/acme/manifests/tomcat_node.pp

  class 'acme::tomcat_node'($db_host = 'db.local') {

      class { "java":
        distribution => "java-1.6.0-openjdk"
      }

      class { 'tomcat': } ->
      tomcat::instance {'appfuse': } ->

      class { 'maven::maven': } ->
      maven { "/srv/tomcat/appfuse/webapps/ROOT.war":
        id => "org.appfuse:appfuse-spring:2.2.1:war",
      }
  }
manifests/site.pp



import 'nodes/*.pp'

node ‘parent’ {
  class {'epel': } ->

    class {'avahi':
      firewall => true,
    }
}
manifests/nodes/tomcat.pp



# tomcat1.acme.com, tomcat2.acme.com,
tomcat3.acme.com,...
node /tomcatd..*/ inherits ‘parent’ {
  file {'/etc/motd':
    content => ”tomcat server: ${::hostname}n”,
  }

    class {'acme::tomcat_node'}
}
manifests/nodes/qa.pp


node /qa..*/ inherits ‘parent’ {
  class {'acme::db_node': }

     class {'acme::tomcat_node':
       db_host => 'localhost',
     }

    class {'acme::www_node':
       tomcat_host => 'localhost',
     }
}
spec/hosts/db_spec.pp



require 'rspec-puppet'

describe 'db.acme.com' do
  let(:facts) { {
    :osfamily => 'RedHat',
    :operatingsystem => 'CentOS',
    :operatingsystemrelease => ‘6.3’} }

  it { should contain_class('postgresql::server') }
end
spec/hosts/www_spec.pp



require 'rspec-puppet'

describe 'www.acme.com' do
  let(:facts) { {
    :osfamily => 'RedHat',
    :operatingsystem => 'CentOS',
    :operatingsystemrelease => ‘6.3’} }

  it { should contain_package('httpd') }
end
Example code and slides




          Available at
 http://slideshare.csanchez.org
  http://github.csanchez.org
   http://blog.csanchez.org
Thanks!

http://csanchez.org
http://maestrodev.com


csanchez@maestrodev.com
carlos@apache.org
@csanchez
Photo Credits

                Brick wall - Luis Argerich
  http://www.flickr.com/photos/lrargerich/4353397797/
       Agile vs. Iterative flow - Christopher Little
http://en.wikipedia.org/wiki/File:Agile-vs-iterative-flow.jpg
                   DevOps - Rajiv.Pant
      http://en.wikipedia.org/wiki/File:Devops.png
         Pimientos de Padron - Howard Walfish
  http://www.flickr.com/photos/h-bomb/4868400647/
                    Compiling - XKCD
                  http://xkcd.com/303/
            Printer in 1568 - Meggs, Philip B
 http://en.wikipedia.org/wiki/File:Printer_in_1568-ce.png
                 Relativity - M. C. Escher
http://en.wikipedia.org/wiki/File:Escher%27s_Relativity.jpg
             Teacher and class - Herald Post
 http://www.flickr.com/photos/heraldpost/5169295832/

More Related Content

KEY
Puppet for Java developers - JavaZone NO 2012
KEY
From Dev to DevOps - Apache Barcamp Spain 2011
KEY
From Dev to DevOps - FOSDEM 2012
KEY
From Dev to DevOps - ApacheCON NA 2011
PDF
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
PDF
Continuous Delivery: The Next Frontier
PDF
From Dev to DevOps
PDF
From Dev to DevOps - Codemotion ES 2012
Puppet for Java developers - JavaZone NO 2012
From Dev to DevOps - Apache Barcamp Spain 2011
From Dev to DevOps - FOSDEM 2012
From Dev to DevOps - ApacheCON NA 2011
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
Continuous Delivery: The Next Frontier
From Dev to DevOps
From Dev to DevOps - Codemotion ES 2012

What's hot (20)

PDF
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
PDF
Antons Kranga Building Agile Infrastructures
PDF
Continuous infrastructure testing
PDF
DevOps(4) : Ansible(2) - (MOSG)
PDF
Puppet: Eclipsecon ALM 2013
PDF
Preparation study of_docker - (MOSG)
PDF
10 Million hits a day with WordPress using a $15 VPS
PDF
Ansible new paradigms for orchestration
PPTX
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
PPTX
Docker Starter Pack
PDF
DevOps(3) : Ansible - (MOSG)
PDF
Using Kubernetes for Continuous Integration and Continuous Delivery
PDF
Ansible 實戰:top down 觀點
PDF
PuppetCamp SEA 1 - Puppet Deployment at OnApp
PDF
Getting started with Ansible
PDF
Cooking Perl with Chef
PPTX
Harmonious Development: Standardizing The Deployment Process via Vagrant and ...
PDF
Vagrant for real (codemotion rome 2016)
PDF
PuppetCamp SEA 1 - Use of Puppet
PDF
Zero Downtime Deployment with Ansible
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Antons Kranga Building Agile Infrastructures
Continuous infrastructure testing
DevOps(4) : Ansible(2) - (MOSG)
Puppet: Eclipsecon ALM 2013
Preparation study of_docker - (MOSG)
10 Million hits a day with WordPress using a $15 VPS
Ansible new paradigms for orchestration
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
Docker Starter Pack
DevOps(3) : Ansible - (MOSG)
Using Kubernetes for Continuous Integration and Continuous Delivery
Ansible 實戰:top down 觀點
PuppetCamp SEA 1 - Puppet Deployment at OnApp
Getting started with Ansible
Cooking Perl with Chef
Harmonious Development: Standardizing The Deployment Process via Vagrant and ...
Vagrant for real (codemotion rome 2016)
PuppetCamp SEA 1 - Use of Puppet
Zero Downtime Deployment with Ansible
Ad

Viewers also liked (20)

PDF
Automated Deployment with Maven - going the whole nine yards
PDF
Industrialisation des développements Java
PDF
DevOps: Coding Defines Monitoring
PPTX
如何利用Jira + structure 做需求管理
PDF
Puppet Deployment at OnApp
PPTX
Fastest Servlets in the West
PDF
Alpes Jug (29th March, 2010) - Apache Maven
ODP
Captain Agile and the Providers of Value
KEY
Building Android apps with Maven
PPTX
20091112 - Mars Jug - Apache Maven
PDF
Maven 3.0 at Øredev
PDF
Veni, Vide, Built: Android Gradle Plugin
PDF
Gradle enabled android project
PDF
不只自動化而且更敏捷的Android開發工具 gradle mopcon
PDF
Gradle in 45min
PDF
Lorraine JUG (1st June, 2010) - Maven
PPTX
PDF
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
PDF
Gradle - the Enterprise Automation Tool
PDF
Gradle talk, Javarsovia 2010
Automated Deployment with Maven - going the whole nine yards
Industrialisation des développements Java
DevOps: Coding Defines Monitoring
如何利用Jira + structure 做需求管理
Puppet Deployment at OnApp
Fastest Servlets in the West
Alpes Jug (29th March, 2010) - Apache Maven
Captain Agile and the Providers of Value
Building Android apps with Maven
20091112 - Mars Jug - Apache Maven
Maven 3.0 at Øredev
Veni, Vide, Built: Android Gradle Plugin
Gradle enabled android project
不只自動化而且更敏捷的Android開發工具 gradle mopcon
Gradle in 45min
Lorraine JUG (1st June, 2010) - Maven
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle - the Enterprise Automation Tool
Gradle talk, Javarsovia 2010
Ad

Similar to Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013 (20)

PPTX
Harmonious Development: Via Vagrant and Puppet
PDF
infra-as-code
PDF
Burn down the silos! Helping dev and ops gel on high availability websites
PDF
Writing & Sharing Great Modules - Puppet Camp Boston
PDF
20090514 Introducing Puppet To Sasag
PPT
Dance for the puppet master: G6 Tech Talk
KEY
Cooking with Chef
PPTX
Vagrant introduction for Developers
PDF
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
PPTX
Software Defined Datacenter
PDF
Postgres the hardway
PDF
Bare Metal to OpenStack with Razor and Chef
PDF
Vagrant for real
PDF
Vagrant for real codemotion (moar tips! ;-))
PPTX
Control your deployments with Capistrano
KEY
Railsconf2011 deployment tips_for_slideshare
PDF
Puppet and Vagrant in development
PDF
Provisioning with Puppet
Harmonious Development: Via Vagrant and Puppet
infra-as-code
Burn down the silos! Helping dev and ops gel on high availability websites
Writing & Sharing Great Modules - Puppet Camp Boston
20090514 Introducing Puppet To Sasag
Dance for the puppet master: G6 Tech Talk
Cooking with Chef
Vagrant introduction for Developers
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
Software Defined Datacenter
Postgres the hardway
Bare Metal to OpenStack with Razor and Chef
Vagrant for real
Vagrant for real codemotion (moar tips! ;-))
Control your deployments with Capistrano
Railsconf2011 deployment tips_for_slideshare
Puppet and Vagrant in development
Provisioning with Puppet

More from Carlos Sanchez (20)

PDF
Using Containers for Continuous Integration and Continuous Delivery. KubeCon ...
PDF
Divide and Conquer: Easier Continuous Delivery using Micro-Services
PDF
Using Kubernetes for Continuous Integration and Continuous Delivery. Java2days
PDF
Using Containers for Continuous Integration and Continuous Delivery
PDF
Divide and Conquer: Easier Continuous Delivery using Micro-Services
PDF
Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...
PDF
Testing Distributed Micro Services. Agile Testing Days 2017
PDF
CI and CD at Scale: Scaling Jenkins with Docker and Apache Mesos
PDF
From Monolith to Docker Distributed Applications
PDF
From Monolith to Docker Distributed Applications. JavaOne
PDF
Scaling Jenkins with Docker: Swarm, Kubernetes or Mesos?
PDF
CI and CD at Scale: Scaling Jenkins with Docker and Apache Mesos
PDF
From Monolith to Docker Distributed Applications
PDF
Scaling Jenkins with Docker and Kubernetes
PDF
Using Docker for Testing
PDF
Scaling Docker with Kubernetes
PPTX
Scaling Jenkins with Docker and Kubernetes
PDF
Scaling Docker with Kubernetes
KEY
Enterprise Build And Test In The Cloud
KEY
Enterprise Build And Test In The Cloud
Using Containers for Continuous Integration and Continuous Delivery. KubeCon ...
Divide and Conquer: Easier Continuous Delivery using Micro-Services
Using Kubernetes for Continuous Integration and Continuous Delivery. Java2days
Using Containers for Continuous Integration and Continuous Delivery
Divide and Conquer: Easier Continuous Delivery using Micro-Services
Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...
Testing Distributed Micro Services. Agile Testing Days 2017
CI and CD at Scale: Scaling Jenkins with Docker and Apache Mesos
From Monolith to Docker Distributed Applications
From Monolith to Docker Distributed Applications. JavaOne
Scaling Jenkins with Docker: Swarm, Kubernetes or Mesos?
CI and CD at Scale: Scaling Jenkins with Docker and Apache Mesos
From Monolith to Docker Distributed Applications
Scaling Jenkins with Docker and Kubernetes
Using Docker for Testing
Scaling Docker with Kubernetes
Scaling Jenkins with Docker and Kubernetes
Scaling Docker with Kubernetes
Enterprise Build And Test In The Cloud
Enterprise Build And Test In The Cloud

Recently uploaded (20)

PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Encapsulation theory and applications.pdf
PDF
Approach and Philosophy of On baking technology
PDF
cuic standard and advanced reporting.pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Machine learning based COVID-19 study performance prediction
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Diabetes mellitus diagnosis method based random forest with bat algorithm
Dropbox Q2 2025 Financial Results & Investor Presentation
MYSQL Presentation for SQL database connectivity
Programs and apps: productivity, graphics, security and other tools
Encapsulation theory and applications.pdf
Approach and Philosophy of On baking technology
cuic standard and advanced reporting.pdf
Spectroscopy.pptx food analysis technology
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
NewMind AI Weekly Chronicles - August'25 Week I
sap open course for s4hana steps from ECC to s4
Review of recent advances in non-invasive hemoglobin estimation
Mobile App Security Testing_ A Comprehensive Guide.pdf
Electronic commerce courselecture one. Pdf
MIND Revenue Release Quarter 2 2025 Press Release
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Machine learning based COVID-19 study performance prediction

Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013

  • 1. Continuous Delivery with Maven, Puppet and Tomcat Carlos Sanchez @csanchez http://csanchez.org http://maestrodev.com
  • 2. @csanchez Apache Maven ASF Eclipse Member Foundation csanchez.org maestrodev.com
  • 3. How we got here
  • 4. Agile planning iterative development continuous integration release soon, release often
  • 7. Fear of change Risky deployments It works on my machine! Siloisation Dev Change vs. Ops stability
  • 8. Individuals and interactions over processes and tools Working software over comprehensive documentation Customer collaboration over contract negotiation Responding to change over following a plan
  • 9. OPs requirements Operating System config files packages installed multi stage configurations dev QA pre-production production
  • 10. Deployment How do I deploy this? documentation manual steps prone to errors
  • 11. Cloud How do I deploy this? to hundreds of servers
  • 16. DEV QA OPS
  • 17. QA DEV OPS
  • 18. Specs Packages DEV PROD Versions
  • 20. Metrics Logs DEV PROD Security updates
  • 21. is not about the tools but how can I implement IT
  • 22. Tools can enable change in behavior and eventually change culture Patrick Debois
  • 23. everyone is intelligent enough every tool is cloud enabled every tool is DevOps(tm)
  • 27. Infrastructure as Code it’s all been invented, now it’s standardized
  • 28. manifests ruby-like ERB templates exec { "maven-untar": command => "tar xf /tmp/x.tgz", cwd => "/opt", creates => "/opt/apache-maven-${version}", path => ["/bin"], } -> file { "/usr/bin/mvn": ensure => link, target => "/opt/apache-maven-${version}/bin/mvn", } file { "/usr/local/bin/mvn": ensure => absent, require => Exec["maven-untar"], } file { "$home/.mavenrc": mode => "0600", owner => $user, content => template("maven/mavenrc.erb"), require => User[$user], }
  • 29. package { 'openssh-server': ensure => present, } infrastructure IS code
  • 30. service { 'ntp': name => 'ntpd', ensure => running, } declarative model state vs process no scripting
  • 31. Follow development new best solutions practices tagging branching new releasing challenges dev, QA, production
  • 34. devs buy-in With great power comes great responsibility
  • 38. Vagrant Oracle VirtualBox cmdline automation Easy Puppet and Chef provisioning Keep VM configuration for different projects Share boxes and configuration files across teams base box + configuration files
  • 39. Vagrant base boxes www.vagrantbox.es anywhere! just (big) files
  • 40. using Vagrant $ gem install vagrant $ vagrant box add centos-6.0-x86_64 http://dl.dropbox.com/u/1627760/centos-6.0-x86_64.box $ vagrant init myproject $ vagrant up $ vagrant ssh $ vagrant suspend $ vagrant resume $ vagrant destroy
  • 41. Vagrant Vagrant::Config.run do |config| # Every Vagrant virtual environment requires a box to build off of. config.vm.box = "centos-6.0-x86_64" # The url from where the 'config.vm.box' box will be fetched config.vm.box_url = "http://dl.dropbox.com/u/1627760/centos-6.0-x86_64.box" # Boot with a GUI so you can see the screen. (Default is headless) #config.vm.boot_mode = :gui # Assign this VM to a host only network IP, allowing you to access it via the IP. # config.vm.network "33.33.33.10" # Forward a port from the guest to the host, which allows for outside # computers to access the VM, whereas host only networking does not. config.vm.forward_port "sonar", 9000, 19000 # Enable provisioning with Puppet stand alone. config.vm.share_folder("templates", "/tmp/vagrant-puppet/templates", "templates") config.vm.provision :puppet do |puppet| puppet.manifest_file = "base.pp" puppet.module_path = "mymodules" puppet.options = ["--templatedir","/tmp/vagrant-puppet/templates"] puppet.options = "-v -d" end end
  • 42. manifests/base.pp package { jdk: ensure => installed, name => $operatingsystem ? { centOS => "java-1.6.0-openjdk-devel", Ubuntu => "openjdk-6-jdk", default => "jdk", }, }
  • 44. What am I doing to automate deployment Ant tasks plugin ssh commands Assembly plugin Cargo Capistrano
  • 45. What can I do to automate deployment Handle full deployment including infrastructure not just webapp deployment Help Ops with clear, automated manifests Ability to reproduce production environments in local box using Vagrant / VirtualBox / VMWare Use the right tool for the right job
  • 46. Maven-Puppet module A Maven Puppet module https://github.com/maestrodev/puppet-maven fetches Maven artifacts from the repo manages them with Puppet no more extra packaging
  • 47. Installing Maven $repo1 = { id => "myrepo", username => "myuser", password => "mypassword", url => "http://repo.acme.com", } # Install Maven class { "maven::maven": version => "2.2.1", } -> # Create a settings.xml with the repo credentials class { "maven::settings" : servers => [$repo1], }
  • 48. New Maven type maven { "/tmp/maven-core-2.2.1.jar": id => "org.apache.maven:maven-core:jar:2.2.1", repos => ["http://repo1.maven.apache.org/maven2", "http://mirrors.ibiblio.org/pub/mirrors/maven2"], }
  • 49. New Maven type maven { "/tmp/maven-core-2.2.1.jar": groupId => "org.apache.maven", artifactId => "maven-core", version => "2.2.1", packaging => "jar", repos => ["http://repo1.maven.apache.org/maven2", "http://mirrors.ibiblio.org/pub/mirrors/maven2"], }
  • 51. Infrastructure QA www httpd, tomcat, httpd postgres Jenkins tomcat1 tomcat Archiva db postgres
  • 52. Tomcat cluster + postgres postgres database db.acme.com tomcat servers tomcat1.acme.com tomcat2.acme.com ... httpd www.acme.com
  • 53. Puppet Modules required bundle install && librarian-puppet install mod 'puppetlabs/java', '0.1.6' mod 'puppetlabs/apache', '0.4.0' mod 'inkling/postgresql', '0.2.0' mod 'puppetlabs/firewall', '0.0.4' mod 'tomcat', :git => 'https://github.com/carlossg/puppet-tomcat.git', :ref => 'centos' mod 'maestrodev/maven', '1.x' mod 'stahnma/epel', '0.0.2' mod 'maestrodev/avahi', '1.x' mod 'acme', :path => 'mymodules/acme'
  • 54. mymodules/acme/manifests/db_node.pp class 'acme::db_node' { class { "postgresql::server" : config_hash => { 'postgres_password' => 'postgres' } } -> postgresql::db{ "appfuse": user => "appfuse", password => "appfuse", grant => "all", } }
  • 55. mymodules/acme/manifests/tomcat_node.pp class 'acme::tomcat_node'($db_host = 'db.local') { class { "java": distribution => "java-1.6.0-openjdk" } class { 'tomcat': } -> tomcat::instance {'appfuse': } -> class { 'maven::maven': } -> maven { "/srv/tomcat/appfuse/webapps/ROOT.war": id => "org.appfuse:appfuse-spring:2.2.1:war", } }
  • 56. manifests/site.pp import 'nodes/*.pp' node ‘parent’ { class {'epel': } -> class {'avahi': firewall => true, } }
  • 57. manifests/nodes/tomcat.pp # tomcat1.acme.com, tomcat2.acme.com, tomcat3.acme.com,... node /tomcatd..*/ inherits ‘parent’ { file {'/etc/motd': content => ”tomcat server: ${::hostname}n”, } class {'acme::tomcat_node'} }
  • 58. manifests/nodes/qa.pp node /qa..*/ inherits ‘parent’ { class {'acme::db_node': } class {'acme::tomcat_node': db_host => 'localhost', } class {'acme::www_node': tomcat_host => 'localhost', } }
  • 59. spec/hosts/db_spec.pp require 'rspec-puppet' describe 'db.acme.com' do let(:facts) { { :osfamily => 'RedHat', :operatingsystem => 'CentOS', :operatingsystemrelease => ‘6.3’} } it { should contain_class('postgresql::server') } end
  • 60. spec/hosts/www_spec.pp require 'rspec-puppet' describe 'www.acme.com' do let(:facts) { { :osfamily => 'RedHat', :operatingsystem => 'CentOS', :operatingsystemrelease => ‘6.3’} } it { should contain_package('httpd') } end
  • 61. Example code and slides Available at http://slideshare.csanchez.org http://github.csanchez.org http://blog.csanchez.org
  • 63. Photo Credits Brick wall - Luis Argerich http://www.flickr.com/photos/lrargerich/4353397797/ Agile vs. Iterative flow - Christopher Little http://en.wikipedia.org/wiki/File:Agile-vs-iterative-flow.jpg DevOps - Rajiv.Pant http://en.wikipedia.org/wiki/File:Devops.png Pimientos de Padron - Howard Walfish http://www.flickr.com/photos/h-bomb/4868400647/ Compiling - XKCD http://xkcd.com/303/ Printer in 1568 - Meggs, Philip B http://en.wikipedia.org/wiki/File:Printer_in_1568-ce.png Relativity - M. C. Escher http://en.wikipedia.org/wiki/File:Escher%27s_Relativity.jpg Teacher and class - Herald Post http://www.flickr.com/photos/heraldpost/5169295832/