SlideShare a Scribd company logo
Vagrant for Developers
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
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 collaboration
Host everything natviely
Master Image contains:
- All software installed
- All configuration
Hosted typically in project File Server
Often maintained by one Person
No team collaboration
Master Image
Master Image: Problems
Hard to distribute in big teams
Maintenance process is manual
Hard to maintain in parallel
Cannot use Version Control System
Just Enough Operating System
- Written declaratively
(just enough ruby DSL)
- Repeatable
- OS agnostic
- Source control
- Help from Community
- Testable
JEOS
Naked OS Configuration
V for Vagrant
www.vagrantup.com Off Site
www.vagrantbox.es VM Images
https://github.com/opscode/bento VM Images from Chef
Useful Links:
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
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 = "http://files.vagrantup.com/precise64.box"
end
Quick start v2
shell
$ vagrant box add NAME http://files.vagrantup.com/precise64.box
$ vagrant init
# modify Vagrantfile until you happy
$ vagrant up
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)
Modifying scripts
Vagrantfile
Vagrant.configure "2" do |config|
config.vm.box = "vagrant-1"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
end
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
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
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
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
Demo
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
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 plugin install vagrant-berkshelf
# Kind of apt-cache for Vagrant
$ vagrant plugin install vagrant-cachier
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
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
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 --provision
# to provision without restart
$ vagrant provision
Demo
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"
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
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
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
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
- 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
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
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
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 tuning
variables.json
{
"chef_version": "latest",
"mirror": "../builds/iso/"
}
Demo
Thank You!

More Related Content

PPTX
DevOps Hackathon - Session 1: Vagrant
PPTX
DevOps hackathon Session 2: Basics of Chef
PPTX
Java Day Kharkiv - Next-gen engineering with Docker and Kubernetes
PPTX
Vagrant to-aws-flow
PPTX
Baking docker using chef
PDF
Test-Driven Infrastructure with Chef
PPT
Learn basic ansible using docker
PDF
Vagrant for real (codemotion rome 2016)
DevOps Hackathon - Session 1: Vagrant
DevOps hackathon Session 2: Basics of Chef
Java Day Kharkiv - Next-gen engineering with Docker and Kubernetes
Vagrant to-aws-flow
Baking docker using chef
Test-Driven Infrastructure with Chef
Learn basic ansible using docker
Vagrant for real (codemotion rome 2016)

What's hot (20)

PDF
Ansible introduction - XX Betabeers Galicia
PDF
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
 
ODP
It Works On My Machine: Vagrant for Software Development
PDF
Server(less) Swift at SwiftCloudWorkshop 3
PDF
Ansible Introduction
PDF
Deploying Symfony | symfony.cat
PDF
Multi-provider Vagrant and Chef: AWS, VMware, and more
PDF
Infrastructure = Code
PDF
Infrastructure = code - 1 year later
PDF
Docker Docker Docker Chef
PDF
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
PDF
jbang: Unleash the power of Java for shell scripting
PDF
Vagrant for real codemotion (moar tips! ;-))
PPTX
London Community Summit - Habitat 2016
PDF
Ansible - A 'crowd' introduction
PPT
Python virtualenv & pip in 90 minutes
PDF
Deploying an application with Chef and Docker
PDF
Docker for (Java) Developers
PDF
Docker and Puppet for Continuous Integration
PPTX
Orchestration? You Don't Need Orchestration. What You Want is Choreography.
Ansible introduction - XX Betabeers Galicia
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
 
It Works On My Machine: Vagrant for Software Development
Server(less) Swift at SwiftCloudWorkshop 3
Ansible Introduction
Deploying Symfony | symfony.cat
Multi-provider Vagrant and Chef: AWS, VMware, and more
Infrastructure = Code
Infrastructure = code - 1 year later
Docker Docker Docker Chef
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
jbang: Unleash the power of Java for shell scripting
Vagrant for real codemotion (moar tips! ;-))
London Community Summit - Habitat 2016
Ansible - A 'crowd' introduction
Python virtualenv & pip in 90 minutes
Deploying an application with Chef and Docker
Docker for (Java) Developers
Docker and Puppet for Continuous Integration
Orchestration? You Don't Need Orchestration. What You Want is Choreography.
Ad

Viewers also liked (10)

