Top Banner
Vagrant for Real
99

Vagrant for real (codemotion rome 2016)

Jan 16, 2017

Download

Software

Michele Orselli
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Vagrant for real (codemotion rome 2016)

Vagrant for Real

Michele OrselliCTOIdeato

_orso_

micheleorselli ideatosrl

moideatoit

httpmitchellhcomthe-tao-of-vagrant

1) clone repo

2) vagrant up

3) therersquos no 3

1) clone repo

2) vagrant up

tips

vagrantfile configs vm performance

app config tips provisionpackaging

Portable configuration tips

Donrsquot use local names for your boxes

configvmbox = base

cvmbox = hashicorpprecise64

cvmbox_url = httpyour_box

Avoid absolute paths

cvmsynced_folder ldquomyProjvarwwwmyProj

configvmsynced_folder varwwwmyProj

Move host specific configuration outside

Vagrantfile

ram 2048 cpus 2 ipaddress 10101010

vagrantfile-local-configyml

require lsquoyaml

_config = YAMLload(Fileopen(Filejoin(Filedirname(__FILE__) ldquovagrantfile-local-configymlrdquo) FileRDONLY)read) CONF = _config

configvmprovider virtualbox do |vb| vbcustomize[modifyvmidldquo--memory CONF[ram]] vbcustomize [modifyvmid--cpus CONF[ldquocpus]] hellip end

As rule of thumb you could assign the half cpus and a quarter of the memory based on your host machine

httpsstefanwrobelcomhow-to-make-vagrant-performance-not-suck

Force a specific provider

ENV[VAGRANT_DEFAULT_PROVIDER] = virtualbox

Support multiple providers

configvmprovider virtualbox do |vb| vbcustomize [modifyvmid --memory CONF[ram]] vbcustomize [modifyvmid --cpus CONF[cpus]] end configvmprovider vmware_fusion do |v| vvmx[memsize] = CONF[ram] vvmx[numvcpus] = CONF[cpus] end

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 2: Vagrant for real (codemotion rome 2016)

Michele OrselliCTOIdeato

_orso_

micheleorselli ideatosrl

moideatoit

httpmitchellhcomthe-tao-of-vagrant

1) clone repo

2) vagrant up

3) therersquos no 3

1) clone repo

2) vagrant up

tips

vagrantfile configs vm performance

app config tips provisionpackaging

Portable configuration tips

Donrsquot use local names for your boxes

configvmbox = base

cvmbox = hashicorpprecise64

cvmbox_url = httpyour_box

Avoid absolute paths

cvmsynced_folder ldquomyProjvarwwwmyProj

configvmsynced_folder varwwwmyProj

Move host specific configuration outside

Vagrantfile

ram 2048 cpus 2 ipaddress 10101010

vagrantfile-local-configyml

require lsquoyaml

_config = YAMLload(Fileopen(Filejoin(Filedirname(__FILE__) ldquovagrantfile-local-configymlrdquo) FileRDONLY)read) CONF = _config

configvmprovider virtualbox do |vb| vbcustomize[modifyvmidldquo--memory CONF[ram]] vbcustomize [modifyvmid--cpus CONF[ldquocpus]] hellip end

As rule of thumb you could assign the half cpus and a quarter of the memory based on your host machine

httpsstefanwrobelcomhow-to-make-vagrant-performance-not-suck

Force a specific provider

ENV[VAGRANT_DEFAULT_PROVIDER] = virtualbox

Support multiple providers

configvmprovider virtualbox do |vb| vbcustomize [modifyvmid --memory CONF[ram]] vbcustomize [modifyvmid --cpus CONF[cpus]] end configvmprovider vmware_fusion do |v| vvmx[memsize] = CONF[ram] vvmx[numvcpus] = CONF[cpus] end

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 3: Vagrant for real (codemotion rome 2016)

httpmitchellhcomthe-tao-of-vagrant

1) clone repo

2) vagrant up

3) therersquos no 3

1) clone repo

2) vagrant up

tips

vagrantfile configs vm performance

app config tips provisionpackaging

Portable configuration tips

Donrsquot use local names for your boxes

configvmbox = base

cvmbox = hashicorpprecise64

cvmbox_url = httpyour_box

Avoid absolute paths

cvmsynced_folder ldquomyProjvarwwwmyProj

configvmsynced_folder varwwwmyProj

Move host specific configuration outside

Vagrantfile

ram 2048 cpus 2 ipaddress 10101010

vagrantfile-local-configyml

