Example code at https://github.com/carlossg/puppet-for-java-devs
More info at http://blog.carlossanchez.eu/tag/devops
Video at http://vimeo.com/49483627
Puppet is an infrastructure-as-code tool that allows easy and automated provisioning of servers, defining the packages, configuration, services,... in code. Enabling DevOps culture, tools like Puppet help drive Agile development all the way to operations and systems administration, and along with continuous integration tools like Jenkins, it is a key piece to accomplish repeatability and continuous delivery, automating the operations side during development, QA or production, and enabling testing of systems configuration.
Traditionally a field for system administrators, Puppet can empower developers, allowing both to collaborate coding the infrastructure needed for their developments, whether it runs in hardware, virtual machines or cloud. Developers and sysadmins can define what JDK version must be installed, application server, version, configuration files, war and jar files,... and easily make changes that propagate across all nodes.
Using Vagrant, a command line automation layer for VirtualBox, they can also spin off virtual machines in their local box, easily from scratch with the same configuration as production servers, do development or testing and tear them down afterwards.
We’ll show how to install and manage Puppet nodes with JDK, multiple application server instances with installed web applications, database, configuration files and all the supporting services. Including getting up and running with Vagrant and VirtualBox for quickstart and Puppet experiments, as well as setting up automated testing of the Puppet code.
6. Agile
planning
iterative development
continuous integration
release soon, release often
7.
8.
9. DevOps addresses
Fear of change
Risky deployments
It works on my machine!
Siloisation
Dev Change vs. Ops stability
10. Individuals and interactions over processes and tools
Working software over comprehensive documentation
Customer collaboration over contract negotiation
Responding to change over following a plan
28. 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
http://vagrantup.com/
31. 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
config.vm.provision :puppet do |puppet|
puppet.manifest_file = "site.pp"
puppet.module_path = "mymodules"
end
end
48. variables
$longthing = "Imagine I have something really
long in here. Like an SSH key, let's say."
file {'authorized_keys':
path => '/root/.ssh/authorized_keys',
content => $longthing,
}
49. facts
host {'self':
ensure => present,
name => $::fqdn,
host_aliases => ['puppet', $::hostname],
ip => $::ipaddress,
}
file {'motd':
ensure => file,
path => '/etc/motd',
mode => 0644,
content => "Welcome to ${::hostname},na $
{::operatingsystem} island in the sea of ${::domain}.
n",
}
50. conditionals
if $is_virtual {
service {'ntpd':
ensure => stopped,
enable => false,
}
}
else {
service { 'ntpd':
name => 'ntpd',
ensure => running,
enable => true,
hasrestart => true,
require => Package['ntp'],
}
}
70. What am I doing to automate deployment
Ant tasks plugin
ssh commands
Assembly plugin
Cargo
Capistrano
71. 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
72. 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
73. 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],
}
74. 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"],
}
75. 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"],
}
79. Puppetfile
forge 'http://forge.puppetlabs.com'
mod 'puppetlabs/stdlib', '3.0.1'
mod 'puppetlabs/java', '0.1.6'
mod 'puppetlabs/apache', '0.2.2'
mod 'inkling/postgresql'
mod 'camptocamp/tomcat',
:git => 'git://github.com/camptocamp/puppet-tomcat.git',
:ref => '16e498'
mod 'maestrodev/maven', ‘0.0.1’
mod 'maestrodev/wget', '0.0.1'
mod 'stahnma/epel', '0.0.2'
83. Puppet Rspec
require 'spec_helper'
describe 'db.acme.com' do
let(:facts) { {
:osfamily => 'RedHat',
:operatingsystem => 'CentOS',
:operatingsystemrelease => 6.3} }
it { should_not contain_class('java') }
it { should contain_class('postgresql::server')}
end
84. Example code and slides
Available at
http://slideshare.carlossanchez.eu
http://github.carlossanchez.eu
https://github.com/carlossg/puppet-for-java-devs
http://blog.carlossanchez.eu
https://github.com/maestrodev/puppet-modules
86. Photo Credits
Son of Man Lego - Alex Eylar
http://www.flickr.com/photos/hoyvinmayvin/4702772452/
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/
Editor's Notes
\n
question? #developers vs #ops vs #devops\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
question? what do you do to specify ops requirements?\n
\n
question? what do you do to specify ops requirements?\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
question? who’s able to roll back to a previous version of software? and system?\n