Your SlideShare is downloading. ×
0
Vagrant for Developers
Presenter
- Technology Architect at Accenture
- 10+ years Enterprise Java Developmentg
- Areas of work:
- Open Source acti...
Motivation
Basic Vagrant Usage
Provisioning with Cookbooks
Base Images Creation
Agenda
Motivation
Basic Vagrant Usage
Provisioning with Cookbooks
Base Images Creation
Agenda
How do you manage your Dev Env?
Low or no automation at all
Long error-prone install guides
Painful maintenance or recovery
Painful rollback
No team colla...
Master Image contains:
- All software installed
- All configuration
Hosted typically in project File Server
Often maintain...
Master Image: Problems
Hard to distribute in big teams
Maintenance process is manual
Hard to maintain in parallel
Cannot u...
Just Enough Operating System
- Written declaratively
(just enough ruby DSL)
- Repeatable
- OS agnostic
- Source control
- Help from Community
- Testabl...
V for Vagrant
www.vagrantup.com Off Site
www.vagrantbox.es VM Images
https://github.com/opscode/bento VM Images from Chef
...
Vagrant
- Vagrant will mange VM for you
- Can create whole stack of VMs
- Describe VM resources in Configuration
- Can put...
Motivation
Basic Vagrant Usage
Provisioning with Cookbooks
Base Images Creation
Agenda
Quick start
shell
$ vagrant up
Vagrantfile
Vagrant.configure "2" do |config|
config.vm.box = "vagrant-1"
config.vm.box_url...
Quick start v2
shell
$ vagrant box add NAME http://files.vagrantup.com/precise64.box
$ vagrant init
# modify Vagrantfile u...
Most useful commands
shell
$ vagrant ssh # Connect to VM
$ vagrant reload # Connect to VM
$ vagrant halt # Stop VM
$ vagra...
Modifying scripts
Vagrantfile
Vagrant.configure "2" do |config|
config.vm.box = "vagrant-1"
config.vm.box_url = "http://fi...
Modifying scripts
Vagrantfile
Vagrant.configure "2" do |config|
config.vm.box = "vagrant-1"
config.vm.box_url = "http://fi...
Modifying scripts
Vagrantfile
Vagrant.configure "2" do |config|
config.vm.box = "vagrant-1"
config.vm.box_url = "http://fi...
Modifying scripts
Vagrantfile
Vagrant.configure "2" do |config|
config.vm.box = "vagrant-1"
config.vm.box_url = "http://fi...
Modifying scripts
Vagrantfile
Vagrant.configure "2" do |config|
config.vm.box = "vagrant-1"
config.vm.box_url = "http://fi...
Demo
Vagrantfile
Vagrant.configure "2" do |config|
config.vm.define :ubuntu1204 do |ubuntu1204|
ubuntu1204.vm.box = "example4-u...
Motivation
Basic Vagrant Usage
Provisioning with Cookbooks
Base Images Creation
Agenda
- You declare what software you want
- Chef will provision it for you
- Over 1300 cookbooks
Chef
Before you start
shell
# install Chef plugin
$ vagrant plugin install vagrant-omnibus
# install Berkshelf plugin
$ vagrant...
Update configuration
Vagrantfile
Vagrant.configure "2" do |config|
config.vm.box = "vagrant-5"
config.vm.box_url = "http:/...
Update configuration
Vagrantfile
Vagrant.configure "2" do |config|
config.vm.box = "vagrant-5"
config.vm.box_url = "http:/...
Create berkshelf configuration
Berksfile
site :opscode
metadata
cookbook "apache2"
Provisioning commands
shell
# to provision for first time just enough
$ vagrant up
# to restart VM
$ vagrant reload --prov...
Demo
Create berkshelf configuration
Berksfile
site :opscode
metadata
cookbook 'apt'
cookbook 'git'
cookbook 'tomcat', git: "htt...
Vagrantfile
Vagrant.configure "2" do |config|
config.vm.box = "vagrant-5"
config.vm.box_url = "http://files.vagrantup.com/...
Vagrantfile
Vagrant.configure "2" do |config|
config.vm.box = "vagrant-5"
config.vm.box_url = "http://files.vagrantup.com/...
Vagrantfile
Vagrant.configure "2" do |config|
config.vm.box = "vagrant-5"
config.vm.box_url = "http://files.vagrantup.com/...
Motivation
Basic Vagrant Usage
Provisioning with Cookbooks
Base Images Creation
Agenda
Motivation
Custom project specifics
OS-level patching
Produce Stemcells
(preinstalled images)
True Infra-as-code
Tools we need
“Packer is a tool for creating identical
machine images for multiple platforms…”
- Off Site: packer.io
- Wri...
Shell
$ git clone https://github.com/opscode/bento.git
$ cd bento/packer
bento/packer $ packer build ubuntu-13.10-amd64.js...
Shell
$ git clone https://github.com/opscode/bento.git
$ cd bento/packer
bento/packer $ packer build ubuntu-13.10-amd64.js...
Shell
bento/packer $ packer build 
-only=virtualbox-iso 
ubuntu-13.10-amd64.json
Little bit more tuning
Shell
bento/packer $ packer build 
-only=virtualbox 
-var-file=variables.json
ubuntu-13.10-amd64.json
Little bit more tuni...
Demo
Thank You!
Upcoming SlideShare
Loading in...5
×