require lsquoyaml

_config = YAMLload(Fileopen(Filejoin(Filedirname(__FILE__) ldquovagrantfile-local-configymlrdquo) FileRDONLY)read) CONF = _config

configvmprovider virtualbox do |vb| vbcustomize[modifyvmidldquo--memory CONF[ram]] vbcustomize [modifyvmid--cpus CONF[ldquocpus]] hellip end

As rule of thumb you could assign the half cpus and a quarter of the memory based on your host machine

httpsstefanwrobelcomhow-to-make-vagrant-performance-not-suck

Force a specific provider

ENV[VAGRANT_DEFAULT_PROVIDER] = virtualbox

Support multiple providers

configvmprovider virtualbox do |vb| vbcustomize [modifyvmid --memory CONF[ram]] vbcustomize [modifyvmid --cpus CONF[cpus]] end configvmprovider vmware_fusion do |v| vvmx[memsize] = CONF[ram] vvmx[numvcpus] = CONF[cpus] end

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 4: Vagrant for real (codemotion rome 2016)

1) clone repo

2) vagrant up

3) therersquos no 3

1) clone repo

2) vagrant up

tips

vagrantfile configs vm performance

app config tips provisionpackaging

Portable configuration tips

Donrsquot use local names for your boxes

configvmbox = base

cvmbox = hashicorpprecise64

cvmbox_url = httpyour_box

Avoid absolute paths

cvmsynced_folder ldquomyProjvarwwwmyProj

configvmsynced_folder varwwwmyProj

Move host specific configuration outside

Vagrantfile

ram 2048 cpus 2 ipaddress 10101010

vagrantfile-local-configyml

require lsquoyaml

_config = YAMLload(Fileopen(Filejoin(Filedirname(__FILE__) ldquovagrantfile-local-configymlrdquo) FileRDONLY)read) CONF = _config

configvmprovider virtualbox do |vb| vbcustomize[modifyvmidldquo--memory CONF[ram]] vbcustomize [modifyvmid--cpus CONF[ldquocpus]] hellip end

As rule of thumb you could assign the half cpus and a quarter of the memory based on your host machine

httpsstefanwrobelcomhow-to-make-vagrant-performance-not-suck

Force a specific provider

ENV[VAGRANT_DEFAULT_PROVIDER] = virtualbox

Support multiple providers

configvmprovider virtualbox do |vb| vbcustomize [modifyvmid --memory CONF[ram]] vbcustomize [modifyvmid --cpus CONF[cpus]] end configvmprovider vmware_fusion do |v| vvmx[memsize] = CONF[ram] vvmx[numvcpus] = CONF[cpus] end

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 5: Vagrant for real (codemotion rome 2016)

1) clone repo

2) vagrant up

tips

vagrantfile configs vm performance

app config tips provisionpackaging

Portable configuration tips

Donrsquot use local names for your boxes

configvmbox = base

cvmbox = hashicorpprecise64

cvmbox_url = httpyour_box

Avoid absolute paths

cvmsynced_folder ldquomyProjvarwwwmyProj

configvmsynced_folder varwwwmyProj

Move host specific configuration outside

Vagrantfile

ram 2048 cpus 2 ipaddress 10101010

vagrantfile-local-configyml

require lsquoyaml

_config = YAMLload(Fileopen(Filejoin(Filedirname(__FILE__) ldquovagrantfile-local-configymlrdquo) FileRDONLY)read) CONF = _config

configvmprovider virtualbox do |vb| vbcustomize[modifyvmidldquo--memory CONF[ram]] vbcustomize [modifyvmid--cpus CONF[ldquocpus]] hellip end

As rule of thumb you could assign the half cpus and a quarter of the memory based on your host machine

httpsstefanwrobelcomhow-to-make-vagrant-performance-not-suck

Force a specific provider

ENV[VAGRANT_DEFAULT_PROVIDER] = virtualbox

Support multiple providers

configvmprovider virtualbox do |vb| vbcustomize [modifyvmid --memory CONF[ram]] vbcustomize [modifyvmid --cpus CONF[cpus]] end configvmprovider vmware_fusion do |v| vvmx[memsize] = CONF[ram] vvmx[numvcpus] = CONF[cpus] end

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 6: Vagrant for real (codemotion rome 2016)

tips

vagrantfile configs vm performance

app config tips provisionpackaging

Portable configuration tips

Donrsquot use local names for your boxes

configvmbox = base

cvmbox = hashicorpprecise64

