SlideShare a Scribd company logo
1 of 28
Download to read offline
Vagrant
Why it’s awesome sauce AND a bag of
chips
What is Vagrant?
● Syntactic sugar around VMs
○ Virtualbox
○ VMWare
○ LXC
○ AWS
○ Rackspace
○ etc, etc, etc
What is Vagrant?
● Syntactic sugar around provisioning
○ Chef
○ Puppet
○ CFEngine
○ Scripts (bash, etc)
○ etc, etc, etc
What is Vagrant?
● Five commands
○ vagrant up
○ vagrant provision
○ vagrant ssh
○ vagrant suspend
○ vagrant destroy
● Actually 18 commands (v1.5)
○ You really only use the 5 above.
It’s just Ruby
● Runs on Windows, Linux, OSX
● Use all the programming constructs
○ loops
○ variables
○ etc
● Check the environment
○ Great for working with Jenkins
● Bring in gems
It’s just a configuration file
● You’re building a configuration file
○ Actions don’t happen immediately
● The Vagrant engine is intuitive
○ (usually)
require 'vagrant-vbguest'
max_memory = 4 * 1024 # This is in megabytes
Vagrant.configure("2") do |config|
config.vm.provider :virtualbox do |vb, override|
override.vm.box = "precise64"
override.vm.box_url = "http://some.place.com/some/path.box"
vb.customize ["modifyvm", :id, "--memory", max_memory]
end
end
require ‘vagrant-lxc’
max_memory = 4 * 1024 # This is in megabytes
Vagrant.configure("2") do |config|
config.vm.provider :lxc do |lxc, override|
override.vm.box = "precise64"
override.vm.box_url = "http://some.otherplace.com/some/path.box"
lxc.customize 'cgroup.memory.limit_in_bytes', "#{max_memory}M"
end
end
require 'vagrant-vbguest'
require ‘vagrant-lxc’
max_memory = 4 * 1024 # This is in megabytes
Vagrant.configure("2") do |config|
config.vm.provider :virtualbox do |vb, override|
….
end
config.vm.provider :lxc do |lxc, override|
….
end
end
Provider details
● Provider is specified in “vagrant up”
○ Other commands detect the provider
● There are dozens of providers
○ Virtualbox, VMWare, LXC, Docker
○ AWS, Joyent, Rackspace, DigitalOcean
○ OpenStack, Parallels
● Writing your own isn’t all that hard
○ Prior art is very helpful, as is mailing list and IRC
Shared Folders
● By default, the folder with the Vagrantfile is
shared into /vagrant
○ Can be changed
● Can add more shared folders
○ The provisioners already do this
● For cloud VMs, “shared” means “rsync’ed on
demand”.
Vagrant.configure("2") do |config|
chefdir = ‘.’
config.vm.provision :chef_solo do |chef|
chef.roles_path = “#{chefdir}/roles”
chef.run_list.clear
chef.add_role "container"
end
end
Vagrant.configure("2") do |config|
chefdir = ‘devops/chef’
config.vm.provision :chef_solo do |chef|
chef.roles_path = “#{chefdir}/roles”
chef.run_list.clear
chef.add_role "container"
end
end
Vagrant.configure("2") do |config|
config.vm.provision :shell,
inline: “some bash code here”
config.vm.provision :shell,
path: “path/to/script” # Must be relative to Vagrantfile directory
end
Provisioner details
● The order provisioners are declared matters.
○ If one fails, the remainder will not run.
● Can mix-and-match
○ Normally one chef/puppet/etc and several shell
Multiple VMs
● Can launch 1-N VMs
○ Each VM must have a unique name
● Each VM can have a different:
○ provider (one and only one)
○ set of provisioners
○ configuration, including:
■ network interface
Vagrant.configure("2") do |config|
config.vm.define “web” do |web|
web.vm.provision ‘shell’, inline: “echo “web” > /etc/vagrant_purpose”
web.vm.provider :chef-solo do |chef|
end
end
config.vm.define “database” do |database|
database.vm.provision ‘shell’, inline: “echo “database” > /etc/vagrant_purpose”
database.vm.provider :puppet do |puppet|
end
end
end
Vagrant.configure("2") do |config|
config.vm.provider :virtualbox do |vb, override|
...
end
(‘web’, ‘database’).each do |name|
config.vm.define name do |machine|
machine.vm.provision ‘shell’, inline: “echo “#{name}” > /etc/vagrant_purpose”
end
end
end
So what?
● This isn’t just another cool tool.
● Sometimes, all you need is simpler controls.
○ Everything has always been possible, just most
things are too expensive to build.
Clone production
● Dev and QA should be clones of Prod
○ Prod doesn’t run on a single server
○ So, why does QA and Dev?
Setup load-testing
● Use a cloud provider (AWS, etc)
● A Vagrantfile that has:
○ Your production structure
○ Your load-testing systems (Tsung, JMeter, etc)
● Running a load test is now just:
○ vagrant up
○ vagrant ssh load1 -c “/vagrant/bin/run_load_test.sh”
Jenkins and Testing
● Testing should be in a clone of Production
○ The best clone is what you’ll build Production from
● Jenkins can integrate with Vagrant
○ vagrant up
○ vagrant ssh -c “/vagrant/bin/run_tests.sh”
■ This will return the exit code properly
Vagrant.configure("2") do |config|
# Configure the AWS provider here
NUM = # Figure out how many instances to run
(1 .. NUM).each do |index|
config.vm.define “test#{index}” do |test|
test.vm.provision ‘shell’, inline: “echo “test#{index}” > /etc/vagrant_purpose”
test.vm.provider :aws do |aws|
aws.tags = { ‘Name’ => “#{aws.tags[‘Name’]}-test#{index}” }
end
end
end
end
Automate Golden Images
$ vagrant up --provider=aws
$ ec2-create-image 
`cat .vagrant/machines/default/aws/id` 
--name “my_new_ami”
$ vagrant destroy -f
Putting it all together (A Crazy Idea)
● Let developers manage server changes
○ Provisioners for a project are checked into that
project’s repository
○ Developers can make changes
○ Vagrant lets them test out changes in a clone of
production
○ Devops participates in code reviews (as needed)
■ Devops has veto over changes to devops/
directory and code.
Putting it all together (A Crazy Idea)
● Devops is no longer responsible for:
○ Server changes
● Devops IS responsible for:
○ Validating proposed server changes
○ Ensuring the pipeline for server changes
○ Training the developers to own their server changes
● Job changes
○ Build the engine instead of pulling the rickshaw
Community is key
● https://github.com/rails/rails-dev-box
● https://github.com/jpettersson/vagrant-rails-
project-box
○ Same thing, but with Chef
● http://manuel.manuelles.
nl/blog/2013/07/23/developing-ruby-on-rails-
on-windows/
○ Same thing, but on Windows
Questions?
Rob Kinyon
rob.kinyon@gmail.com
rkinyon on Twitter
robkinyon on IRC
www.greenfishbluefish.com

More Related Content

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Vagrant (crb, 2014 03-17)

  • 1. Vagrant Why it’s awesome sauce AND a bag of chips
  • 2. What is Vagrant? ● Syntactic sugar around VMs ○ Virtualbox ○ VMWare ○ LXC ○ AWS ○ Rackspace ○ etc, etc, etc
  • 3. What is Vagrant? ● Syntactic sugar around provisioning ○ Chef ○ Puppet ○ CFEngine ○ Scripts (bash, etc) ○ etc, etc, etc
  • 4. What is Vagrant? ● Five commands ○ vagrant up ○ vagrant provision ○ vagrant ssh ○ vagrant suspend ○ vagrant destroy ● Actually 18 commands (v1.5) ○ You really only use the 5 above.
  • 5. It’s just Ruby ● Runs on Windows, Linux, OSX ● Use all the programming constructs ○ loops ○ variables ○ etc ● Check the environment ○ Great for working with Jenkins ● Bring in gems
  • 6. It’s just a configuration file ● You’re building a configuration file ○ Actions don’t happen immediately ● The Vagrant engine is intuitive ○ (usually)
  • 7. require 'vagrant-vbguest' max_memory = 4 * 1024 # This is in megabytes Vagrant.configure("2") do |config| config.vm.provider :virtualbox do |vb, override| override.vm.box = "precise64" override.vm.box_url = "http://some.place.com/some/path.box" vb.customize ["modifyvm", :id, "--memory", max_memory] end end
  • 8. require ‘vagrant-lxc’ max_memory = 4 * 1024 # This is in megabytes Vagrant.configure("2") do |config| config.vm.provider :lxc do |lxc, override| override.vm.box = "precise64" override.vm.box_url = "http://some.otherplace.com/some/path.box" lxc.customize 'cgroup.memory.limit_in_bytes', "#{max_memory}M" end end
  • 9. require 'vagrant-vbguest' require ‘vagrant-lxc’ max_memory = 4 * 1024 # This is in megabytes Vagrant.configure("2") do |config| config.vm.provider :virtualbox do |vb, override| …. end config.vm.provider :lxc do |lxc, override| …. end end
  • 10. Provider details ● Provider is specified in “vagrant up” ○ Other commands detect the provider ● There are dozens of providers ○ Virtualbox, VMWare, LXC, Docker ○ AWS, Joyent, Rackspace, DigitalOcean ○ OpenStack, Parallels ● Writing your own isn’t all that hard ○ Prior art is very helpful, as is mailing list and IRC
  • 11. Shared Folders ● By default, the folder with the Vagrantfile is shared into /vagrant ○ Can be changed ● Can add more shared folders ○ The provisioners already do this ● For cloud VMs, “shared” means “rsync’ed on demand”.
  • 12. Vagrant.configure("2") do |config| chefdir = ‘.’ config.vm.provision :chef_solo do |chef| chef.roles_path = “#{chefdir}/roles” chef.run_list.clear chef.add_role "container" end end
  • 13. Vagrant.configure("2") do |config| chefdir = ‘devops/chef’ config.vm.provision :chef_solo do |chef| chef.roles_path = “#{chefdir}/roles” chef.run_list.clear chef.add_role "container" end end
  • 14. Vagrant.configure("2") do |config| config.vm.provision :shell, inline: “some bash code here” config.vm.provision :shell, path: “path/to/script” # Must be relative to Vagrantfile directory end
  • 15. Provisioner details ● The order provisioners are declared matters. ○ If one fails, the remainder will not run. ● Can mix-and-match ○ Normally one chef/puppet/etc and several shell
  • 16. Multiple VMs ● Can launch 1-N VMs ○ Each VM must have a unique name ● Each VM can have a different: ○ provider (one and only one) ○ set of provisioners ○ configuration, including: ■ network interface
  • 17. Vagrant.configure("2") do |config| config.vm.define “web” do |web| web.vm.provision ‘shell’, inline: “echo “web” > /etc/vagrant_purpose” web.vm.provider :chef-solo do |chef| end end config.vm.define “database” do |database| database.vm.provision ‘shell’, inline: “echo “database” > /etc/vagrant_purpose” database.vm.provider :puppet do |puppet| end end end
  • 18. Vagrant.configure("2") do |config| config.vm.provider :virtualbox do |vb, override| ... end (‘web’, ‘database’).each do |name| config.vm.define name do |machine| machine.vm.provision ‘shell’, inline: “echo “#{name}” > /etc/vagrant_purpose” end end end
  • 19. So what? ● This isn’t just another cool tool. ● Sometimes, all you need is simpler controls. ○ Everything has always been possible, just most things are too expensive to build.
  • 20. Clone production ● Dev and QA should be clones of Prod ○ Prod doesn’t run on a single server ○ So, why does QA and Dev?
  • 21. Setup load-testing ● Use a cloud provider (AWS, etc) ● A Vagrantfile that has: ○ Your production structure ○ Your load-testing systems (Tsung, JMeter, etc) ● Running a load test is now just: ○ vagrant up ○ vagrant ssh load1 -c “/vagrant/bin/run_load_test.sh”
  • 22. Jenkins and Testing ● Testing should be in a clone of Production ○ The best clone is what you’ll build Production from ● Jenkins can integrate with Vagrant ○ vagrant up ○ vagrant ssh -c “/vagrant/bin/run_tests.sh” ■ This will return the exit code properly
  • 23. Vagrant.configure("2") do |config| # Configure the AWS provider here NUM = # Figure out how many instances to run (1 .. NUM).each do |index| config.vm.define “test#{index}” do |test| test.vm.provision ‘shell’, inline: “echo “test#{index}” > /etc/vagrant_purpose” test.vm.provider :aws do |aws| aws.tags = { ‘Name’ => “#{aws.tags[‘Name’]}-test#{index}” } end end end end
  • 24. Automate Golden Images $ vagrant up --provider=aws $ ec2-create-image `cat .vagrant/machines/default/aws/id` --name “my_new_ami” $ vagrant destroy -f
  • 25. Putting it all together (A Crazy Idea) ● Let developers manage server changes ○ Provisioners for a project are checked into that project’s repository ○ Developers can make changes ○ Vagrant lets them test out changes in a clone of production ○ Devops participates in code reviews (as needed) ■ Devops has veto over changes to devops/ directory and code.
  • 26. Putting it all together (A Crazy Idea) ● Devops is no longer responsible for: ○ Server changes ● Devops IS responsible for: ○ Validating proposed server changes ○ Ensuring the pipeline for server changes ○ Training the developers to own their server changes ● Job changes ○ Build the engine instead of pulling the rickshaw
  • 27. Community is key ● https://github.com/rails/rails-dev-box ● https://github.com/jpettersson/vagrant-rails- project-box ○ Same thing, but with Chef ● http://manuel.manuelles. nl/blog/2013/07/23/developing-ruby-on-rails- on-windows/ ○ Same thing, but on Windows
  • 28. Questions? Rob Kinyon rob.kinyon@gmail.com rkinyon on Twitter robkinyon on IRC www.greenfishbluefish.com