3. MOTIVATION
• How to take control inside the
following environment issues?
• Common workstation problems
(HD failure, dead computer)
• Different OS’s
• Extra machine configuration to
enable devs to work (programming
languages, databases, plugins, etc),
taking one or two days to be
ready-to-code
• “Works on my machine” syndrome
4. MOTIVATION
• Vagrant or Docker. Period.
• Embrace virtualisation
• Each offers a way to pre-setup yourVM with necessary libraries,
databases and so on
• No more development databases in your pre-staging DB server,
additional dependencies
• A try to make development environment more similar to production
5. MOTIVATION
• It sounds good, but… how to take control over each applicationVM?
• Sometimes your team needs to use some tools that are not available in
official package repository (or are too old), forcing to manual configuration
after up aVM
• Even running aVM, developer personal choices can contaminate the
application (example: rspec add-ons, irb plugins)
• Some developers don’t have knowledge about Chef / Puppet recipes
• How to maintainVagrant Custom Boxes / Docker Custom Images when
you need to add / change tools, repositories or configs?
6. MOTIVATION
• For sysadms / sysops:
• How to export a new machine image to your
virtualisation server (KVM, Xen,VMWare, etc)
when a new OS release is launched without
“dist-upgrade”?
• How to automate it?
7. MOTIVATION
• Packer for the rescue
• Written in Go
• Owner: Mitchell Hashimoto
(Vagrant, Serf)
• http://www.packer.io
10. HOW IT WORKS
• Packer recipes are JSON files
• Validate template:
• $ packer validate your_recipe.json
• Run template:
• $ packer run your_recipe.json
15. INSIDETEMPLATES:
BUILDERS
• Create a machine image from scratch
• Download a ISO from official OS mirror, select a
base image to start
• Set CPU cores, memory size, disk size
• See documentation for further details (a lot of
options)
18. INSIDETEMPLATES:
BUILDERS
• For CentOS: Kickstart
• For Debian: Preseed
• For Windows:
• Windows Automated Installation Kit (AIK)
• Microsoft DeploymentToolkit (MDT)
20. INSIDETEMPLATES:
BUILDERS /VMWARE &VIRTUALBOX
• VMWare:
• vmware-iso: create from scratch
• vmware-vmx: create from a baseVMX file
• Virtualbox:
• virtualbox-iso: create from scratch
• virtualbox-ovf: create from a base OVF file
21. INSIDETEMPLATES:
BUILDERS / QEMU
• Create KVM / Xen images from scratch
• Packer depends on qemu-system-x86_64, available
only on Debian at this time as a binary
• CentOS have qemu-kvm, but you need to
manually override all Packer default options
22. INSIDETEMPLATES:
BUILDERS / DOCKER
• Creates a Docker image by pulling a existent,
starting a container, provision it and exports a .tar
file
• Provision without Dockerfile
23. INSIDETEMPLATES:
BUILDERS / OTHERS
• For other builders, you simply need to inform:
• username / password,API key
• base image
• zone and other related information
• See Packer documentation
24. INSIDETEMPLATES:
PROVISIONERS
• After the setup of a machine image, it’s time to configure
it
• Here is where magic happens:
• Add packages, useful scripts
• Standardise config files
• Apply existent recipes from a CM
28. INSIDETEMPLATES:
PROVISIONERS / FILE UPLOADS
• Need to set default configuration files or upload
some custom packages (.tar, .deb / .rpm) to be
installed later?
• Upload them and after process with a shell script
or CM recipe
30. INSIDETEMPLATES:
PROVISIONERS / OTHERS
• The following provisioners requires installation before run:
• Ansible
• Puppet
• Salt
• Chef Solo is installed by Packer if not present
• At this time, all provisioners are executed in client mode (no remote
server)
32. INSIDETEMPLATES:
POST-PROCESSORS
• After create / setup a machine image, you can:
• Convert to aVagrant Custom Box
• Locally add it as a Docker container
• Publish in a Docker registry
• Publish in a vSphere endpoint
35. INSIDETEMPLATES:
POST-PROCESSORS / DOCKER
• You can locally import a Docker image
• You can push a Docker image to a registry
• Needs manual login (automated soon)
• Important: Docker pushes a completely new
image, not incremental
41. OUR EXPERIENCE
• Prepare to argue (sometimes fight :)
• It’s hard to change development tradition of
premature optimisation, ultra-high performance,
personal choices,“nightly build” syndrome
• Create a culture first
42. OUR EXPERIENCE
• Sometimes the better choice must be autocracy-based
• Use OS package system ASAP (or backport / automate installation if
package not exists)
• Introduce to developers a wisdom to use the same package of
programming language / DB / whatever that runs in production (!)
• If is old, upgrade your app to use a newer version
• The same for tools that “vendorize" your app libraries (maven,
bundler, etc)
43. OUR EXPERIENCE
• Make all applications ready-to-setup-and-run with one command
• Track all dependencies with Dockerfile orVagrant Shell Scripts
• Bash scripts are more easy to setup than 3rd party CM tools
at first time
• Adopt a convention to make all applications more similar as
possible about their structure
• Code generators
44. OUR EXPERIENCE
• Divide to conquer
• Adopt a bottom-up strategy
• Minor systems that are easy to setup
• Minor teams
• Start to apply with more systems and greater teams
• Standardise ASAP
45. OUR EXPERIENCE
• At this time, major systems in Locaweb PaaS areVagrant-ready
• git clone, vagrant up, vagrant ssh
• Docker in development
• Internally created a gem to apply standardisation of Rails apps:
• Packaging (Debian)
• Vagrant
• Packer recipes to createVagrant custom boxes, using our mirrors
46. FAQ
• Questions?
• New recipes available on:
• https://github.com/salizzar/packer-vmware