cvmbox_url = httpyour_box

Avoid absolute paths

cvmsynced_folder ldquomyProjvarwwwmyProj

configvmsynced_folder varwwwmyProj

Move host specific configuration outside

Vagrantfile

ram 2048 cpus 2 ipaddress 10101010

vagrantfile-local-configyml

require lsquoyaml

_config = YAMLload(Fileopen(Filejoin(Filedirname(__FILE__) ldquovagrantfile-local-configymlrdquo) FileRDONLY)read) CONF = _config

configvmprovider virtualbox do |vb| vbcustomize[modifyvmidldquo--memory CONF[ram]] vbcustomize [modifyvmid--cpus CONF[ldquocpus]] hellip end

As rule of thumb you could assign the half cpus and a quarter of the memory based on your host machine

httpsstefanwrobelcomhow-to-make-vagrant-performance-not-suck

Force a specific provider

ENV[VAGRANT_DEFAULT_PROVIDER] = virtualbox

Support multiple providers

configvmprovider virtualbox do |vb| vbcustomize [modifyvmid --memory CONF[ram]] vbcustomize [modifyvmid --cpus CONF[cpus]] end configvmprovider vmware_fusion do |v| vvmx[memsize] = CONF[ram] vvmx[numvcpus] = CONF[cpus] end

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 7: Vagrant for real (codemotion rome 2016)

vagrantfile configs vm performance

app config tips provisionpackaging

Portable configuration tips

Donrsquot use local names for your boxes

configvmbox = base

cvmbox = hashicorpprecise64

cvmbox_url = httpyour_box

Avoid absolute paths

cvmsynced_folder ldquomyProjvarwwwmyProj

configvmsynced_folder varwwwmyProj

Move host specific configuration outside

Vagrantfile

ram 2048 cpus 2 ipaddress 10101010

vagrantfile-local-configyml

require lsquoyaml

_config = YAMLload(Fileopen(Filejoin(Filedirname(__FILE__) ldquovagrantfile-local-configymlrdquo) FileRDONLY)read) CONF = _config

configvmprovider virtualbox do |vb| vbcustomize[modifyvmidldquo--memory CONF[ram]] vbcustomize [modifyvmid--cpus CONF[ldquocpus]] hellip end

As rule of thumb you could assign the half cpus and a quarter of the memory based on your host machine

httpsstefanwrobelcomhow-to-make-vagrant-performance-not-suck

Force a specific provider

ENV[VAGRANT_DEFAULT_PROVIDER] = virtualbox

Support multiple providers

configvmprovider virtualbox do |vb| vbcustomize [modifyvmid --memory CONF[ram]] vbcustomize [modifyvmid --cpus CONF[cpus]] end configvmprovider vmware_fusion do |v| vvmx[memsize] = CONF[ram] vvmx[numvcpus] = CONF[cpus] end

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 8: Vagrant for real (codemotion rome 2016)

Portable configuration tips

Donrsquot use local names for your boxes

configvmbox = base

cvmbox = hashicorpprecise64

cvmbox_url = httpyour_box

Avoid absolute paths

cvmsynced_folder ldquomyProjvarwwwmyProj

configvmsynced_folder varwwwmyProj

Move host specific configuration outside

Vagrantfile

ram 2048 cpus 2 ipaddress 10101010

vagrantfile-local-configyml

require lsquoyaml

_config = YAMLload(Fileopen(Filejoin(Filedirname(__FILE__) ldquovagrantfile-local-configymlrdquo) FileRDONLY)read) CONF = _config

configvmprovider virtualbox do |vb| vbcustomize[modifyvmidldquo--memory CONF[ram]] vbcustomize [modifyvmid--cpus CONF[ldquocpus]] hellip end

As rule of thumb you could assign the half cpus and a quarter of the memory based on your host machine

httpsstefanwrobelcomhow-to-make-vagrant-performance-not-suck

Force a specific provider

ENV[VAGRANT_DEFAULT_PROVIDER] = virtualbox

Support multiple providers

configvmprovider virtualbox do |vb| vbcustomize [modifyvmid --memory CONF[ram]] vbcustomize [modifyvmid --cpus CONF[cpus]] end configvmprovider vmware_fusion do |v| vvmx[memsize] = CONF[ram] vvmx[numvcpus] = CONF[cpus] end

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 9: Vagrant for real (codemotion rome 2016)

Donrsquot use local names for your boxes

configvmbox = base

cvmbox = hashicorpprecise64

