Vagrant, Packer, and Puppet can be used together to create a development environment. Packer is used to build custom base boxes that include only the operating system. Vagrant uses these base boxes to create isolated virtual machines. Puppet then provisions the virtual machines by installing additional software, configuring applications, and defining infrastructure as code. This allows for consistent, reproducible development environments that match production.
Create your very own Development Environment with Vagrant and Packer
1. Create your very own Development
Environment with Vagrant and Packer
… and a little bit of Puppet
Frank Stelzer https://www.flickr.com/photos/eiriknewth/238681391
2. Créateur de
Agenda
• Motivation
• Vagrant Introduction
• Base Boxes
• Creating an own Base Box with Packer
• Demo
• Fat vs. Thin Boxes
• Provisioning with Puppet
21. Créateur de
Available Base Boxes
• Ubuntu Lucid 32 Bit (10.04)
• Ubuntu Lucid 64 Bit (10.04)
• Ubuntu Precise 32 Bit (12.04)
• Ubuntu Precise 64 Bit (12.04)
• https://github.com/mitchellh/vagrant/wiki/Available-Vagrant-
Boxes
• https://cloud-images.ubuntu.com/vagrant/
• other inofficial userland boxes: vagrantboxes.es, puphpet.com …
What is in there!?
22. Créateur de
Native supported base boxes are not up-
to-date in the most cases
PHP 5.3
nginx 0.9
Apache 1
not node compatible
http://www.flickr.com/photos/yoshimov/13909857/
PPAs :(
23. Créateur de
Can I haz the new things please?
PHP 5.5.9
nginx 1.6
Apache 2
node!
http://www.flickr.com/photos/chaosandcreations/2325239486/
PPAs not needed
34. Créateur de
Provisioning - with Puppet
"provisioners": [
{ […]
"type": "puppet-‐masterless",
"manifest_file": "puppet/manifests/lamp.pp",
"module_paths": ["puppet/modules"]
[…] }
]
• Provisioning types could be mixed
• Puppet has to be installed within Shell Provisioning first
35. Créateur de
Resulting VM could be converted to a
Vagrant box or whatever
"builders": […],
"post-‐processors": [
{
"only": ["virtualbox-‐iso"],
"type": "vagrant",
"output": "buildpacker_ubuntu-‐14.04_{{.Provider}}.box"
}
]
47. Créateur de
Fat Base Box
• advantages:
• vagrant up -> ultrafast
• no internet connection needed during VM creation
• disadvantages:
• out-of-date very fast
• heavy maintenance needed
• one fat base box for every server type (webserver, database server,
search server etc.)
• … or do you want PHP to be installed on a DB node?
48. Créateur de
Fat vs. Slim Base Box
Fat Base Box
ISO
VBoxGuestAdditions
PHP 5
MySQL
Redis
nginx
Slim Base Box
ISO
VBoxGuestAdditions
+ Provisioning (Puppet)
52. Créateur de
Usage
Fat Base Box
!
• no changes
• System is well known
• Golden Image way
• Admins are defining the system
Slim Base Box
• frequent changes
• System is not yet
defined
• Developers are
defining the system
53. Créateur de
Slim Base Boxes need additional
provisioning after Virtual Machine has
been installed!
54. Créateur de
Provisioning with Puppet
VM
Box
!
dev.smoov.io
Vagrant
Base BoxVagrantfile
"name =
dev.smoov.io"
project $
Packer
Base BoxVM
1
2
4Puppet
3
vagrant up
55. Créateur de
Vagrantfile
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "packer_ubuntu-‐14.04_virtualbox"
# …
!
config.vm.provision :puppet do |puppet|
puppet.manifest_file = "lamp.pp"
puppet.manifests_path = "puppet/manifests"
puppet.module_path = "puppet/modules"
puppet.options = ["-‐-‐verbose"]
end
end
our generated Base Box from Packer
Provisioning with Puppet
66. Créateur de
To sum up
• with Vagrant you can create Virtual Machines bases on
Base Boxes very easy
• Packer adds the possibility to create your own Base
Box for those VMs
• It's up to you if you create a Fat or a Thin Base Box
• After creation a Virtual Machine could be provisioned
with Puppet (or place your preferred provisioning tool
here)
67. Créateur de
Need more Information or Help!?
http://sensiolabs.de/workshops/vagrant/
packer build <your own base box>.json … now!
Frank Stelzer
@frastel