Documente Academic
Documente Profesional
Documente Cultură
for
Real
Michele Orselli
CTO@Ideato
_orso_
micheleorselli / ideatosrl
mo@ideato.it
http://mitchellh.com/the-tao-of-vagrant
1) clone repo
2) vagrant up
3) theres no #3
1) clone repo
2) vagrant up
#tips
vagrantfile configs vm performance
config.vm.box = "base"
c.vm.box = "hashicorp/precise64"
c.vm.box_url = "http://your_box"
Avoid absolute paths
c.vm.synced_folder /myProj","/var/www/myProj"
config.vm.synced_folder "./", "/var/www/myProj"
Move host specific
configuration outside
Vagrantfile
vagrantfile-local-config.yml
ram: 2048
cpus: 2
ipaddress: 10.10.10.10
require yaml'
_config =
YAML.load(File.open(File.join(File.dirname(__FILE__),
vagrantfile-local-config.yml), File::RDONLY).read)
CONF = _config
myproject
--
-- vagrant
-- Vagrantfile
c.vm.synced_folder .,/var/www/myproject"
single git repository
myproject
-- project
--
-- vagrant
-- Vagrantfile
c.vm.synced_folder ./project,/var/www/
project
single/multiple git repositories
myproject
-- vagrant
-- www
-- project1
-- project2
-- Vagrantfile
c.vm.synced_folder ./www,/var/www
vagrant plugin install
HostsUpdater
(or HostManager)
# /etc/hosts
still running
Virtualbox vs VmWare
mitchellh.com/comparing-filesystem-performance-in-virtual-
machines
Virtualbox 22 min
VmWare 15 min
Virtualbox 22 min
+30%
VmWare 15 min
use VmWare if you can
(it will cost you a few $)
use nfs if you can*
vagrant plugin install
vbguest
keeps guest addition updated
unless Vagrant.has_plugin?(vagrant-vbguest")
raise please install vagrant-vbguest
end
On VM I/O is the
bottleneck
loading webpages
running testsuites
are READ heavy
move I/O outside
shared folders
Default provider: virtualbox
return parent::getCacheDir();
}
return parent::getLogDir();
}
}
class AppKernel extends Kernel
{
public function getCacheDir()
{
if (in_array($this->environment, array('dev', 'test')))
{
return '/dev/shm/appname/cache/' . $this->environment;
}
+13-16%
return parent::getCacheDir();
}
return parent::getLogDir();
}
}
I/O: move DB on RAM
if you use sqlite move it on /dev/shm
vagrant plugin install
vagrantcachier
Vagrantfile
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
config.cache.synced_folder_opts = {
type: :nfs,
mount_options: ['rw','vers=3','tcp','nolock']
}
end
Vagrantfile
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
}
end
+30%
config.cache.synced_folder_opts = {
type: :nfs,
mount_options: ['rw','vers=3','tcp','nolock']
-15%
config.vm.synced_folder "../", "/var/www",
id: vagrant-root,
type: nfs,
mount_options: ['rw','vers=3','tcp','fsc']
+10%
should you trust these
numbers?
Application
Management
How to access mysql
- name: add mysql user
mysql_user: name=ideato
host='%'
password=ideato
priv=*.*:ALL,GRANT
login_user=root
login_password=
ForwardAgent yes
grunt/gulp watch
http://www.sebastien-han.fr/blog/2012/12/18/noac-performance-impact-on-web-
applications/
config.vm.synced_folder "../", "/var/www",
id: vagrant-root,
type: nfs,
mount_options: [rw,'vers=3','tcp','fsc',
'actimeo=1']
Provisioning
to phansible or not to
phansible?
quick and easy way to start
theyre general
config.vm.provision :shell,
:path => scripts/provision.sh",
:args => "/var/www"
create your own template
https://github.com/ideatosrl/vagrant-php-template
youre in control of provisioning command
https://speakerdeck.com/mitchellh/vagrant-usage-patterns
Golden image
vagrant package - -name mybox.box
c.vm.box_url = http://../mybox.box
- Dont make assumptions about the host
- Provision first, then bake your own image
- The more moving part the harder will get
Keep it simple
Thank you!
_orso_
micheleorselli / ideatosrl
mo@ideato.it