cvmbox_url = httpyour_box

Avoid absolute paths

cvmsynced_folder ldquomyProjvarwwwmyProj

configvmsynced_folder varwwwmyProj

Move host specific configuration outside

Vagrantfile

ram 2048 cpus 2 ipaddress 10101010

vagrantfile-local-configyml

require lsquoyaml

_config = YAMLload(Fileopen(Filejoin(Filedirname(__FILE__) ldquovagrantfile-local-configymlrdquo) FileRDONLY)read) CONF = _config

configvmprovider virtualbox do |vb| vbcustomize[modifyvmidldquo--memory CONF[ram]] vbcustomize [modifyvmid--cpus CONF[ldquocpus]] hellip end

As rule of thumb you could assign the half cpus and a quarter of the memory based on your host machine

httpsstefanwrobelcomhow-to-make-vagrant-performance-not-suck

Force a specific provider

ENV[VAGRANT_DEFAULT_PROVIDER] = virtualbox

Support multiple providers

configvmprovider virtualbox do |vb| vbcustomize [modifyvmid --memory CONF[ram]] vbcustomize [modifyvmid --cpus CONF[cpus]] end configvmprovider vmware_fusion do |v| vvmx[memsize] = CONF[ram] vvmx[numvcpus] = CONF[cpus] end

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 10: Vagrant for real (codemotion rome 2016)

cvmbox = hashicorpprecise64

cvmbox_url = httpyour_box

Avoid absolute paths

cvmsynced_folder ldquomyProjvarwwwmyProj

configvmsynced_folder varwwwmyProj

Move host specific configuration outside

Vagrantfile

ram 2048 cpus 2 ipaddress 10101010

vagrantfile-local-configyml

require lsquoyaml

_config = YAMLload(Fileopen(Filejoin(Filedirname(__FILE__) ldquovagrantfile-local-configymlrdquo) FileRDONLY)read) CONF = _config

configvmprovider virtualbox do |vb| vbcustomize[modifyvmidldquo--memory CONF[ram]] vbcustomize [modifyvmid--cpus CONF[ldquocpus]] hellip end

As rule of thumb you could assign the half cpus and a quarter of the memory based on your host machine

httpsstefanwrobelcomhow-to-make-vagrant-performance-not-suck

Force a specific provider

ENV[VAGRANT_DEFAULT_PROVIDER] = virtualbox

Support multiple providers

configvmprovider virtualbox do |vb| vbcustomize [modifyvmid --memory CONF[ram]] vbcustomize [modifyvmid --cpus CONF[cpus]] end configvmprovider vmware_fusion do |v| vvmx[memsize] = CONF[ram] vvmx[numvcpus] = CONF[cpus] end

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 11: Vagrant for real (codemotion rome 2016)

cvmbox_url = httpyour_box

Avoid absolute paths

cvmsynced_folder ldquomyProjvarwwwmyProj

configvmsynced_folder varwwwmyProj

Move host specific configuration outside

Vagrantfile

ram 2048 cpus 2 ipaddress 10101010

vagrantfile-local-configyml

require lsquoyaml

_config = YAMLload(Fileopen(Filejoin(Filedirname(__FILE__) ldquovagrantfile-local-configymlrdquo) FileRDONLY)read) CONF = _config

configvmprovider virtualbox do |vb| vbcustomize[modifyvmidldquo--memory CONF[ram]] vbcustomize [modifyvmid--cpus CONF[ldquocpus]] hellip end

As rule of thumb you could assign the half cpus and a quarter of the memory based on your host machine

httpsstefanwrobelcomhow-to-make-vagrant-performance-not-suck

Force a specific provider

ENV[VAGRANT_DEFAULT_PROVIDER] = virtualbox

Support multiple providers

configvmprovider virtualbox do |vb| vbcustomize [modifyvmid --memory CONF[ram]] vbcustomize [modifyvmid --cpus CONF[cpus]] end configvmprovider vmware_fusion do |v| vvmx[memsize] = CONF[ram] vvmx[numvcpus] = CONF[cpus] end

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 12: Vagrant for real (codemotion rome 2016)

Avoid absolute paths

cvmsynced_folder ldquomyProjvarwwwmyProj

configvmsynced_folder varwwwmyProj

Move host specific configuration outside

Vagrantfile

ram 2048 cpus 2 ipaddress 10101010

vagrantfile-local-configyml

require lsquoyaml