PPTX
Riga dev day: Lambda architecture at AWS
PDF
DevOps Days Tel Aviv - Serverless Architecture
PDF
Robert kiyosaki pdf
PDF
DevTernity - DevOps with smell
PDF
Antons Kranga Building Agile Infrastructures
PDF
JavaDay Lviv: Serverless Archtiectures
PDF
OpenSlava Infrastructure Automation Patterns
PPTX
DevOps Hackathon: Session 3 - Test Driven Infrastructure
PPTX
OpenSlava 2014 - CloudFoundry inside-out
PDF
Dev ops with smell v1.2
Riga dev day: Lambda architecture at AWS
DevOps Days Tel Aviv - Serverless Architecture
Robert kiyosaki pdf
DevTernity - DevOps with smell
Antons Kranga Building Agile Infrastructures
JavaDay Lviv: Serverless Archtiectures
OpenSlava Infrastructure Automation Patterns
DevOps Hackathon: Session 3 - Test Driven Infrastructure
OpenSlava 2014 - CloudFoundry inside-out
Dev ops with smell v1.2
Ad

Similar to Vagrant introduction for Developers (20)

PPTX
How To Set a Vagrant Development System
PDF
Vagrant - Version control your dev environment
PDF
Vagrant For DevOps
PDF
Intro to vagrant
PPTX
Vagrant-Overview
KEY
Using Vagrant
KEY
Vagrant
PPT
Vagrant
PPTX
Vagrant and Chef on FOSSASIA 2014
PDF
DevOps Series: Defining and Sharing Testable Machine Configurations with vagrant
PDF
Create Development and Production Environments with Vagrant
PDF
Getting started with Vagrant
PPTX
Vagrant
PPTX
PPTX
Vagrant Up in 5 Easy Steps
PDF
Keep calm and vagrant up
PPTX
Vagrant - PugMI
PDF
Minicurso de Vagrant
PDF
Vagrant workshop 2015
PDF
Introduction to Vagrant
How To Set a Vagrant Development System
Vagrant - Version control your dev environment
Vagrant For DevOps
Intro to vagrant
Vagrant-Overview
Using Vagrant
Vagrant
Vagrant
Vagrant and Chef on FOSSASIA 2014
DevOps Series: Defining and Sharing Testable Machine Configurations with vagrant
Create Development and Production Environments with Vagrant
Getting started with Vagrant
Vagrant
Vagrant Up in 5 Easy Steps
Keep calm and vagrant up
Vagrant - PugMI
Minicurso de Vagrant
Vagrant workshop 2015
Introduction to Vagrant

Recently uploaded (20)

PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
cuic standard and advanced reporting.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPT
Teaching material agriculture food technology
PDF
Modernizing your data center with Dell and AMD
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
 
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Big Data Technologies - Introduction.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
cuic standard and advanced reporting.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
“AI and Expert System Decision Support & Business Intelligence Systems”
Dropbox Q2 2025 Financial Results & Investor Presentation
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Teaching material agriculture food technology
Modernizing your data center with Dell and AMD
CIFDAQ's Market Insight: SEC Turns Pro Crypto
 
Review of recent advances in non-invasive hemoglobin estimation
Big Data Technologies - Introduction.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Unlocking AI with Model Context Protocol (MCP)
20250228 LYD VKU AI Blended-Learning.pptx
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy

Vagrant introduction for Developers

  • 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. Motivation Basic Vagrant Usage Provisioning with Cookbooks Base Images Creation Agenda
  • 4. Motivation Basic Vagrant Usage Provisioning with Cookbooks Base Images Creation Agenda
  • 5. How do you manage your Dev Env?
  • 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. 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. Master Image: Problems Hard to distribute in big teams Maintenance process is manual Hard to maintain in parallel Cannot use Version Control System
  • 10. - Written declaratively (just enough ruby DSL) - Repeatable - OS agnostic - Source control - Help from Community - Testable JEOS Naked OS Configuration
  • 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. 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. Motivation Basic Vagrant Usage Provisioning with Cookbooks Base Images Creation Agenda
  • 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. Quick start v2 shell $ vagrant box add NAME http://files.vagrantup.com/precise64.box $ vagrant init # modify Vagrantfile until you happy $ vagrant up
  • 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. 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. 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. 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. 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. 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. Demo
  • 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. Motivation Basic Vagrant Usage Provisioning with Cookbooks Base Images Creation Agenda
  • 25. - You declare what software you want - Chef will provision it for you - Over 1300 cookbooks Chef
  • 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. 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. 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. Create berkshelf configuration Berksfile site :opscode metadata cookbook "apache2"
  • 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. Demo
  • 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. 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. 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. 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. Motivation Basic Vagrant Usage Provisioning with Cookbooks Base Images Creation Agenda
  • 37. Motivation Custom project specifics OS-level patching Produce Stemcells (preinstalled images) True Infra-as-code
  • 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. 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. 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. Shell bento/packer $ packer build -only=virtualbox-iso ubuntu-13.10-amd64.json Little bit more tuning
  • 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. Demo