Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Vagrant
Agenda
• Introduction to Vagrant
• Create VM

• Provisioning
• plugins

2/17/2014

Copyright 2013 Trend Micro Inc.
Introduction

2/17/2014

Copyright 2013 Trend Micro Inc.
Vagrant
• A open source command line VM provision tool
• MIT licence

• Still virtualization,
but more easier, more flexib...
Easy to use and share
http://www.vagrantbox.es/
http://puppet-vagrant-boxes.puppetlabs.com/

2/17/2014

Copyright 2013 Tre...
Installation
• Install virtualbox
– https://www.virtualbox.org/wiki/Downloads

• Install vagrant (support windows, mac, li...
Architecture
Providers

2/17/2014

Copyright 2013 Trend Micro Inc.
How does it work?
• Via VBoxManage tool
• list running VM
– $ VBoxManage list runningvms

• pause VM
– $ VBoxManage contro...
Why we need it
• Deploy a project on a machine for testing
– mess things up
– Fix it
– …loop…

• Environment specific
– I ...
Problem to solve
• Provisioning:
– automate trivial things
• install httpd, mysql, config, config, config…

• reuse:
– Pac...
Create VM

2/17/2014

Copyright 2013 Trend Micro Inc.
Basic Commands
• Vm status control:
–
–
–
–

Up
halt
destroy
reload
(for config change)
– resume
– suspend

2/17/2014

Cop...
Create a VM
• vagrant box add precise32
http://files.vagrantup.com/precise32.box
• Vagrant init precise32 (new a vagrantfi...
Networking
• default : eth0 for NAT
• Port forwarding
– config.vm.network :forwarded_port, host: 8070, guest: 8070

• Host...
More settings in Vagrantfile
• Hardware spec.
– config.vm.provider :virtualbox do |vb|
–
vb.customize ["modifyvm", :id, "-...
Provisioning

2/17/2014

Copyright 2013 Trend Micro Inc.
Shell
• Auto execute the shell script as root
• Vagrantfile syntax:
– config.vm.provision :shell, :path => "bootstrap.sh"
...
Puppet
• Auto apply a puppet script
• Vagrantfile syntax:
– config.vm.provision :puppet do |puppet|
– puppet.manifests_pat...
Plugins
• vagrant plugin install vagrant-vbox-snapshot
• vagrant plugin install vagrant-vbguest

2/17/2014

Copyright 2013...
Q&A

2/17/2014

Copyright 2013 Trend Micro Inc.
Backup Slides

2/17/2014

Copyright 2013 Trend Micro Inc.
Get ssh command on windows
• ssh
– Install git (MINGW)
– Install Cygwin (too fat, I think)

• There‟re many ways you can d...
Reference
• http://www.slideshare.net/ihower/vagrant-osdc
• https://github.com/mitchellh/vagrant-aws

• http://kvz.io/blog...
Upcoming SlideShare
Loading in …5
×

Vagrant

1,415 views

Published on

Published in: Technology
  • Be the first to comment

Vagrant

  1. 1. Vagrant
  2. 2. Agenda • Introduction to Vagrant • Create VM • Provisioning • plugins 2/17/2014 Copyright 2013 Trend Micro Inc.
  3. 3. Introduction 2/17/2014 Copyright 2013 Trend Micro Inc.
  4. 4. Vagrant • A open source command line VM provision tool • MIT licence • Still virtualization, but more easier, more flexible • Support shell, puppet, chef on provisioning 2/17/2014 Copyright 2013 Trend Micro Inc.
  5. 5. Easy to use and share http://www.vagrantbox.es/ http://puppet-vagrant-boxes.puppetlabs.com/ 2/17/2014 Copyright 2013 Trend Micro Inc.
  6. 6. Installation • Install virtualbox – https://www.virtualbox.org/wiki/Downloads • Install vagrant (support windows, mac, linux) – http://downloads.vagrantup.com/tags/v1.3.5 • Get GNU commands on windows (not necessary) – Install git (MINGW) – Install Cygwin (too fat) 2/17/2014 Copyright 2013 Trend Micro Inc.
  7. 7. Architecture Providers 2/17/2014 Copyright 2013 Trend Micro Inc.
  8. 8. How does it work? • Via VBoxManage tool • list running VM – $ VBoxManage list runningvms • pause VM – $ VBoxManage controlvm <vmname> pause • send poweroff single to VM (tells VM OS to shutdown) – $ VBoxManage controlvm <vmname> acpipowerbutton • … 2/17/2014 Copyright 2013 Trend Micro Inc.
  9. 9. Why we need it • Deploy a project on a machine for testing – mess things up – Fix it – …loop… • Environment specific – I can run it well on MY machine (cause I only test it on my machine) • Can not automate • I don‟t have machines… 2/17/2014 Copyright 2013 Trend Micro Inc.
  10. 10. Problem to solve • Provisioning: – automate trivial things • install httpd, mysql, config, config, config… • reuse: – Package configured VM as a “box” • testing: – clean environment for testing • Portable: – one box file – local machine 2/17/2014 Copyright 2013 Trend Micro Inc.
  11. 11. Create VM 2/17/2014 Copyright 2013 Trend Micro Inc.
  12. 12. Basic Commands • Vm status control: – – – – Up halt destroy reload (for config change) – resume – suspend 2/17/2014 Copyright 2013 Trend Micro Inc.
  13. 13. Create a VM • vagrant box add precise32 http://files.vagrantup.com/precise32.box • Vagrant init precise32 (new a vagrantfile) • Vagrant up (create VM) • vagrant ssh (get into the VM) 2/17/2014 Copyright 2013 Trend Micro Inc.
  14. 14. Networking • default : eth0 for NAT • Port forwarding – config.vm.network :forwarded_port, host: 8070, guest: 8070 • Host-only – config.vm.network :private_network, ip: "192.168.56.2“ • Bridge – config.vm.network :public_network – config.vm.network :public_network, :bridge => 'en0: Wi-Fi (AirPort)„ • (Not always work) 2/17/2014 Copyright 2013 Trend Micro Inc.
  15. 15. More settings in Vagrantfile • Hardware spec. – config.vm.provider :virtualbox do |vb| – vb.customize ["modifyvm", :id, "--memory", "1024"] – end • Hostname – config.vm.hostname = “YOUR_HOSTNAME“ • Share folder – config.vm.synced_folder "../data", "/vagrant_data“ host guest 2/17/2014 Copyright 2013 Trend Micro Inc.
  16. 16. Provisioning 2/17/2014 Copyright 2013 Trend Micro Inc.
  17. 17. Shell • Auto execute the shell script as root • Vagrantfile syntax: – config.vm.provision :shell, :path => "bootstrap.sh" • Command – $ vagrant provision –provision-with shell 2/17/2014 Copyright 2013 Trend Micro Inc.
  18. 18. Puppet • Auto apply a puppet script • Vagrantfile syntax: – config.vm.provision :puppet do |puppet| – puppet.manifests_path = "manifests" – puppet.manifest_file = "init.pp" – end • Folder structure: – Vagrantfile – Manifests – Init.pp 2/17/2014 Copyright 2013 Trend Micro Inc.
  19. 19. Plugins • vagrant plugin install vagrant-vbox-snapshot • vagrant plugin install vagrant-vbguest 2/17/2014 Copyright 2013 Trend Micro Inc.
  20. 20. Q&A 2/17/2014 Copyright 2013 Trend Micro Inc.
  21. 21. Backup Slides 2/17/2014 Copyright 2013 Trend Micro Inc.
  22. 22. Get ssh command on windows • ssh – Install git (MINGW) – Install Cygwin (too fat, I think) • There‟re many ways you can do to achieve this goal, My suggestion is to install git on your windows – Download git – 6 page quick tutorial • Then use putty to ssh in. 2/17/2014 Copyright 2013 Trend Micro Inc.
  23. 23. Reference • http://www.slideshare.net/ihower/vagrant-osdc • https://github.com/mitchellh/vagrant-aws • http://kvz.io/blog/2013/01/16/vagrant-tip-keep-virtualboxguest-additions-in-sync/ 2/17/2014 Copyright 2013 Trend Micro Inc.

×