_config = YAMLload(Fileopen(Filejoin(Filedirname(__FILE__) ldquovagrantfile-local-configymlrdquo) FileRDONLY)read) CONF = _config

configvmprovider virtualbox do |vb| vbcustomize[modifyvmidldquo--memory CONF[ram]] vbcustomize [modifyvmid--cpus CONF[ldquocpus]] hellip end

As rule of thumb you could assign the half cpus and a quarter of the memory based on your host machine

httpsstefanwrobelcomhow-to-make-vagrant-performance-not-suck

Force a specific provider

ENV[VAGRANT_DEFAULT_PROVIDER] = virtualbox

Support multiple providers

configvmprovider virtualbox do |vb| vbcustomize [modifyvmid --memory CONF[ram]] vbcustomize [modifyvmid --cpus CONF[cpus]] end configvmprovider vmware_fusion do |v| vvmx[memsize] = CONF[ram] vvmx[numvcpus] = CONF[cpus] end

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 13: Vagrant for real (codemotion rome 2016)

cvmsynced_folder ldquomyProjvarwwwmyProj

configvmsynced_folder varwwwmyProj

Move host specific configuration outside

Vagrantfile

ram 2048 cpus 2 ipaddress 10101010

vagrantfile-local-configyml

require lsquoyaml

_config = YAMLload(Fileopen(Filejoin(Filedirname(__FILE__) ldquovagrantfile-local-configymlrdquo) FileRDONLY)read) CONF = _config

configvmprovider virtualbox do |vb| vbcustomize[modifyvmidldquo--memory CONF[ram]] vbcustomize [modifyvmid--cpus CONF[ldquocpus]] hellip end

As rule of thumb you could assign the half cpus and a quarter of the memory based on your host machine

httpsstefanwrobelcomhow-to-make-vagrant-performance-not-suck

Force a specific provider

ENV[VAGRANT_DEFAULT_PROVIDER] = virtualbox

Support multiple providers

configvmprovider virtualbox do |vb| vbcustomize [modifyvmid --memory CONF[ram]] vbcustomize [modifyvmid --cpus CONF[cpus]] end configvmprovider vmware_fusion do |v| vvmx[memsize] = CONF[ram] vvmx[numvcpus] = CONF[cpus] end

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 14: Vagrant for real (codemotion rome 2016)

configvmsynced_folder varwwwmyProj

Move host specific configuration outside

Vagrantfile

ram 2048 cpus 2 ipaddress 10101010

vagrantfile-local-configyml

require lsquoyaml

_config = YAMLload(Fileopen(Filejoin(Filedirname(__FILE__) ldquovagrantfile-local-configymlrdquo) FileRDONLY)read) CONF = _config

configvmprovider virtualbox do |vb| vbcustomize[modifyvmidldquo--memory CONF[ram]] vbcustomize [modifyvmid--cpus CONF[ldquocpus]] hellip end

As rule of thumb you could assign the half cpus and a quarter of the memory based on your host machine

httpsstefanwrobelcomhow-to-make-vagrant-performance-not-suck

Force a specific provider

ENV[VAGRANT_DEFAULT_PROVIDER] = virtualbox

Support multiple providers

configvmprovider virtualbox do |vb| vbcustomize [modifyvmid --memory CONF[ram]] vbcustomize [modifyvmid --cpus CONF[cpus]] end configvmprovider vmware_fusion do |v| vvmx[memsize] = CONF[ram] vvmx[numvcpus] = CONF[cpus] end

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 15: Vagrant for real (codemotion rome 2016)

Move host specific configuration outside

Vagrantfile

ram 2048 cpus 2 ipaddress 10101010

vagrantfile-local-configyml

require lsquoyaml

_config = YAMLload(Fileopen(Filejoin(Filedirname(__FILE__) ldquovagrantfile-local-configymlrdquo) FileRDONLY)read) CONF = _config

configvmprovider virtualbox do |vb| vbcustomize[modifyvmidldquo--memory CONF[ram]] vbcustomize [modifyvmid--cpus CONF[ldquocpus]] hellip end

As rule of thumb you could assign the half cpus and a quarter of the memory based on your host machine

httpsstefanwrobelcomhow-to-make-vagrant-performance-not-suck

Force a specific provider

ENV[VAGRANT_DEFAULT_PROVIDER] = virtualbox

Support multiple providers

configvmprovider virtualbox do |vb| vbcustomize [modifyvmid --memory CONF[ram]] vbcustomize [modifyvmid --cpus CONF[cpus]] end configvmprovider vmware_fusion do |v| vvmx[memsize] = CONF[ram] vvmx[numvcpus] = CONF[cpus] end

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 16: Vagrant for real (codemotion rome 2016)