Vagrant introduction for Developers

1,352

Published on

Vagrant introduction to development teams.

Published in: Technology
0 Comments
13 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,352
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
46
Comments
0
Likes
13
Embeds 0
No embeds

No notes for slide

Transcript of "Vagrant introduction for Developers"

  1. 1. Vagrant for Developers
  2. 2. Presenter - Technology Architect at Accenture - 10+ years Enterprise Java Developmentg - Areas of work: - Open Source activist - DevOps evangelist - Technical and OO Trainer - Cloud and PaaS development http://www.linkedin.com/in/antonskranga
  3. 3. Motivation Basic Vagrant Usage Provisioning with Cookbooks Base Images Creation Agenda
  4. 4. Motivation Basic Vagrant Usage Provisioning with Cookbooks Base Images Creation Agenda
  5. 5. How do you manage your Dev Env?
  6. 6. Low or no automation at all Long error-prone install guides Painful maintenance or recovery Painful rollback No team collaboration Host everything natviely
  7. 7. Master Image contains: - All software installed - All configuration Hosted typically in project File Server Often maintained by one Person No team collaboration Master Image
  8. 8. Master Image: Problems Hard to distribute in big teams Maintenance process is manual Hard to maintain in parallel Cannot use Version Control System
  9. 9. Just Enough Operating System
  10. 10. - Written declaratively (just enough ruby DSL) - Repeatable - OS agnostic - Source control - Help from Community - Testable JEOS Naked OS Configuration
  11. 11. V for Vagrant www.vagrantup.com Off Site www.vagrantbox.es VM Images https://github.com/opscode/bento VM Images from Chef Useful Links:
  12. 12. Vagrant - Vagrant will mange VM for you - Can create whole stack of VMs - Describe VM resources in Configuration - Can put configuration in Source Control - Easy to distribute and update
  13. 13. Motivation Basic Vagrant Usage Provisioning with Cookbooks Base Images Creation Agenda
  14. 14. Quick start shell $ vagrant up Vagrantfile Vagrant.configure "2" do |config| config.vm.box = "vagrant-1" config.vm.box_url = "http://files.vagrantup.com/precise64.box" end
  15. 15. Quick start v2 shell $ vagrant box add NAME http://files.vagrantup.com/precise64.box $ vagrant init # modify Vagrantfile until you happy $ vagrant up
  16. 16. Most useful commands shell $ vagrant ssh # Connect to VM $ vagrant reload # Connect to VM $ vagrant halt # Stop VM $ vagrant destroy # delete VM $ vagrant package # Create snapshot (.box file)
  17. 17. Modifying scripts Vagrantfile Vagrant.configure "2" do |config| config.vm.box = "vagrant-1" config.vm.box_url = "http://files.vagrantup.com/precise64.box" end
  18. 18. Modifying scripts Vagrantfile Vagrant.configure "2" do |config| config.vm.box = "vagrant-1" config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.hostname = “vmhost" end
  19. 19. Modifying scripts Vagrantfile Vagrant.configure "2" do |config| config.vm.box = "vagrant-1" config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.hostname = “vmhost" config.vm.network :forwarded_port, guest: 80, host: 1080 end
  20. 20. Modifying scripts Vagrantfile Vagrant.configure "2" do |config| config.vm.box = "vagrant-1" config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.hostname = “vmhost" config.vm.network :forwarded_port, guest: 80, host: 1080 config.vm.synced_folder “webapp/", "/var/www" end
  21. 21. Modifying scripts Vagrantfile Vagrant.configure "2" do |config| config.vm.box = "vagrant-1" config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.hostname = “vmhost" config.vm.network :forwarded_port, guest: 80, host: 1080 config.vm.synced_folder “webapp/", "/var/www“ config.vm.provider "virtualbox" do |v| v.customize ["modifyvm", :id, "--memory", 1024] end end
  22. 22. Demo
  23. 23. Vagrantfile Vagrant.configure "2" do |config| config.vm.define :ubuntu1204 do |ubuntu1204| ubuntu1204.vm.box = "example4-ubuntu-12.10" ubuntu1204.vm.box_url = "http://files.vagrantup..." ubuntu1204.vm.hostname = "example4-ubuntu-1210" ubuntu1204.vm.network :forwarded_port, guest: 80, host: 1080 ubuntu1204.vm.network :private_network, ip: "34.33.33.10" end config.vm.define :ubuntu1310 do |ubuntu1310| ubuntu1310.vm.box = "example4-ubuntu-13.10" ubuntu1310.vm.box_url = "http://files.vagrantup..." ubuntu1310.vm.hostname = "example4-ubuntu-1310" ubuntu1204.vm.network :forwarded_port, guest: 80, host: 2080 ubuntu1204.vm.network :private_network, ip: "34.33.33.11" end config.vm.provider "virtualbox" do |v| v.customize ["modifyvm", :id, "--memory", 1024] end end
  24. 24. Motivation Basic Vagrant Usage Provisioning with Cookbooks Base Images Creation Agenda
  25. 25. - You declare what software you want - Chef will provision it for you - Over 1300 cookbooks Chef
  26. 26. Before you start shell # install Chef plugin $ vagrant plugin install vagrant-omnibus # install Berkshelf plugin $ vagrant plugin install vagrant-berkshelf # Kind of apt-cache for Vagrant $ vagrant plugin install vagrant-cachier
  27. 27. Update configuration Vagrantfile Vagrant.configure "2" do |config| config.vm.box = "vagrant-5" config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.hostname = “localhost" config.vm.network :forwarded_port, guest: 80, host: 1080 config.vm.synced_folder “webapp/", "/var/www“ config.omnibus.chef_version = :latest config.berkshelf.enabled = true config.cache.auto_detect = true end
  28. 28. Update configuration Vagrantfile Vagrant.configure "2" do |config| config.vm.box = "vagrant-5" config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.hostname = “localhost" config.vm.network :forwarded_port, guest: 80, host: 1080 config.vm.synced_folder “webapp/", "/var/www“ config.omnibus.chef_version = :latest config.berkshelf.enabled = true config.cache.auto_detect = true config.vm.provision :chef_solo do |chef| chef.add_recipe “apache2“ end end
  29. 29. Create berkshelf configuration Berksfile site :opscode metadata cookbook "apache2"
  30. 30. Provisioning commands shell # to provision for first time just enough $ vagrant up # to restart VM $ vagrant reload --provision # to provision without restart $ vagrant provision
  31. 31. Demo
  32. 32. Create berkshelf configuration Berksfile site :opscode metadata cookbook 'apt' cookbook 'git' cookbook 'tomcat', git: "https://github.com/opscode-cookbooks/tomcat.git" cookbook 'maven' cookbook 'mongodb' # cookbook 'mycookbook', :path => "cookbooks/mycookbook"
  33. 33. Vagrantfile Vagrant.configure "2" do |config| config.vm.box = "vagrant-5" config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.hostname = “localhost" config.vm.network :forwarded_port, guest: 8080, host: 1080 config.omnibus.chef_version = :latest config.berkshelf.enabled = true config.cache.auto_detect = true config.vm.provision :chef_solo do |chef| chef.add_recipe "mongodb::10gen_repo" chef.add_recipe "apt" chef.add_recipe "git" chef.add_recipe "maven" chef.add_recipe "mongodb" chef.add_recipe "tomcat" end end
  34. 34. Vagrantfile Vagrant.configure "2" do |config| config.vm.box = "vagrant-5" config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.hostname = “localhost" config.vm.network :forwarded_port, guest: 8080, host: 1080 ... config.vm.provision :chef_solo do |chef| chef.add_recipe "mongodb::10gen_repo" chef.add_recipe "apt" chef.add_recipe "git" chef.add_recipe "maven" chef.add_recipe "mongodb" chef.add_recipe "tomcat" chef.json = { "java" => { "jdk_version" => "7", "install_flavor" => "openjdk" } } end end
  35. 35. Vagrantfile Vagrant.configure "2" do |config| config.vm.box = "vagrant-5" config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.hostname = “localhost" config.vm.network :forwarded_port, guest: 8080, host: 1080 ... config.vm.provision :chef_solo do |chef| chef.add_recipe "mongodb::10gen_repo" chef.add_recipe "apt" chef.add_recipe "git" chef.add_recipe "maven" chef.add_recipe "mongodb" chef.add_recipe "tomcat" chef.json = { "java" => { "jdk_version" => "7", "install_flavor" => "oracle", "accept_oracle_download_terms" => true } } end end
  36. 36. Motivation Basic Vagrant Usage Provisioning with Cookbooks Base Images Creation Agenda
  37. 37. Motivation Custom project specifics OS-level patching Produce Stemcells (preinstalled images) True Infra-as-code
  38. 38. Tools we need “Packer is a tool for creating identical machine images for multiple platforms…” - Off Site: packer.io - Written in Go - Must be installed to ~/pakcer “Bento is set of Packer templates for building Vagrant baseboxes” - Off Site: opscode.github.io/bento/ - Maintained by Chef
  39. 39. Shell $ git clone https://github.com/opscode/bento.git $ cd bento/packer bento/packer $ packer build ubuntu-13.10-amd64.json Quick start with Packer
  40. 40. Shell $ git clone https://github.com/opscode/bento.git $ cd bento/packer bento/packer $ packer build ubuntu-13.10-amd64.json Quick start with Packer
  41. 41. Shell bento/packer $ packer build -only=virtualbox-iso ubuntu-13.10-amd64.json Little bit more tuning
  42. 42. Shell bento/packer $ packer build -only=virtualbox -var-file=variables.json ubuntu-13.10-amd64.json Little bit more tuning variables.json { "chef_version": "latest", "mirror": "../builds/iso/" }
  43. 43. Demo
  44. 44. Thank You!
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×