SlideShare una empresa de Scribd logo
VAGRANT
VIRTUALIZANDO ENTORNOS
     DE DESARROLLO




                  Daniel Vigueras
                  daniel@scalia.es
                  @danielvigueras
ESCENARIO 1
Desarrollador de varios proyectos con diferentes entornos conflictivos
entre sí




  Ruby 1.8         PHP 5.2                         Ruby 1.9                            PHP 5.3
  Rails 1.2        CodeIgniter                     Rails 3.2                           Vevui
  MySQL 4.1        MySQL 5.0                       MySQL 5.5                           MongoDB 2.2



                        Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
ESCENARIO 2

Equipo de desarrollo con diferentes sistemas operativos
XAMP, WAMP, MAMP, LAMP, Apache, Nginx...
Instalar librerías y servicios (Memcached, Redis, MongoDB, Sphinx...)




                        Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
SOLUCIÓN
¡ Usar máquinas virtuales para cada entorno de desarrollo !




                        Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
PROBLEMAS
¿Qué entorno de virtualización elijo?
   ¿VMWare? ¿VirtualBox? ¿KVM? ¿Xen?
¿Cómo creo una máquina virtual?
Me da pereza instalar un nuevo sistema operativo...
¿Cómo comparto el entorno con otras personas?
¿Y si quiero cambiar de entorno de virtualización ?




                        Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
PROBLEMAS
¿Qué entorno de virtualización elijo?
   ¿VMWare? ¿VirtualBox? ¿KVM? ¿Xen?
¿Cómo creo una máquina virtual?
Me da pereza instalar un nuevo sistema operativo...
¿Cómo comparto el entorno con otras personas?
¿Y si quiero cambiar de entorno de virtualización ?




                        Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
PROBLEMAS
¿Qué entorno de virtualización elijo?
   ¿VMWare? ¿VirtualBox? ¿KVM? ¿Xen?
¿Cómo creo una máquina virtual?
Me da pereza instalar un nuevo sistema operativo...
¿Cómo comparto el entorno con otras personas?
¿Y si quiero cambiar de entorno de virtualización ?




Usar herramienta independiente del entorno de virtualización que nos
oculte los detalles


                        Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
SOLUCIÓN: VAGRANT