ram 2048 cpus 2 ipaddress 10101010

vagrantfile-local-configyml

require lsquoyaml

_config = YAMLload(Fileopen(Filejoin(Filedirname(__FILE__) ldquovagrantfile-local-configymlrdquo) FileRDONLY)read) CONF = _config

configvmprovider virtualbox do |vb| vbcustomize[modifyvmidldquo--memory CONF[ram]] vbcustomize [modifyvmid--cpus CONF[ldquocpus]] hellip end

As rule of thumb you could assign the half cpus and a quarter of the memory based on your host machine

httpsstefanwrobelcomhow-to-make-vagrant-performance-not-suck

Force a specific provider

ENV[VAGRANT_DEFAULT_PROVIDER] = virtualbox

Support multiple providers

configvmprovider virtualbox do |vb| vbcustomize [modifyvmid --memory CONF[ram]] vbcustomize [modifyvmid --cpus CONF[cpus]] end configvmprovider vmware_fusion do |v| vvmx[memsize] = CONF[ram] vvmx[numvcpus] = CONF[cpus] end

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 17: Vagrant for real (codemotion rome 2016)

require lsquoyaml

_config = YAMLload(Fileopen(Filejoin(Filedirname(__FILE__) ldquovagrantfile-local-configymlrdquo) FileRDONLY)read) CONF = _config

configvmprovider virtualbox do |vb| vbcustomize[modifyvmidldquo--memory CONF[ram]] vbcustomize [modifyvmid--cpus CONF[ldquocpus]] hellip end

As rule of thumb you could assign the half cpus and a quarter of the memory based on your host machine

httpsstefanwrobelcomhow-to-make-vagrant-performance-not-suck

Force a specific provider

ENV[VAGRANT_DEFAULT_PROVIDER] = virtualbox

Support multiple providers

configvmprovider virtualbox do |vb| vbcustomize [modifyvmid --memory CONF[ram]] vbcustomize [modifyvmid --cpus CONF[cpus]] end configvmprovider vmware_fusion do |v| vvmx[memsize] = CONF[ram] vvmx[numvcpus] = CONF[cpus] end

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 18: Vagrant for real (codemotion rome 2016)

As rule of thumb you could assign the half cpus and a quarter of the memory based on your host machine

httpsstefanwrobelcomhow-to-make-vagrant-performance-not-suck

Force a specific provider

ENV[VAGRANT_DEFAULT_PROVIDER] = virtualbox

Support multiple providers

configvmprovider virtualbox do |vb| vbcustomize [modifyvmid --memory CONF[ram]] vbcustomize [modifyvmid --cpus CONF[cpus]] end configvmprovider vmware_fusion do |v| vvmx[memsize] = CONF[ram] vvmx[numvcpus] = CONF[cpus] end

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 19: Vagrant for real (codemotion rome 2016)

Force a specific provider

ENV[VAGRANT_DEFAULT_PROVIDER] = virtualbox

Support multiple providers

configvmprovider virtualbox do |vb| vbcustomize [modifyvmid --memory CONF[ram]] vbcustomize [modifyvmid --cpus CONF[cpus]] end configvmprovider vmware_fusion do |v| vvmx[memsize] = CONF[ram] vvmx[numvcpus] = CONF[cpus] end

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 20: Vagrant for real (codemotion rome 2016)

ENV[VAGRANT_DEFAULT_PROVIDER] = virtualbox

Support multiple providers

configvmprovider virtualbox do |vb| vbcustomize [modifyvmid --memory CONF[ram]] vbcustomize [modifyvmid --cpus CONF[cpus]] end configvmprovider vmware_fusion do |v| vvmx[memsize] = CONF[ram] vvmx[numvcpus] = CONF[cpus] end

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 21: Vagrant for real (codemotion rome 2016)

Support multiple providers

configvmprovider virtualbox do |vb| vbcustomize [modifyvmid --memory CONF[ram]] vbcustomize [modifyvmid --cpus CONF[cpus]] end configvmprovider vmware_fusion do |v| vvmx[memsize] = CONF[ram] vvmx[numvcpus] = CONF[cpus] end

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 22: Vagrant for real (codemotion rome 2016)

