Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Vagrant

 Vagrant

Un introducción a Vagrant y alguno tips para un mejor uso

17411ddb51e17861ef4f8e2d866f7ab6?s=128

Guido Marucci Blas

November 13, 2013
Tweet

Transcript

  1. Wednesday, November 13, 13

  2. Guido Marucci Blas CTO & Co-Founder at Wolox guidomb guidomb@wolox.com.ar

    Wednesday, November 13, 13
  3. Permite virtualizar ambientes Es open source Soporta Virtualbox y VMware

    Configurable con un DSL en Ruby Multiplataforma Wednesday, November 13, 13
  4. ¿Por qué usar Vagrant? Wednesday, November 13, 13

  5. Probar server setups Ambientes de desarrollo replicables Probar cluster de

    forma local Wednesday, November 13, 13
  6. Probar server setups Ambientes de desarrollo replicables Probar cluster de

    forma local Wednesday, November 13, 13
  7. Projecto A Projecto B Rails 3.2 Ruby 1.9.3 Postgres 8.4

    Imagemagick Poppler Rails 4.1 Ruby 2.0.0 Postgres 9.6 Wednesday, November 13, 13
  8. - RRHH: Juan, hoy empieza el nuevo dev para el

    proyecto X. ¿Cuáles van a ser sus tareas para la próxima semana? - Juan (PM): Configurar el ambiente Wednesday, November 13, 13
  9. Nos ayuda a bajar la barrera de entrada en un

    proyecto Wednesday, November 13, 13
  10. Instalar VirtualBox Instalar Vagrant Configurar Vagrantfile $> vagrant up $>

    vagrant ssh $vagrant> Setup Wednesday, November 13, 13
  11. DEMO Wednesday, November 13, 13

  12. Tips Wednesday, November 13, 13

  13. Definir nombre de box por proyecto # -*- mode: ruby

    -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| config.vm.box = "vagrant-demo" config.vm.box_url = "http://files.vagrantup.com/precise64.box" # Network config.vm.synced_folder ".", "/vagrant", :nfs => true, id: "vagrant-root" config.vm.network :forwarded_port, guest: 3000, host: 8000 config.vm.network :private_network, ip: "192.168.50.4" end Wednesday, November 13, 13
  14. Usar NFS para sync de archivos # -*- mode: ruby

    -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| config.vm.box = "vagrant-demo" config.vm.box_url = "http://files.vagrantup.com/precise64.box" # Network config.vm.synced_folder ".", "/vagrant", :nfs => true, id: "vagrant-root" config.vm.network :forwarded_port, guest: 3000, host: 8000 config.vm.network :private_network, ip: "192.168.50.4" end Wednesday, November 13, 13
  15. Configurar memoria RAM de la VM # -*- mode: ruby

    -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| config.vm.box = "vagrant-demo" config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.customize = ["modifyvm", :id, "memory", 1024] # Network config.vm.synced_folder ".", "/vagrant", :nfs => true, id: "vagrant-root" config.vm.network :forwarded_port, guest: 3000, host: 8000 config.vm.network :private_network, ip: "192.168.50.4" end Wednesday, November 13, 13
  16. Exportar la VM configurada $> vagrant up ... SETUP ...

    $> vagrant halt $> vagrant package $> mv package.box vagrant-demo.box $> echo "*.box" >> .gitignore $> vagrant box add vagrant-demo ./vagrant-demo.box Wednesday, November 13, 13
  17. DEMO Wednesday, November 13, 13

  18. Berkshelf Chef + + Wednesday, November 13, 13

  19. $> vagrant plugin install vagrant-berkshelf # -*- mode: ruby -*-

    # vi: set ft=ruby : Vagrant.configure("2") do |config| config.vm.box = "vagrant-demo-chef" config.vm.box_url = "http://files.vagrantup.com/precise64.box" # Network config.vm.synced_folder ".", "/vagrant", :nfs => true, id: "vagrant-root" config.vm.network :forwarded_port, guest: 3000, host: 8000 config.vm.network :private_network, ip: "192.168.50.4" # Provisioning config.berkshelf.enabled = true config.vm.provision :chef_solo do |chef| chef.add_recipe "apt" chef.add_recipe "build-essential" chef.add_recipe "git" end end Wednesday, November 13, 13
  20. site :opscode cookbook 'apt' cookbook 'build-essential' cookbook 'git' Definir el

    Berksfile $>vim Berksfile http://berkshelf.com Wednesday, November 13, 13
  21. $> vagrant plugin install vagrant-omnibus # -*- mode: ruby -*-

    # vi: set ft=ruby : Vagrant.configure("2") do |config| config.vm.box = "vagrant-demo-chef" config.vm.box_url = "http://files.vagrantup.com/precise64.box" # Network config.vm.synced_folder ".", "/vagrant", :nfs => true, id: "vagrant-root" config.vm.network :forwarded_port, guest: 3000, host: 8000 config.vm.network :private_network, ip: "192.168.50.4" # Provisioning config.omnibus.chef_version = :latest config.berkshelf.enabled = true config.vm.provision :chef_solo do |chef| chef.add_recipe "apt" chef.add_recipe "build-essential" chef.add_recipe "git" end end Wednesday, November 13, 13
  22. Usar versiones fijas en las cookbooks No actualizar Vagrant a

    menos que los plugins soporten la nueva versión ProTip Wednesday, November 13, 13
  23. DEMO Wednesday, November 13, 13

  24. Amazon EC2 + cocina de AMIs = Wednesday, November 13,

    13
  25. $> vagrant plugin install vagrant-aws config.vm.define :aws do |aws_config| credentials

    = YAML.load_file("./.amazon.yml") aws_config.vm.box = "dummy" aws_config.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box" aws_config.omnibus.chef_version = "10.24.0" aws_config.vm.provider :aws do |aws, override| aws.access_key_id = credentials['access_key_id'] aws.secret_access_key = credentials['secret_access_key'] aws.keypair_name = "APPLICATION_NAME" aws.region = "sa-east-1" aws.region_config "sa-east-1", :ami => "ami-a3da00be" aws.security_groups = ["APPLICATION_NAME"] aws.instance_type = "m1.medium" override.ssh.username = "ubuntu" override.ssh.private_key_path = "~/.ssh/APPLICATION_NAME.pem" end aws_config.vm.provision :chef_solo do |chef| chef.add_recipe 'apt' chef.add_recipe 'application::packages' chef.add_recipe 'nginx::source' chef.add_recipe 'mysql::client' end end $> vagrant up --provider=aws Wednesday, November 13, 13
  26. vagrant halt ¿Preguntas? Wednesday, November 13, 13