Crear, iniciar, detener y eliminar VMs de manera sencilla
Escrito en ruby
Open source ( http://github.com/mitchellh/vagrant )
Actualmente sólo es capaz de controlar Oracle VM VirtualBox
En el futuro soportará cualquier entorno mediante plugins
Está siendo usado por varias empresas importantes




                        Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
SOLUCIÓN: VAGRANT



Crear, iniciar, detener y eliminar VMs de manera sencilla
Escrito en ruby
Open source ( http://github.com/mitchellh/vagrant )
Actualmente sólo es capaz de controlar Oracle VM VirtualBox
En el futuro soportará cualquier entorno mediante plugins
Está siendo usado por varias empresas importantes



          « ¡¡ En mi ordenador funciona !! »

                        Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
OBTENER VAGRANT
Descargar e instalar Oracle VM VirtualBox de http://www.virtualbox.org (Última versión 4.2)
Descargar e instalar Vagrant de http://vagrantup.com (Última versión 1.0.4)
Mac (DMG), Linux (DEB, RPM), Windows (MSI)




                                Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
INICIO RÁPIDO (I)




    Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
INICIO RÁPIDO (I)

Añadir una primera imagen como base




                     Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
INICIO RÁPIDO (I)

Añadir una primera imagen como base

$	
  vagrant	
  box	
  add	
  base	
  http://files.vagrantup.com/lucid32.box




                               Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
INICIO RÁPIDO (I)

Añadir una primera imagen como base

 $	
  vagrant	
  box	
  add	
  base	
  http://files.vagrantup.com/lucid32.box



Crear fichero de configuración inicial ( Vagrantfile )




                                Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
INICIO RÁPIDO (I)

Añadir una primera imagen como base

 $	
  vagrant	
  box	
  add	
  base	
  http://files.vagrantup.com/lucid32.box



Crear fichero de configuración inicial ( Vagrantfile )

 $	
  vagrant	
  init




                                Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
INICIO RÁPIDO (I)

Añadir una primera imagen como base

 $	
  vagrant	
  box	
  add	
  base	
  http://files.vagrantup.com/lucid32.box



Crear fichero de configuración inicial ( Vagrantfile )

 $	
  vagrant	
  init



Iniciar máquina virtual




                                Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
INICIO RÁPIDO (I)

Añadir una primera imagen como base

 $	
  vagrant	
  box	
  add	
  base	
  http://files.vagrantup.com/lucid32.box



Crear fichero de configuración inicial ( Vagrantfile )

 $	
  vagrant	
  init



Iniciar máquina virtual

 $	
  vagrant	
  up




                                Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
INICIO RÁPIDO (II)
Resultado de ejecución
 $	
  vagrant	
  box	
  add	
  base	
  http://files.vagrantup.com/lucid32.box
 [vagrant]	
  Downloading	
  with	
  Vagrant::Downloaders::HTTP...
 [vagrant]	
  Downloading	
  box:	
  http://files.vagrantup.com/lucid32.box
 [vagrant]	
  Extracting	
  box...
 [vagrant]	
  Verifying	
  box...
 [vagrant]	
  Cleaning	
  up	
  downloaded	
  box...

 $	
  vagrant	
  init
 A	
  `Vagrantfile`	
  has	
  been	
  placed	
  in	
  this	
  directory.	
  You	
  are	
  now
 ready	
  to	
  `vagrant	
  up`	
  your	
  first	
  virtual	
  environment!	
  Please	
  read
 the	
  comments	
  in	
  the	
  Vagrantfile	
  as	
  well	
  as	
  documentation	
  on
 `vagrantup.com`	
  for	
  more	
  information	
  on	
  using	
  Vagrant.
 $	
  vagrant	
  up
 [default]	
  VM	
  already	
  created.	
  Booting	
  if	
  it's	
  not	
  already	
  running...
 [default]	
  Clearing	
  any	
  previously	
  set	
  forwarded	
  ports...
 [default]	
  Forwarding	
  ports...
 [default]	
  -­‐-­‐	
  22	
  =>	
  2222	
  (adapter	
  1)
 [default]	
  Creating	
  shared	
  folders	
  metadata...
 [default]	
  Clearing	
  any	
  previously	
  set	
  network	
  interfaces...
 [default]	
  Booting	
  VM...
 [default]	
  Waiting	
  for	
  VM	
  to	
  boot.	
  This	
  can	
  take	
  a	
  few	
  minutes.
 [default]	
  VM	
  booted	
  and	
  ready	
  for	
  use!
 [default]	
  Mounting	
  shared	
  folders...
 [default]	
  -­‐-­‐	
  v-­‐root:	
  /vagrant
                                   Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
INICIO RÁPIDO (III)
Accediendo por SSH

 $	
  vagrant	
  ssh
 Linux	
  lucid32	
  2.6.32-­‐38-­‐generic	
  #83-­‐Ubuntu	
  SMP	
  Wed	
  Jan	
  4	
  11:13:04	
  UTC	
  
 2012	
  i686	
  GNU/Linux
 Ubuntu	
  10.04.4	
  LTS
 Welcome	
  to	
  Ubuntu!
 	
  *	
  Documentation:	
  	
  https://help.ubuntu.com/
 New	
  release	
  'precise'	
  available.
 Run	
  'do-­‐release-­‐upgrade'	
  to	
  upgrade	
  to	
  it.
 Welcome	
  to	
  your	
  Vagrant-­‐built	
  virtual	
  machine.
 Last	
  login:	
  Fri	
  Sep	
  14	
  07:26:29	
  2012	
  from	
  10.0.2.2
 vagrant@lucid32:~$	
  ifconfig	
  eth0|grep	
  inet
 	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  inet	
  addr:10.0.2.15	
  	
  Bcast:10.0.2.255	
  	
  Mask:255.255.255.0
 	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  inet6	
  addr:	
  fe80::a00:27ff:feb5:756c/64	
  Scope:Link
 vagrant@lucid32:~$	
  ping	
  -­‐c	
  1	
  www.google.es
 PING	
  www.google.es	
  (173.194.34.216)	
  56(84)	
  bytes	
  of	
  data.
 64	
  bytes	
  from	
  mad01s08-­‐in-­‐f24.1e100.net	
  (173.194.34.216):	
  icmp_seq=1	
  
 ttl=63	
  time=85.0	
  ms
 -­‐-­‐-­‐	
  www.google.es	
  ping	
  statistics	
  -­‐-­‐-­‐
 1	
  packets	
  transmitted,	
  1	
  received,	
  0%	
  packet	
  loss,	
  time	
  0ms
 rtt	
  min/avg/max/mdev	
  =	
  85.038/85.038/85.038/0.000	
  ms


                                        Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
INICIO RÁPIDO (IV)
Suspender, despertar, detener y destruir la VM

 $	
  vagrant	
  suspend
 [default]	
  Saving	
  VM	
  state	
  and	
  suspending	
  execution...
 $	
  vagrant	
  resume
 [default]	
  Resuming	
  suspended	
  VM...
 [default]	
  Booting	
  VM...
 [default]	
  Waiting	
  for	
  VM	
  to	
  boot.	
  This	
  can	
  take	
  a	
  few	
  minutes.
 [default]	
  VM	
  booted	
  and	
  ready	
  for	
  use!
 $	
  vagrant	
  halt
 [default]	
  Attempting	
  graceful	
  shutdown	
  of	
  VM...

 $	
  vagrant	
  destroy
 Are	
  you	
  sure	
  you	
  want	
  to	
  destroy	
  the	
  'default'	
  VM?	
  [Y/N]	
  Y
 [default]	
  Destroying	
  VM	
  and	
  associated	
  drives...




                                       Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
CONFIGURACIÓN

Elementos importantes del fichero Vagrantfile
Vagrant::Config.run	
  do	
  |config|
	
  	
  #	
  Alias	
  local	
  de	
  la	
  VM	
  base
	
  	
  config.vm.box	
  =	
  "base"

	
  	
  #	
  URL	
  de	
  dónde	
  descargar	
  la	
  VM	
  en	
  caso	
  de	
  no	
  tenerla
	
  	
  config.vm.box_url	
  =	
  "http://files.vagrantup.com/lucid32.box"

	
  	
  #	
  Tipo	
  de	
  arranque	
  (Podría	
  ser	
  :gui)
	
  	
  config.vm.boot_mode	
  =	
  :headless

	
  	
  #	
  Modo	
  de	
  red	
  (Podría	
  ser	
  :bridged)
	
  	
  config.vm.network	
  :hostonly,	
  "192.168.33.10"

	
  	
  #	
  Redirigir	
  puerto	
  8000	
  en	
  host	
  hacia	
  el	
  puerto	
  80	
  en	
  VM
	
  	
  config.vm.forward_port	
  80,	
  8000
	
  	
  #	
  Directorio	
  compartido
	
  	
  config.vm.share_folder("v-­‐root",	
  "/vagrant",	
  ".")
end
                                          Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
AUTOMATIZACIÓN (I)

Una VM vacía no nos sirve de mucho
Para empezar un proyecto necesitamos ciertas herramientas
A mitad del proyecto es muy probable que necesitemos más
Es necesario automatizar la instalación y configuración de software




                       Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
AUTOMATIZACIÓN (I)

Una VM vacía no nos sirve de mucho
Para empezar un proyecto necesitamos ciertas herramientas
A mitad del proyecto es muy probable que necesitemos más
Es necesario automatizar la instalación y configuración de software




                       Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
AUTOMATIZACIÓN (II)




Declarativo                                     Imperativo (ruby)
Clases y módulos                                Recetas
Maduro (2005)                                   Más reciente (2009)
Extendido                                       Menos extendido



                   Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
EJEMPLO CON PUPPET (I)
Vagrant::Config.run	
  do	
  |config|
	
  	
  #	
  Alias	
  local	
  de	
  la	
  VM	
  base
	
  	
  config.vm.box	
  =	
  "base"

	
  	
  #	
  URL	
  de	
  dónde	
  descargar	
  la	
  VM	
  en	
  caso	
  de	
  no	
  tenerla
	
  	
  config.vm.box_url	
  =	
  "http://files.vagrantup.com/lucid32.box"

	
  	
  #	
  Modo	
  de	
  red	
  (Podría	
  ser	
  :bridged)
	
  	
  config.vm.network	
  :hostonly,	
  "192.168.33.10"

	
  	
  #	
  Directorio	
  compartido
	
  	
  config.vm.share_folder("v-­‐root",	
  "/vagrant",	
  ".")
	
  	
  
	
  	
  #	
  Usar	
  puppet/ejemplo.pp	
  como	
  fichero	
  de	
  manifiesto	
  puppet
	
  	
  config.vm.provision	
  :puppet	
  do	
  |puppet|
	
  	
  	
  	
  puppet.manifests_path	
  =	
  "puppet"
	
  	
  	
  	
  puppet.manifest_file	
  =	
  "ejemplo.pp"
	
  	
  end
end


                                      Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
EJEMPLO CON PUPPET (II)
Contenido de puppet/ejemplo.pp


 exec	
  {"apt-­‐get-­‐update":"apt-­‐get-­‐update":
 	
  	
  	
  	
  creates	
  =>	
  "/tmp/apt-­‐get-­‐updated",
 	
  	
  	
  	
  command	
  =>	
  "/usr/bin/apt-­‐get	
  update	
  &&	
  /usr/bin/touch	
  /tmp/apt-­‐
 get-­‐updated"
 }

 package	
  {"apache2":
 	
  	
  	
  	
  ensure	
  =>	
  present,
 	
  	
  	
  	
  require	
  =>	
  Exec["apt-­‐get-­‐update"],
 }

 $php	
  =	
  ["php5-­‐cli",	
  "php5-­‐mysql",	
  "libapache2-­‐mod-­‐php5"]
 package	
  {	
  $php:
 	
  	
  	
  	
  ensure	
  =>	
  present,
 	
  	
  	
  	
  notify	
  =>	
  Service["apache2"],
 	
  	
  	
  	
  require	
  =>	
  Exec["apt-­‐get-­‐update"]
 }



                                       Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
EJEMPLO CON PUPPET (III)
Agregando soporte a MySQL
 $mysql	
  =	
  ["mysql-­‐server",	
  "mysql-­‐client"]
 package	
  {	
  $mysql:
 	
  	
  	
  	
  ensure	
  =>	
  present,
 	
  	
  	
  	
  require	
  =>	
  Exec["apt-­‐get-­‐update"]
 }

 file	
  {"/etc/mysql/my.cnf":
 	
   ensure	
   =>	
  file,
 	
   owner	
  =>	
  "root",
 	
   group	
  =>	
  "root",
 	
   mode	
   =>	
  644,
 	
   source	
   =>	
  "/vagrant/puppet/files/mysql/my.cnf",
 	
   require	
   =>	
  Package[$mysql],
 	
   notify	
   =>	
  Service["mysql"],
 }

 service	
  {"mysql":
 	
   enable	
   =>	
  true,
 	
   ensure	
   =>	
  running,
 	
   require	
   =>	
  Package[$mysql],
 }
                                    Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
RESUMEN



Vagrant es una herramienta muy potente

Réplica en desarrollo del entorno de producción

Si aún no la usas estás perdiendo tiempo y dinero...




                        Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
RESUMEN



Vagrant es una herramienta muy potente

Réplica en desarrollo del entorno de producción

Si aún no la usas estás perdiendo tiempo y dinero...




                        Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras

Más contenido relacionado

PPT
PDF
Creación de entornos de desarrollo con Vagrant
PDF
Entornos de desarrollo para symfony2 con vagrant y puppet
PDF
Introducción a Vagrant
ODP
Virtualización y Provisionamiento: Entornos de desarrollo con Vagrant y Puppet
PDF
Vagrant para automatizar entornos DEV/PRO: VirtualBox y vSphere
PDF
Vagrant: virtualizando entornos de desarrollo
PDF
Entorno de desarrollo rápido con Vagrant
Creación de entornos de desarrollo con Vagrant
Entornos de desarrollo para symfony2 con vagrant y puppet
Introducción a Vagrant
Virtualización y Provisionamiento: Entornos de desarrollo con Vagrant y Puppet
Vagrant para automatizar entornos DEV/PRO: VirtualBox y vSphere
Vagrant: virtualizando entornos de desarrollo
Entorno de desarrollo rápido con Vagrant

La actualidad más candente (20)

PDF
Evolución de la admon. sistemas
PDF
Exprime al máximo la capacidad de tus servidores gracias a la virtualización ...
PDF
Introduccion A Docker
ODP
Solapas principales Ver(solapa activa) Editar Gestionar present...
PDF
Un recorrido por las herramientas de software libre que uso cada día, en los ...
PPTX
Oracle VM VirtualBox Hacked
PDF
Orquestadores para las cuatro estaciones (swarm, kubernetes, mesos y rancher)
PDF
nerdear.la 2016 - Docker workshop
PPT
Sesion Nº 03 Tecnologias Web I Instalación Y Configuración Del Servidor A...
PDF
Docker: la revolución en virtualización
PPTX
Meetup V.E.No.M. y docker
PDF
Dev ops infraestructura agil con open source
PDF
03 de Marzo 2015: Andrés Villarreal - Herramientas del Desarrollador Moderno
PDF
Conceptos avanzados en docker
PDF
Una introducción a vagrant
PDF
DevOps+[Chef/Docker]
PPTX
Presentación Docker
PDF
Sandbox para ejercicios de programación
PDF
Virtualenv y buildout
Evolución de la admon. sistemas
Exprime al máximo la capacidad de tus servidores gracias a la virtualización ...
Introduccion A Docker
Solapas principales Ver(solapa activa) Editar Gestionar present...
Un recorrido por las herramientas de software libre que uso cada día, en los ...
Oracle VM VirtualBox Hacked
Orquestadores para las cuatro estaciones (swarm, kubernetes, mesos y rancher)
nerdear.la 2016 - Docker workshop
Sesion Nº 03 Tecnologias Web I Instalación Y Configuración Del Servidor A...
Docker: la revolución en virtualización
Meetup V.E.No.M. y docker
Dev ops infraestructura agil con open source
03 de Marzo 2015: Andrés Villarreal - Herramientas del Desarrollador Moderno
Conceptos avanzados en docker
Una introducción a vagrant
DevOps+[Chef/Docker]
Presentación Docker
Sandbox para ejercicios de programación
Virtualenv y buildout
Publicidad

Destacado (6)

PPTX
Discovering New Apps
PPTX
Dev ops e infraestructura – acompañando nuestro software a producción
PDF
Curso puppet lenguaje_2
PDF
Vagrant y Docker - Guía práctica de uso
PPTX
Dev ops. Rompiendo Barreras
ODP
Gestionando servidores con Puppet
Discovering New Apps
Dev ops e infraestructura – acompañando nuestro software a producción
Curso puppet lenguaje_2
Vagrant y Docker - Guía práctica de uso
Dev ops. Rompiendo Barreras
Gestionando servidores con Puppet
Publicidad

Similar a Vagrant (20)

PDF
Entornos de desarrollo portables, reproducibles y ligeros
PDF
Cloud Computing. Gestión de configuraciones. Vagrant
PDF
Vagrant sobre Debian: Primeros Pasos
PDF
Virtualizacion KVM + libvirt + HREL6
PDF
Manualvirtualbox.pdf
PPTX
Maquinas virtuales
PDF
Virtualizacion
PPTX
Geekend 2018 - No trabajes en Local! (Utiliza Vagrant o Docker)
PPTX
VirtualBox historia y características como virtualizador
DOC
Maquinas virtuales manual de virtual box
DOCX
Maquina virtual
ODP
Virtualizacion
DOCX
Maquina virtual
PPTX
Tipos de virtualizacion
PDF
Virtualbox
PPTX
Maquinas virtuales
PPTX
Máquina virtual
PPTX
Tipos de virtualizacion
PDF
Bitacora virtualizacion - introduccion.pdf
PPTX
MAQUINAS VIRTUALES
Entornos de desarrollo portables, reproducibles y ligeros
Cloud Computing. Gestión de configuraciones. Vagrant
Vagrant sobre Debian: Primeros Pasos
Virtualizacion KVM + libvirt + HREL6
Manualvirtualbox.pdf
Maquinas virtuales
Virtualizacion
Geekend 2018 - No trabajes en Local! (Utiliza Vagrant o Docker)
VirtualBox historia y características como virtualizador
Maquinas virtuales manual de virtual box
Maquina virtual
Virtualizacion
Maquina virtual
Tipos de virtualizacion
Virtualbox
Maquinas virtuales
Máquina virtual
Tipos de virtualizacion
Bitacora virtualizacion - introduccion.pdf
MAQUINAS VIRTUALES

Más de betabeers (20)

PPSX
IONIC, el framework para crear aplicaciones híbridas multiplataforma
PDF
Servicios de Gestión de Datos en la Nube - Jaime Balañá (NetApp)
PPTX
Blockchain: la revolución industrial de internet - Oscar Lage
PDF
Cloud Learning: la formación del siglo XXI - Mónica Mediavilla
PDF
Desarrollo web en Nodejs con Pillars por Chelo Quilón
PDF
La línea recta hacia el éxito - Jon Torrado - Betabeers Bilbao
PDF
6 errores a evitar si eres una startup móvil y quieres evolucionar tu app
PDF
Dev ops.continuous delivery - Ibon Landa (Plain Concepts)
PPTX
Introducción a scrum - Rodrigo Corral (Plain Concepts)
PPTX
Gestión de proyectos y consorcios internacionales - Iñigo Cañadas (GFI)
PPTX
Software de gestión Open Source - Odoo - Bakartxo Aristegi (Aizean)
PDF
Elemental, querido Watson - Caso de Uso
PDF
Seguridad en tu startup
PPTX
Spark Java: Aplicaciones web ligeras y rápidas con Java, por Fran Paredes.
PDF
Buenas prácticas para la optimización web
PDF
La magia de Scrum
PDF
Programador++ por @wottam
PPTX
RaspberryPi: Tu dispositivo para IoT
PDF
Introducción al Big Data - Xabier Tranche - VIII Betabeers Bilbao 27/02/2015
PDF
PAYTPV Plataforma Integral de Cobros - VIII Betabeers Bilbao 27/02/2015
IONIC, el framework para crear aplicaciones híbridas multiplataforma
Servicios de Gestión de Datos en la Nube - Jaime Balañá (NetApp)
Blockchain: la revolución industrial de internet - Oscar Lage
Cloud Learning: la formación del siglo XXI - Mónica Mediavilla
Desarrollo web en Nodejs con Pillars por Chelo Quilón
La línea recta hacia el éxito - Jon Torrado - Betabeers Bilbao
6 errores a evitar si eres una startup móvil y quieres evolucionar tu app
Dev ops.continuous delivery - Ibon Landa (Plain Concepts)
Introducción a scrum - Rodrigo Corral (Plain Concepts)
Gestión de proyectos y consorcios internacionales - Iñigo Cañadas (GFI)
Software de gestión Open Source - Odoo - Bakartxo Aristegi (Aizean)
Elemental, querido Watson - Caso de Uso
Seguridad en tu startup
Spark Java: Aplicaciones web ligeras y rápidas con Java, por Fran Paredes.
Buenas prácticas para la optimización web
La magia de Scrum
Programador++ por @wottam
RaspberryPi: Tu dispositivo para IoT
Introducción al Big Data - Xabier Tranche - VIII Betabeers Bilbao 27/02/2015
PAYTPV Plataforma Integral de Cobros - VIII Betabeers Bilbao 27/02/2015

Vagrant

  • 1. VAGRANT VIRTUALIZANDO ENTORNOS DE DESARROLLO Daniel Vigueras daniel@scalia.es @danielvigueras
  • 2. ESCENARIO 1 Desarrollador de varios proyectos con diferentes entornos conflictivos entre sí Ruby 1.8 PHP 5.2 Ruby 1.9 PHP 5.3 Rails 1.2 CodeIgniter Rails 3.2 Vevui MySQL 4.1 MySQL 5.0 MySQL 5.5 MongoDB 2.2 Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 3. ESCENARIO 2 Equipo de desarrollo con diferentes sistemas operativos XAMP, WAMP, MAMP, LAMP, Apache, Nginx... Instalar librerías y servicios (Memcached, Redis, MongoDB, Sphinx...) Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 4. SOLUCIÓN ¡ Usar máquinas virtuales para cada entorno de desarrollo ! Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 5. PROBLEMAS ¿Qué entorno de virtualización elijo? ¿VMWare? ¿VirtualBox? ¿KVM? ¿Xen? ¿Cómo creo una máquina virtual? Me da pereza instalar un nuevo sistema operativo... ¿Cómo comparto el entorno con otras personas? ¿Y si quiero cambiar de entorno de virtualización ? Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 6. PROBLEMAS ¿Qué entorno de virtualización elijo? ¿VMWare? ¿VirtualBox? ¿KVM? ¿Xen? ¿Cómo creo una máquina virtual? Me da pereza instalar un nuevo sistema operativo... ¿Cómo comparto el entorno con otras personas? ¿Y si quiero cambiar de entorno de virtualización ? Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 7. PROBLEMAS ¿Qué entorno de virtualización elijo? ¿VMWare? ¿VirtualBox? ¿KVM? ¿Xen? ¿Cómo creo una máquina virtual? Me da pereza instalar un nuevo sistema operativo... ¿Cómo comparto el entorno con otras personas? ¿Y si quiero cambiar de entorno de virtualización ? Usar herramienta independiente del entorno de virtualización que nos oculte los detalles Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 8. SOLUCIÓN: VAGRANT Crear, iniciar, detener y eliminar VMs de manera sencilla Escrito en ruby Open source ( http://github.com/mitchellh/vagrant ) Actualmente sólo es capaz de controlar Oracle VM VirtualBox En el futuro soportará cualquier entorno mediante plugins Está siendo usado por varias empresas importantes Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 9. SOLUCIÓN: VAGRANT Crear, iniciar, detener y eliminar VMs de manera sencilla Escrito en ruby Open source ( http://github.com/mitchellh/vagrant ) Actualmente sólo es capaz de controlar Oracle VM VirtualBox En el futuro soportará cualquier entorno mediante plugins Está siendo usado por varias empresas importantes « ¡¡ En mi ordenador funciona !! » Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 10. OBTENER VAGRANT Descargar e instalar Oracle VM VirtualBox de http://www.virtualbox.org (Última versión 4.2) Descargar e instalar Vagrant de http://vagrantup.com (Última versión 1.0.4) Mac (DMG), Linux (DEB, RPM), Windows (MSI) Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 11. INICIO RÁPIDO (I) Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 12. INICIO RÁPIDO (I) Añadir una primera imagen como base Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 13. INICIO RÁPIDO (I) Añadir una primera imagen como base $  vagrant  box  add  base  http://files.vagrantup.com/lucid32.box Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 14. INICIO RÁPIDO (I) Añadir una primera imagen como base $  vagrant  box  add  base  http://files.vagrantup.com/lucid32.box Crear fichero de configuración inicial ( Vagrantfile ) Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 15. INICIO RÁPIDO (I) Añadir una primera imagen como base $  vagrant  box  add  base  http://files.vagrantup.com/lucid32.box Crear fichero de configuración inicial ( Vagrantfile ) $  vagrant  init Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 16. INICIO RÁPIDO (I) Añadir una primera imagen como base $  vagrant  box  add  base  http://files.vagrantup.com/lucid32.box Crear fichero de configuración inicial ( Vagrantfile ) $  vagrant  init Iniciar máquina virtual Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 17. INICIO RÁPIDO (I) Añadir una primera imagen como base $  vagrant  box  add  base  http://files.vagrantup.com/lucid32.box Crear fichero de configuración inicial ( Vagrantfile ) $  vagrant  init Iniciar máquina virtual $  vagrant  up Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 18. INICIO RÁPIDO (II) Resultado de ejecución $  vagrant  box  add  base  http://files.vagrantup.com/lucid32.box [vagrant]  Downloading  with  Vagrant::Downloaders::HTTP... [vagrant]  Downloading  box:  http://files.vagrantup.com/lucid32.box [vagrant]  Extracting  box... [vagrant]  Verifying  box... [vagrant]  Cleaning  up  downloaded  box... $  vagrant  init A  `Vagrantfile`  has  been  placed  in  this  directory.  You  are  now ready  to  `vagrant  up`  your  first  virtual  environment!  Please  read the  comments  in  the  Vagrantfile  as  well  as  documentation  on `vagrantup.com`  for  more  information  on  using  Vagrant. $  vagrant  up [default]  VM  already  created.  Booting  if  it's  not  already  running... [default]  Clearing  any  previously  set  forwarded  ports... [default]  Forwarding  ports... [default]  -­‐-­‐  22  =>  2222  (adapter  1) [default]  Creating  shared  folders  metadata... [default]  Clearing  any  previously  set  network  interfaces... [default]  Booting  VM... [default]  Waiting  for  VM  to  boot.  This  can  take  a  few  minutes. [default]  VM  booted  and  ready  for  use! [default]  Mounting  shared  folders... [default]  -­‐-­‐  v-­‐root:  /vagrant Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 19. INICIO RÁPIDO (III) Accediendo por SSH $  vagrant  ssh Linux  lucid32  2.6.32-­‐38-­‐generic  #83-­‐Ubuntu  SMP  Wed  Jan  4  11:13:04  UTC   2012  i686  GNU/Linux Ubuntu  10.04.4  LTS Welcome  to  Ubuntu!  *  Documentation:    https://help.ubuntu.com/ New  release  'precise'  available. Run  'do-­‐release-­‐upgrade'  to  upgrade  to  it. Welcome  to  your  Vagrant-­‐built  virtual  machine. Last  login:  Fri  Sep  14  07:26:29  2012  from  10.0.2.2 vagrant@lucid32:~$  ifconfig  eth0|grep  inet                    inet  addr:10.0.2.15    Bcast:10.0.2.255    Mask:255.255.255.0                    inet6  addr:  fe80::a00:27ff:feb5:756c/64  Scope:Link vagrant@lucid32:~$  ping  -­‐c  1  www.google.es PING  www.google.es  (173.194.34.216)  56(84)  bytes  of  data. 64  bytes  from  mad01s08-­‐in-­‐f24.1e100.net  (173.194.34.216):  icmp_seq=1   ttl=63  time=85.0  ms -­‐-­‐-­‐  www.google.es  ping  statistics  -­‐-­‐-­‐ 1  packets  transmitted,  1  received,  0%  packet  loss,  time  0ms rtt  min/avg/max/mdev  =  85.038/85.038/85.038/0.000  ms Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 20. INICIO RÁPIDO (IV) Suspender, despertar, detener y destruir la VM $  vagrant  suspend [default]  Saving  VM  state  and  suspending  execution... $  vagrant  resume [default]  Resuming  suspended  VM... [default]  Booting  VM... [default]  Waiting  for  VM  to  boot.  This  can  take  a  few  minutes. [default]  VM  booted  and  ready  for  use! $  vagrant  halt [default]  Attempting  graceful  shutdown  of  VM... $  vagrant  destroy Are  you  sure  you  want  to  destroy  the  'default'  VM?  [Y/N]  Y [default]  Destroying  VM  and  associated  drives... Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 21. CONFIGURACIÓN Elementos importantes del fichero Vagrantfile Vagrant::Config.run  do  |config|    #  Alias  local  de  la  VM  base    config.vm.box  =  "base"    #  URL  de  dónde  descargar  la  VM  en  caso  de  no  tenerla    config.vm.box_url  =  "http://files.vagrantup.com/lucid32.box"    #  Tipo  de  arranque  (Podría  ser  :gui)    config.vm.boot_mode  =  :headless    #  Modo  de  red  (Podría  ser  :bridged)    config.vm.network  :hostonly,  "192.168.33.10"    #  Redirigir  puerto  8000  en  host  hacia  el  puerto  80  en  VM    config.vm.forward_port  80,  8000    #  Directorio  compartido    config.vm.share_folder("v-­‐root",  "/vagrant",  ".") end Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 22. AUTOMATIZACIÓN (I) Una VM vacía no nos sirve de mucho Para empezar un proyecto necesitamos ciertas herramientas A mitad del proyecto es muy probable que necesitemos más Es necesario automatizar la instalación y configuración de software Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 23. AUTOMATIZACIÓN (I) Una VM vacía no nos sirve de mucho Para empezar un proyecto necesitamos ciertas herramientas A mitad del proyecto es muy probable que necesitemos más Es necesario automatizar la instalación y configuración de software Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 24. AUTOMATIZACIÓN (II) Declarativo Imperativo (ruby) Clases y módulos Recetas Maduro (2005) Más reciente (2009) Extendido Menos extendido Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 25. EJEMPLO CON PUPPET (I) Vagrant::Config.run  do  |config|    #  Alias  local  de  la  VM  base    config.vm.box  =  "base"    #  URL  de  dónde  descargar  la  VM  en  caso  de  no  tenerla    config.vm.box_url  =  "http://files.vagrantup.com/lucid32.box"    #  Modo  de  red  (Podría  ser  :bridged)    config.vm.network  :hostonly,  "192.168.33.10"    #  Directorio  compartido    config.vm.share_folder("v-­‐root",  "/vagrant",  ".")        #  Usar  puppet/ejemplo.pp  como  fichero  de  manifiesto  puppet    config.vm.provision  :puppet  do  |puppet|        puppet.manifests_path  =  "puppet"        puppet.manifest_file  =  "ejemplo.pp"    end end Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 26. EJEMPLO CON PUPPET (II) Contenido de puppet/ejemplo.pp exec  {"apt-­‐get-­‐update":"apt-­‐get-­‐update":        creates  =>  "/tmp/apt-­‐get-­‐updated",        command  =>  "/usr/bin/apt-­‐get  update  &&  /usr/bin/touch  /tmp/apt-­‐ get-­‐updated" } package  {"apache2":        ensure  =>  present,        require  =>  Exec["apt-­‐get-­‐update"], } $php  =  ["php5-­‐cli",  "php5-­‐mysql",  "libapache2-­‐mod-­‐php5"] package  {  $php:        ensure  =>  present,        notify  =>  Service["apache2"],        require  =>  Exec["apt-­‐get-­‐update"] } Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 27. EJEMPLO CON PUPPET (III) Agregando soporte a MySQL $mysql  =  ["mysql-­‐server",  "mysql-­‐client"] package  {  $mysql:        ensure  =>  present,        require  =>  Exec["apt-­‐get-­‐update"] } file  {"/etc/mysql/my.cnf":   ensure   =>  file,   owner  =>  "root",   group  =>  "root",   mode   =>  644,   source   =>  "/vagrant/puppet/files/mysql/my.cnf",   require   =>  Package[$mysql],   notify   =>  Service["mysql"], } service  {"mysql":   enable   =>  true,   ensure   =>  running,   require   =>  Package[$mysql], } Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 28. RESUMEN Vagrant es una herramienta muy potente Réplica en desarrollo del entorno de producción Si aún no la usas estás perdiendo tiempo y dinero... Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras
  • 29. RESUMEN Vagrant es una herramienta muy potente Réplica en desarrollo del entorno de producción Si aún no la usas estás perdiendo tiempo y dinero... Vagrant: virtualizando entornos de desarrollo / Daniel Vigueras / @danielvigueras