configvmprovider virtualbox do |vb| vbcustomize [modifyvmid --memory CONF[ram]] vbcustomize [modifyvmid --cpus CONF[cpus]] end configvmprovider vmware_fusion do |v| vvmx[memsize] = CONF[ram] vvmx[numvcpus] = CONF[cpus] end

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 23: Vagrant for real (codemotion rome 2016)

Projectrsquos directories organization

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 24: Vagrant for real (codemotion rome 2016)

myproject -- hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquordquordquovarwwwmyproject

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 25: Vagrant for real (codemotion rome 2016)

myproject -- project --hellip -- vagrant -- Vagrantfile

single git repository

cvmsynced_folder ldquoprojectrdquordquovarwwwprojectrdquo

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 26: Vagrant for real (codemotion rome 2016)

myproject -- vagrant -- www -- project1 -- project2 -- Vagrantfile

singlemultiple git repositories

cvmsynced_folder ldquowwwrdquordquovarwwwrdquo

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 27: Vagrant for real (codemotion rome 2016)

vagrant plugin install HostsUpdater

(or HostManager)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 28: Vagrant for real (codemotion rome 2016)

etchosts

10101040 host1lo VAGRANT e2bca7c8bf6d76cbcf6ee48998c16f

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 29: Vagrant for real (codemotion rome 2016)

if Vagranthas_plugin(HostsUpdater) confighostsupdateraliases = [host1lo] else puts --- WARNING --- puts ldquoYou should install HostsUpdaterrdquo end

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 30: Vagrant for real (codemotion rome 2016)

Multi-VM Configuration

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 31: Vagrant for real (codemotion rome 2016)

configvmdefine web do |web| webvmnetwork private_network ip 10002 webvmprovider virtualbox do |v| vcustomize [modifyvm id --memory 2048] end webvmsynced_folder ldquovarwww end configvmdefine db do |db| dbvmnetwork private_network ip 10003 dbvmprovision shell path =gt vagrantdbsh end

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 32: Vagrant for real (codemotion rome 2016)

Dealing with shared folders

no share

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 33: 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 testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 34: Vagrant for real (codemotion rome 2016)

native share- slow - os indipendent-ish

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 35: Vagrant for real (codemotion rome 2016)

