Vagrant y Puppet son herramientas que permiten crear entornos de desarrollo portables y reproducibles mediante la virtualización y la automatización de la configuración. Vagrant usa máquinas virtuales para ejecutar el mismo sistema operativo y software en diferentes equipos. Puppet automatiza y asegura que la configuración de los sistemas sea consistente mediante manifests que definen los recursos y su estado deseado. Juntos, Vagrant y Puppet ayudan a los desarrolladores a tener entornos idénticos en local y producción.
6. SISTEMA OPERATIVO
¿Qué pasa si yo uso Linux y mi compañero MAC?
Ubuntu: Apt-get
RedHat: Yum
Mac: ¿MAMP? ¿Zend Studio? ¿Macports? ¿Homebrew?
Windows: ¿WAMP? ¿caos?
10. PUESTA EN PRODUCCIÓN (O PRE-
PRODUCCION)
OBSERVACIONES
Diferente sistema operativo.
¿Qué versión de PHP tienes? ¿Y en producción?
¿Qué versión del servidor de BBDD? ¿Y en producción?
¿Y de ese paquete para aquel vendor que usamos?
Los tests en local están todos en verde
15. VAGRANT
Vagrant provides easy to configure,
reproducible, and portable work
environments built on top of industry-
standard technology and controlled by a
single consistent workflow to help maximize
the productivity and flexibility of you and
your team.
16. VAGRANT
¿Qué es?
Herramienta de virtualización
Permite crear y configurar entornos de desarrollo
portables, ligeros y reproducibles
19. VAGRANT
¿CÓMO SE USA?
OTRAS IMÁGENES
http://www.vagrantbox.es
$ vagrant init precise64 http://files.vagrantup.com/precise64.box
$ vagrant up
20. VAGRANT
COMANDOS DISPONIBLES
vagrant up - Arranca la máquina
vagrant halt - Para la máquina
vagrant status - Muestra el estado
vagrant destroy - Elimina la máquina virtual
vagrant ssh - Conecta por ssh
22. VAGRANT
CONFIGURACIÓN
Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network :private_network, ip: "192.168.33.10"
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.provider :virtualbox do |vb|
# Don't boot with headless mode
vb.gui = true
# Use VBoxManage to customize the VM.
vb.customize ["modifyvm", :id, "--cpus", "2"]
vb.customize ["modifyvm", :id, "--memory", "1024"]
end
end
23. PUPPET
Existen varias herramientas de automatización para la
configuración de sistemas
Scripts de shell
Chef (Solo y Client)
Puppet (Apply y Agent)
24. SCRIPTS DE SHELL
VENTAJAS
Cualquier Unix lo trae por defecto
Cualquier Sysadmin lo controla
INCONVENIENTES
Difícil de mantener cuando crece
Todo "a pelo"
Difícil de probar
41. ¿PROBLEMAS?
CLASES SON SINGLETONS
class apache::vhost {
...
}
apache::vhost {'users.example.com':
port => 80,
docroot => '/var/www/personal',
}
apache::vhost {'groups.example.com': } ### FAIL
###################
define apache::vhost(
$port = 80
) {
...
}
apache::vhost {'testhost':
port => 8081,
}
42. ¿PROBLEMAS?
RENDIMIENTO
SYMFONY TIENE + 9000 ARCHIVOS
It’s a long known issue that VirtualBox shared
folder performance degrades quickly as the
number of files in the shared folder increases.
As a project reaches 1000+ files, doing simple
things like running unit tests or even just
running an app server can be many orders of
magnitude slower than on a native filesystem
(e.g. from 5 seconds to over 5 minutes).
43. ¿PROBLEMAS?
RENDIMIENTO
Usar NFS mientras sea posible (Requiere permisos de root)
SO Soporte
Mac Sí (instalado por defecto)
Linux (Ubuntu) Sí (sudo apt-get install nfs-kernel-server)
Windows No
46. ¿CÓMO LO USO EN MIS PROYECTOS?
VALE, ME HAS CONVENCIDO, ¿Y AHORA CÓMO LO USO?
47. ¿CÓMO LO USO EN MIS PROYECTOS?
(Casi) Listo para usar
Módulos completos
Útil en proyectos empezados
HTTPS://PUPHPET.COM
48. ¿CÓMO LO USO EN MIS PROYECTOS?
PROYECTOS NUEVOS
https://github.com/vicentgodella/symfony2-vagrant-
skeleton
git clone git@github.com:vicentgodella/symfony2-vagrant-skeleton.git
composer install
# Añadir al '/etc/hosts':
127.0.0.1 sf2-vagrant.dev
Cargar la url 'http://sf2-vagrant.dev:8080/app_dev.php' en el navegador.