SlideShare a Scribd company logo
Vagrant
for
Real
Michele Orselli
CTO@Ideato
_orso_
micheleorselli / ideatosrl
mo@ideato.it
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)
http://mitchellh.com/the-tao-of-vagrant
1) clone repo
2) vagrant up
3) there’s no #3
Vagrant for real (codemotion rome 2016)
1) clone repo
2) vagrant up
Vagrant for real (codemotion rome 2016)
#tips
vagrantfile configs vm performance
app config tips provision/packaging
Portable configuration
tips
Don’t use local names
for your boxes
config.vm.box = "base"
c.vm.box = "hashicorp/precise64"
c.vm.box_url = "http://your_box"
Avoid absolute paths
c.vm.synced_folder “/myProj","/var/www/myProj"
config.vm.synced_folder "./", "/var/www/myProj"
Move host specific
configuration outside
Vagrantfile
ram: 2048
cpus: 2
ipaddress: 10.10.10.10
vagrantfile-local-config.yml
require ‘yaml'
_config =
YAML.load(File.open(File.join(File.dirname(__FILE__),
“vagrantfile-local-config.yml”), File::RDONLY).read)
CONF = _config
config.vm.provider "virtualbox" do |vb|
vb.customize["modifyvm",:id,“--memory", CONF["ram"]]
vb.customize ["modifyvm",:id,"--cpus", CONF[“cpus"]]
…
end
As rule of thumb you could assign the half cpus and
a quarter of the memory based on your host machine
https://stefanwrobel.com/how-to-make-vagrant-performance-not-suck
Force a specific
provider
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'
Support multiple
providers
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm",:id, "--memory", CONF["ram"]]
vb.customize ["modifyvm",:id, "--cpus", CONF["cpus"]]
end
config.vm.provider "vmware_fusion" do |v|
v.vmx["memsize"] = CONF["ram"]
v.vmx["numvcpus"] = CONF["cpus"]
end
Project’s directories
organization
myproject
-- …
-- vagrant
-- Vagrantfile
single git repository
c.vm.synced_folder “.”,”/var/www/myproject"
myproject
-- project
--…
-- vagrant
-- Vagrantfile
single git repository
c.vm.synced_folder “./project”,”/var/www/
project”
myproject
-- vagrant
-- www
-- project1
-- project2
-- Vagrantfile
single/multiple git repositories
c.vm.synced_folder “./www”,”/var/www”
vagrant plugin install
HostsUpdater
(or HostManager)
# /etc/hosts
10.10.10.40 host1.lo #VAGRANT: e2bca7c8bf6d76cbcf6ee48998c16f
if Vagrant.has_plugin?("HostsUpdater")
config.hostsupdater.aliases = ["host1.lo"]
else
puts "--- WARNING ---"

puts “You should install HostsUpdater”
end
Multi-VM
Configuration
config.vm.define "web" do |web|
web.vm.network :private_network, ip: "10.0.0.2"
web.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--memory", 2048]
end
web.vm.synced_folder "../", “/var/www"
end
config.vm.define "db" do |db|
db.vm.network :private_network, ip: "10.0.0.3"
db.vm.provision :shell, :path => 'vagrant/db.sh'
end
Dealing with shared
folders
Vagrant for real (codemotion rome 2016)
no share
native share
- slow
- os indipendent-ish
nfs
- fast
- win support :-(
rsync
- no real share
- update
VM Performance
run tests…
still running…
mitchellh.com/comparing-filesystem-performance-in-virtual-
machines
Virtualbox vs VmWare
Virtualbox 22 min
VmWare 15 min
Virtualbox 22 min
VmWare 15 min
+30%
use VmWare if you can
(it will cost you a few $)
use nfs if you can*
vagrant plugin install
vbguest
keeps guest addition updated
unless Vagrant.has_plugin?(“vagrant-vbguest")
raise ”please install vagrant-vbguest”
end
On VM I/O is the
bottleneck
loading webpages
running testsuites
are READ heavy
move I/O outside
shared folders
Default provider: virtualbox
3 PHP test suites with unit, functional, integration mix
small (sf1): build runs in ~25 sec
medium (zf2): build runs in ~2 mins
large (sf2): build runs ~ 20 mins
I/O: logs, cache
class AppKernel extends Kernel
{
public function getCacheDir()
{
if (in_array($this->environment, array('dev', 'test')))
{
return '/dev/shm/appname/cache/' . $this->environment;
}
return parent::getCacheDir();
}
public function getLogDir()
{
if (in_array($this->environment, array('dev', ‘test')))
{
return '/dev/shm/appname/logs';
}
return parent::getLogDir();
}
}
class AppKernel extends Kernel
{
public function getCacheDir()
{
if (in_array($this->environment, array('dev', 'test')))
{
return '/dev/shm/appname/cache/' . $this->environment;
}
return parent::getCacheDir();
}
public function getLogDir()
{
if (in_array($this->environment, array('dev', ‘test')))
{
return '/dev/shm/appname/logs';
}
return parent::getLogDir();
}
}
+13-16%
I/O: move DB on RAM
if you use sqlite move it on /dev/shm
vagrant plugin install
vagrantcachier
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
config.cache.synced_folder_opts = {
type: :nfs,
mount_options: ['rw','vers=3','tcp','nolock']
}
end
Vagrantfile
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
config.cache.synced_folder_opts = {
type: :nfs,
mount_options: ['rw','vers=3','tcp','nolock']
}
end
Vagrantfile
+30%for reprovisioning a box with git, php apache, mysql
use cachefilesd for nfs
- name: Install cachefilesd
apt: pkg=cachefilesd state=present
- name: Enable cachefilesd
lineinfile: dest=/etc/default/cachefilesd
line=“RUN=yes”
- name: Start cachefilesd service
service: name=cachefilesd state=restarted
config.vm.synced_folder "../", "/var/www",
id: “vagrant-root”,
type: “nfs”,
mount_options: ['rw','vers=3','tcp','fsc']
Vagrantfile
config.vm.synced_folder "../", "/var/www",
id: “vagrant-root”,
type: “nfs”,
mount_options: ['rw','vers=3','tcp','fsc']
Vagrantfile
-15%
+10%
should you trust these
numbers?
Vagrant for real (codemotion rome 2016)
Application
Management
How to access mysql
- name: add mysql user
mysql_user: name=ideato
host='%'
password=ideato
priv=*.*:ALL,GRANT
login_user=root
login_password=
- name: config bind address to allow remote remote
connections
lineinfile: dest=/etc/mysql/my.cnf
state=present
regexp='bind-address = 127.0.0.1'
line='bind-address = 0.0.0.0'
backup=yes
- name: restart mysql
service: name=mysql state=restarted
Permissions management
in shared folders
config.vm.synced_folder "../", "/var/www", id:
"vagrant-root", owner: "vagrant", group: "vagrant",
mount_options: ["dmode=777,fmode=777"]
Use host ssh keys
config.ssh.forward_agent = true
ForwardAgent yes
check ssh config file in your host machine
grunt/gulp watch
http://www.sebastien-han.fr/blog/2012/12/18/noac-performance-impact-on-web-
applications/
config.vm.synced_folder "../", "/var/www",
id: “vagrant-root”,
type: “nfs”,
mount_options: [‘rw’,'vers=3','tcp','fsc',
'actimeo=1']
Provisioning
to phansible or not to
phansible?
quick and easy way to start
they’re general
old platforms are not supported
a lot of a good ideas you can steal from
if which('ansible-playbook')
config.vm.provision "ansible" do |ansible|
ansible.playbook = "ansible/playbook.yml"
ansible.inventory_path = "ansible/inventories/dev"
ansible.limit = 'all'
ansible.extra_vars = {
private_interface: "192.168.33.99",
hostname: "default"
}
end
else
config.vm.provision :shell,
path: "ansible/windows.sh", args: ["default"]
end
can you assume everyone in your team
have the same version?
if which('ansible-playbook')
config.vm.provision "ansible" do |ansible|
ansible.playbook = "ansible/playbook.yml"
ansible.inventory_path = "ansible/inventories/dev"
ansible.limit = 'all'
ansible.extra_vars = {
private_interface: "192.168.33.99",
hostname: "default"
}
end
else
config.vm.provision :shell,
path: "ansible/windows.sh", args: ["default"]
end
the provisioning tool is a moving part:
wanna update? be careful
create Vagrant
indipendent provision
scripts
config.vm.provision :shell,
:path => "scripts/bootstrap.sh",
:args => "/var/www"
config.vm.provision :shell,
:path => “scripts/provision.sh",
:args => "/var/www"
create your own template
https://github.com/ideatosrl/vagrant-php-template
you’re in control of provisioning command
you can perform additional checks on
host machine
Distributing VMs
provisioning does not create immutable
vm by default
eg: package update on LTS
live on the edge and fix provision script
use stable package repositories
https://speakerdeck.com/mitchellh/vagrant-usage-patterns
Create and distribute your own VM
Golden image
vagrant package - -name mybox.box
publish it somewhere (http, atlas)
c.vm.box_url = “http://../mybox.box”
- Don’t make assumptions about the host
- Provision first, then bake your own image
- The more moving part the harder will get
Keep it simple
Thank you!
_orso_
micheleorselli / ideatosrl
mo@ideato.it

More Related Content

What's hot (20)

PDF
Introduction to Vagrant
Marcelo Pinheiro
 
PPTX
Vagrant-Overview
Crifkin
 
PDF
Vagrant presentation
Mahmudur Rahman
 
PDF
Vagrant For DevOps
Lalatendu Mohanty
 
PDF
Using Docker with Puppet - PuppetConf 2014
Puppet
 
PPTX
Installaling Puppet Master and Agent
Ranjit Avasarala
 
PDF
Create your very own Development Environment with Vagrant and Packer
frastel
 
PDF
EC2 AMI Factory with Chef, Berkshelf, and Packer
George Miranda
 
PPTX
Ansible: How to Get More Sleep and Require Less Coffee
Sarah Z
 
PDF
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
Puppet
 
PPT
Learn basic ansible using docker
Larry Cai
 
PDF
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Carlos Sanchez
 
PDF
Docker puppetcamp london 2013
Tomas Doran
 
PDF
Preparation study of_docker - (MOSG)
Soshi Nemoto
 
PDF
Instruction: dev environment
Soshi Nemoto
 
PDF
Cialug August 2021
Andrew Denner
 
PDF
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Puppet
 
PDF
Ansible - A 'crowd' introduction
Manuel de la Peña Peña
 
PDF
Deploying PHP Applications with Ansible
Orestes Carracedo
 
ODP
Building (localized) Vagrant boxes with Packer
Cristovao G. Verstraeten
 
Introduction to Vagrant
Marcelo Pinheiro
 
Vagrant-Overview
Crifkin
 
Vagrant presentation
Mahmudur Rahman
 
Vagrant For DevOps
Lalatendu Mohanty
 
Using Docker with Puppet - PuppetConf 2014
Puppet
 
Installaling Puppet Master and Agent
Ranjit Avasarala
 
Create your very own Development Environment with Vagrant and Packer
frastel
 
EC2 AMI Factory with Chef, Berkshelf, and Packer
George Miranda
 
Ansible: How to Get More Sleep and Require Less Coffee
Sarah Z
 
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
Puppet
 
Learn basic ansible using docker
Larry Cai
 
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Carlos Sanchez
 
Docker puppetcamp london 2013
Tomas Doran
 
Preparation study of_docker - (MOSG)
Soshi Nemoto
 
Instruction: dev environment
Soshi Nemoto
 
Cialug August 2021
Andrew Denner
 
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Puppet
 
Ansible - A 'crowd' introduction
Manuel de la Peña Peña
 
Deploying PHP Applications with Ansible
Orestes Carracedo
 
Building (localized) Vagrant boxes with Packer
Cristovao G. Verstraeten
 

Similar to Vagrant for real (codemotion rome 2016) (20)

PDF
Vagrant for real
Michele Orselli
 
PDF
Continuous Delivery: The Next Frontier
Carlos Sanchez
 
PPTX
Environments line-up! Vagrant & Puppet 101
jelrikvh
 
PDF
Intro to vagrant
Mantas Klasavicius
 
PDF
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Carlos Sanchez
 
PDF
FreeBSD: Dev to Prod
Sean Chittenden
 
PPTX
Harmonious Development: Via Vagrant and Puppet
Achieve Internet
 
PDF
EC2
Igor Kapkov
 
PPT
Python Deployment with Fabric
andymccurdy
 
PPTX
Vagrant introduction for Developers
Antons Kranga
 
PDF
Using Vagrant for Local WordPress Development
slicejack
 
PDF
Minicurso de Vagrant
Leandro Nunes
 
PDF
Vagrant - Version control your dev environment
bocribbz
 
PDF
infra-as-code
Itamar Hassin
 
PDF
Burn down the silos! Helping dev and ops gel on high availability websites
Lindsay Holmwood
 
PDF
Quick & Easy Dev Environments with Vagrant
Joe Ferguson
 
PPTX
Vagrant WordCamp Hamilton
Paul Bearne
 
KEY
Railsconf2011 deployment tips_for_slideshare
tomcopeland
 
DOC
X64服务器 lnmp服务器部署标准 new
Yiwei Ma
 
PDF
Create Development and Production Environments with Vagrant
Brian Hogan
 
Vagrant for real
Michele Orselli
 
Continuous Delivery: The Next Frontier
Carlos Sanchez
 
Environments line-up! Vagrant & Puppet 101
jelrikvh
 
Intro to vagrant
Mantas Klasavicius
 
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Carlos Sanchez
 
FreeBSD: Dev to Prod
Sean Chittenden
 
Harmonious Development: Via Vagrant and Puppet
Achieve Internet
 
Python Deployment with Fabric
andymccurdy
 
Vagrant introduction for Developers
Antons Kranga
 
Using Vagrant for Local WordPress Development
slicejack
 
Minicurso de Vagrant
Leandro Nunes
 
Vagrant - Version control your dev environment
bocribbz
 
infra-as-code
Itamar Hassin
 
Burn down the silos! Helping dev and ops gel on high availability websites
Lindsay Holmwood
 
Quick & Easy Dev Environments with Vagrant
Joe Ferguson
 
Vagrant WordCamp Hamilton
Paul Bearne
 
Railsconf2011 deployment tips_for_slideshare
tomcopeland
 
X64服务器 lnmp服务器部署标准 new
Yiwei Ma
 
Create Development and Production Environments with Vagrant
Brian Hogan
 
Ad

More from Michele Orselli (20)

PDF
Tackling Tech Debt with Rector
Michele Orselli
 
PDF
Comunicare, condividere e mantenere decisioni architetturali nei team di svil...
Michele Orselli
 
PDF
A dive into Symfony 4
Michele Orselli
 
PDF
A recommendation engine for your applications codemotion ams
Michele Orselli
 
PDF
A recommendation engine for your applications phpday
Michele Orselli
 
PDF
Hopping in clouds - phpuk 17
Michele Orselli
 
PDF
A recommendation engine for your php application
Michele Orselli
 
PDF
Symfony e micro (non così tanto) services
Michele Orselli
 
PDF
Hopping in clouds: a tale of migration from one cloud provider to another
Michele Orselli
 
PDF
Migrare a Symfony 3
Michele Orselli
 
PDF
Implementing data sync apis for mibile apps @cloudconf
Michele Orselli
 
PDF
Server side data sync for mobile apps with silex
Michele Orselli
 
PDF
Continuous, continuous, continuous
Michele Orselli
 
PDF
Deploy a PHP App on Google App Engine
Michele Orselli
 
PDF
Implementing Server Side Data Synchronization for Mobile Apps
Michele Orselli
 
PDF
Deploy a php app on Google App Engine
Michele Orselli
 
PDF
Sf2 wtf
Michele Orselli
 
PDF
Manage a project portfolio
Michele Orselli
 
PDF
Developing sustainable php projects
Michele Orselli
 
PDF
Zend Framework 2 per chi viene da Symfony2
Michele Orselli
 
Tackling Tech Debt with Rector
Michele Orselli
 
Comunicare, condividere e mantenere decisioni architetturali nei team di svil...
Michele Orselli
 
A dive into Symfony 4
Michele Orselli
 
A recommendation engine for your applications codemotion ams
Michele Orselli
 
A recommendation engine for your applications phpday
Michele Orselli
 
Hopping in clouds - phpuk 17
Michele Orselli
 
A recommendation engine for your php application
Michele Orselli
 
Symfony e micro (non così tanto) services
Michele Orselli
 
Hopping in clouds: a tale of migration from one cloud provider to another
Michele Orselli
 
Migrare a Symfony 3
Michele Orselli
 
Implementing data sync apis for mibile apps @cloudconf
Michele Orselli
 
Server side data sync for mobile apps with silex
Michele Orselli
 
Continuous, continuous, continuous
Michele Orselli
 
Deploy a PHP App on Google App Engine
Michele Orselli
 
Implementing Server Side Data Synchronization for Mobile Apps
Michele Orselli
 
Deploy a php app on Google App Engine
Michele Orselli
 
Manage a project portfolio
Michele Orselli
 
Developing sustainable php projects
Michele Orselli
 
Zend Framework 2 per chi viene da Symfony2
Michele Orselli
 
Ad

Recently uploaded (20)

PDF
Understanding the EU Cyber Resilience Act
ICS
 
PDF
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
PDF
Optimizing Tiered Storage for Low-Latency Real-Time Analytics at AI Scale
Alluxio, Inc.
 
PDF
Simplify React app login with asgardeo-sdk
vaibhav289687
 
PDF
custom development enhancement | Togglenow.pdf
aswinisuhu
 
PPT
24-BuildingGUIs Complete Materials in Java.ppt
javidmiakhil63
 
PDF
How Attendance Management Software is Revolutionizing Education.pdf
Pikmykid
 
PDF
Code and No-Code Journeys: The Maintenance Shortcut
Applitools
 
PDF
Meet in the Middle: Solving the Low-Latency Challenge for Agentic AI
Alluxio, Inc.
 
PPTX
Transforming Lending with IntelliGrow – Advanced Loan Software Solutions
Intelli grow
 
PDF
Everything you need to know about pricing & licensing Microsoft 365 Copilot f...
Q-Advise
 
PPTX
Function & Procedure: Function Vs Procedure in PL/SQL
Shani Tiwari
 
PDF
Notification System for Construction Logistics Application
Safe Software
 
PPTX
Cutting Optimization Pro 5.18.2 Crack With Free Download
cracked shares
 
PDF
How to get the licensing right for Microsoft Core Infrastructure Server Suite...
Q-Advise
 
PPTX
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
PDF
Instantiations Company Update (ESUG 2025)
ESUG
 
PPTX
prodad heroglyph crack 2.0.214.2 Full Free Download
cracked shares
 
PDF
Best Insurance Compliance Software for Managing Regulations
Insurance Tech Services
 
PDF
Message Level Status (MLS): The Instant Feedback Mechanism for UAE e-Invoicin...
Prachi Desai
 
Understanding the EU Cyber Resilience Act
ICS
 
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
Optimizing Tiered Storage for Low-Latency Real-Time Analytics at AI Scale
Alluxio, Inc.
 
Simplify React app login with asgardeo-sdk
vaibhav289687
 
custom development enhancement | Togglenow.pdf
aswinisuhu
 
24-BuildingGUIs Complete Materials in Java.ppt
javidmiakhil63
 
How Attendance Management Software is Revolutionizing Education.pdf
Pikmykid
 
Code and No-Code Journeys: The Maintenance Shortcut
Applitools
 
Meet in the Middle: Solving the Low-Latency Challenge for Agentic AI
Alluxio, Inc.
 
Transforming Lending with IntelliGrow – Advanced Loan Software Solutions
Intelli grow
 
Everything you need to know about pricing & licensing Microsoft 365 Copilot f...
Q-Advise
 
Function & Procedure: Function Vs Procedure in PL/SQL
Shani Tiwari
 
Notification System for Construction Logistics Application
Safe Software
 
Cutting Optimization Pro 5.18.2 Crack With Free Download
cracked shares
 
How to get the licensing right for Microsoft Core Infrastructure Server Suite...
Q-Advise
 
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
Instantiations Company Update (ESUG 2025)
ESUG
 
prodad heroglyph crack 2.0.214.2 Full Free Download
cracked shares
 
Best Insurance Compliance Software for Managing Regulations
Insurance Tech Services
 
Message Level Status (MLS): The Instant Feedback Mechanism for UAE e-Invoicin...
Prachi Desai
 

Vagrant for real (codemotion rome 2016)