vagrant for real codemotion (moar tips! ;-))

105
Vagrant for Real

Upload: michele-orselli

Post on 12-Apr-2017

675 views

Category:

Software


3 download

TRANSCRIPT

Page 1: Vagrant for real codemotion (moar tips! ;-))

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

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 2: Vagrant for real codemotion (moar tips! ;-))

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

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 3: Vagrant for real codemotion (moar tips! ;-))

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

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 4: Vagrant for real codemotion (moar tips! ;-))

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

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 5: Vagrant for real codemotion (moar tips! ;-))

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

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 6: Vagrant for real codemotion (moar tips! ;-))

tips

vagrantfile configs vm performance

app config tips provisionpackaging

Portable configuration tips

Donrsquot use local names for your boxes

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 7: Vagrant for real codemotion (moar tips! ;-))

vagrantfile configs vm performance

app config tips provisionpackaging

Portable configuration tips

Donrsquot use local names for your boxes

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 8: Vagrant for real codemotion (moar tips! ;-))

Portable configuration tips

Donrsquot use local names for your boxes

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 9: Vagrant for real codemotion (moar tips! ;-))

Donrsquot use local names for your boxes

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 10: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 11: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 12: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 13: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 14: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 15: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 16: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 17: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 18: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 19: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 20: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 21: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 22: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 23: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 24: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 25: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 26: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 27: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 28: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 29: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 30: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 31: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 32: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 33: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 34: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 35: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 36: Vagrant for real codemotion (moar tips! ;-))

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 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 37: Vagrant for real codemotion (moar tips! ;-))

VM Performance

run testshellip

still runninghellip

mitchellhcomcomparing-filesystem-performance-in-virtual-machines

Virtualbox vs VmWare

Virtualbox 22 min

VmWare 15 min

Virtualbox 22 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 38: Vagrant for real codemotion (moar tips! ;-))

run testshellip

still runninghellip

mitchellhcomcomparing-filesystem-performance-in-virtual-machines

Virtualbox vs VmWare

Virtualbox 22 min

VmWare 15 min

Virtualbox 22 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 39: Vagrant for real codemotion (moar tips! ;-))

mitchellhcomcomparing-filesystem-performance-in-virtual-machines

Virtualbox vs VmWare

Virtualbox 22 min

VmWare 15 min

Virtualbox 22 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 40: Vagrant for real codemotion (moar tips! ;-))

Virtualbox 22 min

VmWare 15 min

Virtualbox 22 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 41: Vagrant for real codemotion (moar tips! ;-))

Virtualbox 22 mi

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 42: Vagrant for real codemotion (moar tips! ;-))

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 43: Vagrant for real codemotion (moar tips! ;-))

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 44: Vagrant for real codemotion (moar tips! ;-))

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 45: Vagrant for real codemotion (moar tips! ;-))

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 46: Vagrant for real codemotion (moar tips! ;-))

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 47: Vagrant for real codemotion (moar tips! ;-))

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 48: Vagrant for real codemotion (moar tips! ;-))

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 49: Vagrant for real codemotion (moar tips! ;-))

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 50: Vagrant for real codemotion (moar tips! ;-))

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 51: Vagrant for real codemotion (moar tips! ;-))

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()

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 52: Vagrant for real codemotion (moar tips! ;-))

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 public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 53: Vagrant for real codemotion (moar tips! ;-))

class public function

public function

+13-16

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 54: Vagrant for real codemotion (moar tips! ;-))

IO increase realpath cache

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 55: Vagrant for real codemotion (moar tips! ;-))

realpath_cache_size = 4096k realpath_cache_ttl = 7200

phpini

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 56: Vagrant for real codemotion (moar tips! ;-))

realpath_cache_size realpath_cache_ttl

phpini

+7

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 57: Vagrant for real codemotion (moar tips! ;-))

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

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 58: Vagrant for real codemotion (moar tips! ;-))

vagrant plugin install vagrantcachier

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

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

Vagrantfile

if

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 59: Vagrant for real codemotion (moar tips! ;-))

if Vagranthas_plugin(vagrant-cachier) configcachescope = box

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

Vagrantfile

if

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 60: Vagrant for real codemotion (moar tips! ;-))

if

configcachesynced_folder_opts type mount_options [ 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 61: Vagrant for real codemotion (moar tips! ;-))

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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 62: Vagrant for real codemotion (moar tips! ;-))

- 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 mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 63: Vagrant for real codemotion (moar tips! ;-))

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

Vagrantfile

configvmsynced_folder mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 64: Vagrant for real codemotion (moar tips! ;-))

configvmsynced_folder mount_options [

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 65: Vagrant for real codemotion (moar tips! ;-))

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 66: Vagrant for real codemotion (moar tips! ;-))

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 67: Vagrant for real codemotion (moar tips! ;-))

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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 68: Vagrant for real codemotion (moar tips! ;-))

- 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

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 69: Vagrant for real codemotion (moar tips! ;-))

- name Install phpmyadmin apt pkg=phpmyadmin state=present

- name Include phpmyadmin in Apache config lineinfile dest=etcapache2apache2conf line=Include etcphpmyadmin apacheconf notify restart apache

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 70: Vagrant for real codemotion (moar tips! ;-))

- name adminer clone git repo=httpsgithubcomvranaadminergit dest=varwwwadminer version=v421 accept_hostkey=true

- name adminer compile command php compilephp chdir=varwwwadminer creates=varwwwadmineradminer-421php

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 71: Vagrant for real codemotion (moar tips! ;-))

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 72: Vagrant for real codemotion (moar tips! ;-))

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 73: Vagrant for real codemotion (moar tips! ;-))

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 74: Vagrant for real codemotion (moar tips! ;-))

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 75: Vagrant for real codemotion (moar tips! ;-))

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 76: Vagrant for real codemotion (moar tips! ;-))

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 77: Vagrant for real codemotion (moar tips! ;-))

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 78: Vagrant for real codemotion (moar tips! ;-))

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 79: Vagrant for real codemotion (moar tips! ;-))

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 80: Vagrant for real codemotion (moar tips! ;-))

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 81: Vagrant for real codemotion (moar tips! ;-))

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 82: Vagrant for real codemotion (moar tips! ;-))

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 83: Vagrant for real codemotion (moar tips! ;-))

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 84: Vagrant for real codemotion (moar tips! ;-))

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 85: Vagrant for real codemotion (moar tips! ;-))

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 86: Vagrant for real codemotion (moar tips! ;-))

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 87: Vagrant for real codemotion (moar tips! ;-))

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 88: Vagrant for real codemotion (moar tips! ;-))

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 89: Vagrant for real codemotion (moar tips! ;-))

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 90: Vagrant for real codemotion (moar tips! ;-))

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 91: Vagrant for real codemotion (moar tips! ;-))

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

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 92: Vagrant for real codemotion (moar tips! ;-))

httpsspeakerdeckcommitchellhvagrant-usage-patterns

Create and distribute your own VM

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 93: Vagrant for real codemotion (moar tips! ;-))

Golden image

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 94: Vagrant for real codemotion (moar tips! ;-))

vagrant package - -name myboxbox

publish it somewhere (http atlas)

cvmbox_url = ldquohttpmyboxboxrdquo

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 95: Vagrant for real codemotion (moar tips! ;-))

Keep it simple

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit

Page 96: Vagrant for real codemotion (moar tips! ;-))

Thank youhttpsjoindin16312

_orso_

micheleorselli ideatosrl

moideatoit