nfs- fast - win support -(

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 36: Vagrant for real (codemotion rome 2016)

rsync- no real share - update

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 37: Vagrant for real (codemotion rome 2016)

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 38: Vagrant for real (codemotion rome 2016)

run testshellip

still runninghellip

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 39: Vagrant for real (codemotion rome 2016)

mitchellhcomcomparing-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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 40: Vagrant for real (codemotion rome 2016)

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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 41: Vagrant for real (codemotion rome 2016)

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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 42: Vagrant for real (codemotion rome 2016)

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 Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 43: Vagrant for real (codemotion rome 2016)

use nfs if you can

vagrant plugin install vbguest

keeps guest addition updated

unless Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 44: Vagrant for real (codemotion rome 2016)

vagrant plugin install vbguest

keeps guest addition updated

unless Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 45: Vagrant for real (codemotion rome 2016)

unless Vagranthas_plugin(ldquovagrant-vbguest) raise rdquoplease install vagrant-vbguestrdquo end

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 46: Vagrant for real (codemotion rome 2016)

On VM IO is the bottleneck

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 47: Vagrant for real (codemotion rome 2016)

loading webpages running testsuites are READ heavy

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 48: Vagrant for real (codemotion rome 2016)

move IO 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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 49: Vagrant for real (codemotion rome 2016)

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

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 50: Vagrant for real (codemotion rome 2016)

IO logs cache

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 51: Vagrant for real (codemotion rome 2016)

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 52: Vagrant for real (codemotion rome 2016)

class AppKernel extends Kernel public function getCacheDir() if (in_array($this-gtenvironment array(dev test))) return devshmappnamecache $this-gtenvironment

return parentgetCacheDir()

public function getLogDir() if (in_array($this-gtenvironment array(dev lsquotest))) return devshmappnamelogs

return parentgetLogDir()

+13-16

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 53: Vagrant for real (codemotion rome 2016)

IO move DB on RAMif you use sqlite move it on devshm

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 54: Vagrant for real (codemotion rome 2016)

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 55: Vagrant for real (codemotion rome 2016)

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 56: Vagrant for real (codemotion rome 2016)

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

configcachesynced_folder_opts = type nfs mount_options [rwvers=3tcpnolock] end

Vagrantfile

+30for 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=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 57: Vagrant for real (codemotion rome 2016)

use cachefilesd for nfs

- name Install cachefilesd apt pkg=cachefilesd state=present

- name Enable cachefilesd lineinfile dest=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 58: Vagrant for real (codemotion rome 2016)

- name Install cachefilesd apt pkg=cachefilesd state=present

- name Enable cachefilesd lineinfile dest=etcdefaultcachefilesd line=ldquoRUN=yesrdquo

- name Start cachefilesd service service name=cachefilesd state=restarted

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 59: Vagrant for real (codemotion rome 2016)

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 60: Vagrant for real (codemotion rome 2016)

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [rwvers=3tcpfsc]

Vagrantfile

-15+10

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 61: Vagrant for real (codemotion rome 2016)

should you trust these numbers

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 62: Vagrant for real (codemotion rome 2016)

Application Management

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 63: Vagrant for real (codemotion rome 2016)

How to access mysql

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 64: Vagrant for real (codemotion rome 2016)

- name add mysql user mysql_user name=ideato host= password=ideato priv=ALLGRANT login_user=root login_password=

- name config bind address to allow remote remote connections lineinfile dest=etcmysqlmycnf state=present regexp=bind-address = 127001 line=bind-address = 0000 backup=yes

- name restart mysql service name=mysql state=restarted

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 65: Vagrant for real (codemotion rome 2016)

Permissions management in shared folders

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 66: Vagrant for real (codemotion rome 2016)

configvmsynced_folder varwww id vagrant-root owner vagrant group vagrant mount_options [dmode=777fmode=777]

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 67: Vagrant for real (codemotion rome 2016)

Use host ssh keys

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 68: Vagrant for real (codemotion rome 2016)

configsshforward_agent = true

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 69: Vagrant for real (codemotion rome 2016)

ForwardAgent yes

check ssh config file in your host machine

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 70: Vagrant for real (codemotion rome 2016)

gruntgulp watch

httpwwwsebastien-hanfrblog20121218noac-performance-impact-on-web-applications

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 71: Vagrant for real (codemotion rome 2016)

configvmsynced_folder varwww id ldquovagrant-rootrdquo type ldquonfsrdquo mount_options [lsquorwrsquovers=3tcpfsc actimeo=1]

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 72: Vagrant for real (codemotion rome 2016)

Provisioning

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 73: Vagrant for real (codemotion rome 2016)

to phansible or not to phansible

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 74: Vagrant for real (codemotion rome 2016)

quick and easy way to start

theyrsquore general

old platforms are not supported

a lot of a good ideas you can steal from

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 75: Vagrant for real (codemotion rome 2016)

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 76: Vagrant for real (codemotion rome 2016)

can you assume everyone in your team have the same version

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 77: Vagrant for real (codemotion rome 2016)

if which(ansible-playbook) configvmprovision ansible do |ansible| ansibleplaybook = ansibleplaybookyml ansibleinventory_path = ansibleinventoriesdev ansiblelimit = all ansibleextra_vars = private_interface 1921683399 hostname default end else configvmprovision shell path ansiblewindowssh args [default] end

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 78: Vagrant for real (codemotion rome 2016)

the provisioning tool is a moving part wanna update be careful

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 79: Vagrant for real (codemotion rome 2016)

create Vagrant indipendent provision

scripts

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 80: Vagrant for real (codemotion rome 2016)

configvmprovision shell path =gt scriptsbootstrapsh args =gt varwww

configvmprovision shell path =gt ldquoscriptsprovisionsh args =gt varwww

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 81: Vagrant for real (codemotion rome 2016)

create your own template

httpsgithubcomideatosrlvagrant-php-template

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 82: Vagrant for real (codemotion rome 2016)

yoursquore 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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 83: Vagrant for real (codemotion rome 2016)

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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 84: Vagrant for real (codemotion rome 2016)

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

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 85: Vagrant for real (codemotion rome 2016)

live on the edge and fix provision script

use stable package repositories

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 86: Vagrant for real (codemotion rome 2016)

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 87: Vagrant for real (codemotion rome 2016)

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 88: Vagrant for real (codemotion rome 2016)

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

- Donrsquot 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

moideatoit

Page 89: Vagrant for real (codemotion rome 2016)

- Donrsquot 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

moideatoit

Page 90: Vagrant for real (codemotion rome 2016)

Keep it simple

Thank you

_orso_

micheleorselli ideatosrl

moideatoit

Page 91: Vagrant for real (codemotion rome 2016)

Thank you

_orso_

micheleorselli ideatosrl

moideatoit