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

Out of the box with Vagrant

Out of the box with Vagrant

Introduction to vagrant

Xabier Larrakoetxea

July 14, 2014
Tweet

More Decks by Xabier Larrakoetxea

Other Decks in Technology

Transcript

  1. Providers VmWare Virtualbox Docker AWS 1.0 1.1 1.6 Plugin 1.1

    https://docs.vagrantup.com/v2/providers/index.html
  2. Providers VmWare Virtualbox Docker AWS 1.0 1.1 1.6 Plugin 1.1

    https://docs.vagrantup.com/v2/providers/index.html
  3. Providers VmWare Virtualbox Docker AWS 1.0 1.1 1.6 Plugin 1.1

    https://docs.vagrantup.com/v2/providers/index.html NIRVANA!
  4. Providers VmWare Virtualbox Docker AWS 1.0 1.1 1.6 Plugin 1.1

    https://docs.vagrantup.com/v2/providers/index.html NIRVANA! VALHALLA!
  5. Providers VmWare Virtualbox Docker AWS 1.0 1.1 1.6 Plugin 1.1

    https://docs.vagrantup.com/v2/providers/index.html NIRVANA! VALHALLA! CLIM AX!
  6. Providers VmWare Virtualbox Docker AWS 1.0 1.1 1.6 Plugin 1.1

    https://docs.vagrantup.com/v2/providers/index.html NIRVANA! VALHALLA! CLIM AX! PARADISE!
  7. ==> box: Loading metadata for box 'ubuntu/trusty64' box: URL: https://vagrantcloud.com/ubuntu/trusty64

    ==> box: Adding box 'ubuntu/trusty64' (v14.04) for provider: virtualbox box: Downloading: https://vagrantcloud. com/ubuntu/trusty64/version/1/provider/virtualbox.box ==> box: Successfully added box 'ubuntu/trusty64' (v14.04) for 'virtualbox'! $ vagrant box add ubuntu/trusty64
  8. # Minimun Vagrantfile Vagrant::Config.run do |config| config.vm.box = 'hashicorp/precise64' end

    Vagrantfile https://docs.vagrantup.com/v2/vagrantfile/index.html
  9. Network DHCP Bridged Static config.vm.network "public_network", type: "dhcp" config.vm.network "private_network",

    type: "dhcp" config.vm.network "public_network", :bridge config.vm.network :private_network, ip: "192.168.100.46"
  10. # Vagrantfile VAGRANTFILE_API_VERSION = "2" box = 'ubuntu/trusty64' hostname =

    'dogebox' ip = '192.168.100.46' Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # Box conf config.vm.box = box config.vm.host_name = hostname # Network conf config.vm.network :private_network, ip: ip end Vagrantfile https://docs.vagrantup.com/v2/networking/index.html
  11. Ports TCP/UDP TCP UDP config.vm.network :forwarded_port, guest: 8000, host: 8000

    config.vm.network :forwarded_port, guest: 8000, host: 8000, protocol: 'tcp' config.vm.network :forwarded_port, guest: 8000, host: 8000, protocol: 'udp'
  12. # Vagrantfile VAGRANTFILE_API_VERSION = "2" box = 'ubuntu/trusty64' hostname =

    'dogebox' ip = '192.168.100.46' Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # Box conf config.vm.box = box config.vm.host_name = hostname # Network conf config.vm.network :private_network, ip: ip # Ports config.vm.network :forwarded_port, guest: 8000, host: 8000 # Django config.vm.network :forwarded_port, guest: 9000, host: 9000 # Django 2 config.vm.network :forwarded_port, guest: 5432, host: 15432 # Postgres config.vm.network :forwarded_port, guest: 9200, host: 19200 # Elastic search end Vagrantfile https://docs.vagrantup.com/v2/networking/forwarded_ports.html
  13. # Vagrantfile VAGRANTFILE_API_VERSION = "2" box = 'ubuntu/trusty64' hostname =

    'dogebox' ip = '192.168.100.46' project_location = "~/devops-course" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # Box conf config.vm.box = box config.vm.host_name = hostname # Network conf config.vm.network :private_network, ip: ip # Ports config.vm.network :forwarded_port, guest: 8000, host: 8000 # Django config.vm.network :forwarded_port, guest: 9000, host: 9000 # Django 2 config.vm.network :forwarded_port, guest: 5432, host: 15432 # Postgres config.vm.network :forwarded_port, guest: 9200, host: 19200 # Elastic search # Synced folders config.vm.synced_folder project_location, "/home/vagrant/projects" end Vagrantfile https://docs.vagrantup.com/v2/networking/forwarded_ports.html
  14. Resources memory CPU vb.customize ["modifyvm", :id, "--memory", "2048"] vb.customize ["modifyvm",

    :id, "--cpus", "2"] vb.customize ["modifyvm", :id, "--ioapic", "on"]
  15. # Vagrantfile VAGRANTFILE_API_VERSION = "2" box = 'ubuntu/trusty64' hostname =

    'dogebox' ip = '192.168.100.46' ram = '2048' cpu = '2' project_location = "~/devops-course" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # Box conf config.vm.box = box config.vm.host_name = hostname # Network conf config.vm.network :private_network, ip: ip # Ports config.vm.network :forwarded_port, guest: 8000, host: 8000 # Django config.vm.network :forwarded_port, guest: 9000, host: 9000 # Django 2 config.vm.network :forwarded_port, guest: 5432, host: 15432 # Postgres config.vm.network :forwarded_port, guest: 9200, host: 19200 # Elastic search # Synced folders config.vm.synced_folder project_location, "/home/vagrant/projects" # Provider conf config.vm.provider :virtualbox do |vb| vb.customize [ "modifyvm", :id, "--memory", ram, "--cpus", cpu, "--ioapic", "on", ] end end Vagrantfile
  16. Bringing machine 'default' up with 'virtualbox' provider... ==> default: Importing

    base box 'ubuntu/trusty64'... ==> default: Matching MAC address for NAT networking... ==> default: Checking if box 'ubuntu/trusty64' is up to date... ==> default: Setting the name of the VM: 01_default_1400440793987_30506 ==> default: Clearing any previously set forwarded ports... ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat default: Adapter 2: hostonly ==> default: Forwarding ports... default: 8000 => 8000 (adapter 1) default: 9000 => 9000 (adapter 1) default: 5432 => 15432 (adapter 1) default: 9200 => 19200 (adapter 1) default: 22 => 2222 (adapter 1) ==> default: Running 'pre-boot' VM customizations... ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: Warning: Connection timeout. Retrying... default: Warning: Remote connection disconnect. Retrying... ==> default: Machine booted and ready! ==> default: Checking for guest additions in VM... ==> default: Setting hostname... ==> default: Configuring and enabling network interfaces... ==> default: Mounting shared folders... default: /vagrant => /home/slok/projects/devops-course/01 default: /home/vagrant/projects => /home/slok/devops-course $ vagrant up
  17. Welcome to Ubuntu 14.04 LTS (GNU/Linux 3.13.0-24-generic x86_64) * Documentation:

    https://help.ubuntu.com/ System information disabled due to load higher than 1.0 Get cloud support with Ubuntu Advantage Cloud Guest: http://www.ubuntu.com/business/services/cloud 0 packages can be updated. 0 updates are security updates. vagrant@dogebox:~$ $ vagrant ssh
  18. default: Are you sure you want to destroy the 'default'

    VM? [y/N] y ==> default: Destroying VM and associated drives... $ vagrant destroy
  19. #!

  20. Shell config.vm.provision "shell", path: "script.sh" #! Ansible config.vm.provision "ansible" do

    |ansible| ansible.playbook = "playbook.yml" end Docker config.vm.provision "docker" do |d| d.run "db-1", image: "user/mysql" d.run "db-2", image: "user/mysql" end http://docs.vagrantup.com/v2/provisioning
  21. Icons: Entypo Typography: Google web fonts OS Logos: http://commons.wikimedia.org Github:

    https://github.com Google docs: https://docs.google.com Vagrant: http://docs.vagrantup.com/ Syntax highligter: http://markup.su/highlighter/