SlideShare a Scribd company logo
1 of 37
Vagrant hackaton
Session Activities can be found here:
https://github.com/akranga/devops-hackathon-1
Vagrant
- Vagrant will mange VM for you
- Describe VM in configuration file
- Can put configuration in Source Control
- You can allow other to contribute
- You have full control on VM
Vagrant
- Ruby powered command line interface to
VM hosted in your Computer
- Supports multiple VM providers
(VirtualBox by default)
- Allows to create reproducible and
portable environments
Vagrant
- Supports run of Multi-VM environments
- Allows to create/restore snapshots of VM
- Allows package environment
- Environment configuration stored in file
(you can put it in git)
Installing Vagrant
- Download and install latest VirtualBox for your OS:
https://www.virtualbox.org/wiki/Downloads
- Download and install latest vagrant for your OS:
http://www.vagrantup.com/downloads.html
- Update PATH Environment System Variable. Add entries:
- VirtualBox location
- C:Program FilesOracleVirtualBox
- Vagrant location
- C:DevOpsvagrantbin
- Might require extra directories
- C:DevOpsvagrantembeddedbin
- C:DevOpsvagrantembeddedmingwbin
- C:DevOpsvagrantembeddedgemsbin
Vagrant Components
- Command Line Interface
- Vagrantfile
- Boxes
- Synced Folder
- Provisioning
- Multi Machine
- Providers
Command Line Interface
Vagrant basic operating model through CLI vagrant command
Running any vagrant subcommand with --help or –h prints context help
$ vagrant init
$ vagrant up
$ vagrant halt
$ vagrant reload
$ vagrant provision
$ vagrant destroy
$ vagrant ssh
$ vagrant ssh-config
Create initial Vagrant configuratoin
Start or create VM if not exists
Power down VM
Restart VM (useful when you change config)
Run Chef or Puppet scripts
Destroy VM as it never existed
Connect to VM if it is running
Prints SSH configuration
Command Line Interface
shell
$ vagrant box list
$ vagrant box add
$ vagrant box remove
$ vagrant box repackage
$ vagrant box outdated
$ vagrant box update
List all vagrant environments on your PC
Add basebox record to vagrant registry
Remove basebox (doesn’t terminate VM)
Make a snapshot of your VM
Deprecates the VM
Checks and updates a VM if it is out-dated
Additional commands to manage your vagrant environments
Vagrantfile
All VM configuration stored in Ruby DSL file. This file can be placed in git.
When you run vagrant up. Vagrant will check following directories.
./Vagrantfile
/home/mitchellh/projects/foo/Vagrantfile
/home/mitchellh/projects/Vagrantfile
/home/mitchellh/Vagrantfile
/home/Vagrantfile
/Vagrantfile
VAGRANT_CWD to change directory where Vagrant is looking for configuration
Boxes
Vagrantfile
Vagrant.configure "2" do |config|
config.vm.box = “my-vm"
config.vm.box_url = “box-url"
end
Minimal Vagrantfile looks like this
Vagrant file contains API versioning.
Vagrantfile (cont)
Vagrantfile
Vagrant.configure "2" do |config|
config.vm.box = “my-vm"
config.vm.box_url = “box-url“
(1..3).each do |i|
config.vm.define "slave-#{i}" do |slave|
slave.vm.provision "shell",
inline: "echo hello from slave #{i}"
end
end
end
How many machines will
run this file?
Modifying scripts
config.vm – to mange VM parameters
Vagrantfile
config.vm.box
config.vm.check_update
config.vm.box_url
config.vm.box_version
config.vm.box.hostname
config.vm.provider
cofnig.vm.synced_folder
Name to be associated with box
By default true. Can disable update checks
URL of the VM to download
Version of the basebox file
Hostname of the VM
By default VirtualBox. Can be other
By default current host dir mounted as
/Vagrant. Can map additional directory
inside VM
Modifying scripts
config.ssh – to customize SSH behavior
Vagrantfile
config.ssh.username
config.ssh.password
config.ssh.private_key_path
config.ssh.insert_key
config.ssh.shell
By default vagrant
No pass by default
Path to your SSH key. By default
/home/.vagrant.d/insecure_private_key
By default true. Can disable to use pass
Shell to open when ssh. By default bash -l
Boxes
To create a VM Vagrant needs a basebox file which is typically
Just Enough Operating System.
Baseboxes can be downloaded from Community websites
www.vagrantbox.es Offsite for Vagrant boxes
http://opscode.github.io/bento/ Vagrant boxes optimized for Chef
You can create your own box using
- Packer (http://packer.io)
- Packer templates for Chef optimized boxes can be found:
https://github.com/opscode/bento
Synced Folder
To enable Vagrant to sync files at your Host and Guest machine
By default mapped directory: /vagrant
Permissions: all files in synced folder are 0777
Vagrant Plugins
Vagrant is extremely pluggable.
You can add/costomize almost everything in Vagrant (such as add
VMWare, AWS or Docker providers), Chef or Puppet provisioning etc.
Vagrant has tons of plugins. Official hosted here:
https://github.com/mitchellh/vagrant/tree/master/plugins
Dog Food: API for Vagrant plugins:
http://en.wikipedia.org/wiki/Eating_your_own_dog_food
Most useful Plugins:
- vagrant-omnibus: Chef for Vagrant VMs
- vagrant-cachier: Cache for packages (can be reused across VMs)
- vagrant-berkshelf: Enable Chef cookbook dependency mechanism
Vagrant plugins command
CLI to manage vagrant plugins.
Will be installed in /home/.vagrant.d/gems
Shell
$ vagrant plugin install
$ vagrant plugin list
$ vagrant plugin uninstall
$ vagrant plugin update
Install vagrant plugin
List of installed plugins
Erase plugin
Check plugin and update with newer version
Activity 1
Run a vagrant box.
Activity 1
Go to /activity1 directory
1. Create a vagrant box file:
$ vagrant init vagrant-hackaton http://opscode-vm-
bento.s3.amazonaws.com/vagrant/vmware/opscode_ubuntu-14.04_chef-
provisionerless.box
2. Run command:
This will create a Vagrant configuration which is pointed to URL.
This is a good manner to specify Valid URL so vagrant config can be
repeatable out of box
$ vagrant up
This will start download image from Internet. Please spare our bandwidth
and terminate this process (CTRL+C). We will add image from our local disk
Activity 1
3. Check if nothing installed
$ vagrant box list
5. Spin up VM:
Vagrant should return no images. Otherwise we might overwrite one with
this activity. Or you might want to change name of VM by modifying
Vagrantfile
4. Add box manually with link to local file
$ vagrant box add vagrant-hackaton PATH-TO-BOX/opscode_ubuntu-
14.04_chef-provisionerless.box
$ vagrant up
6. Connect via SSH
$ vagrant ssh
Activity 1
7. Type command
$ vagrant destroy
8. Destroy VM
in VM
$ uptime
$ exit
Activity 2
Customize VM attributes
Activity 2
Go to /activity2 directory
1. Run command
$ vagrant up
This will bring VM to life. Vagrant will reuse basebox from local file because
activity2 VM has same name as VM from activty1
2. In the VM run command
You should get some HTML text on console. Before exiting SSH sesion
in VM
$ sudo apt-get install –y apache2 curl
$ http://localhost
$ exit
Activity 2
3. Modify Vagrantfile
This will instruct Vagrant to use cache on your Host machine all software
installed inside VM (vagrant requires plugin vagrant-cachier)
4. Modify Vagrantfile as per instructions
Vagrantfile: TODO2
config.vm.network :forwarded_port, guest: XXXXX, host: YYYYY
Vagrantfile: TODO1
config.cache.auto_detect = true
Vagrantfile: TODO3
config.vm.synced_folder "webapp/", "/var/www"
5. Modify Vagrantfile as per instructions
Activity 2
5. after Vagrantfile changes we need to raload VM
$ vagrant reload
6. With your browser open: http://localhost:80801
You will get something like this (on the right)
This is allright. We need to create a HTML
7. Create file webapp/index.html
webapp/index.html
<html>
<head><title>Hello World!</title><head>
<body><h1>Hello Vagrant!</h1></body
</html>
Activity 2
No needs to reload VM (directory will be synced automagically )
8. Refresh your browser at: http://localhost:80801
You will get something like this (on the right)
7. Destroy VM
$ vagrant destroy
Activity 3
Provision DB Server
Activity 3
Go to /activity3 directory
1. Run command
$ vagrant up
Vagrant will fail with
Vagrant:
* Unknown configuration section 'berkshelf'.
* Unknown configuration section 'omnibus'.
2. You need to install additional plugins
$ vagrant plugin install vagrant-berkshelf
$ vagrant plugin install vagrant-omnibus
$ vagrant up
Activity 3
Go to /activity3 directory
1. Run command
$ vagrant up
Vagrantfile has extra configuration that says it will use Chef (Omnibus
packaged) and Berkshelf to download cookbooks. But it doesn’t have plugins
and it will fail:
Vagrant:
* Unknown configuration section 'berkshelf'.
* Unknown configuration section 'omnibus'.
2. Check if plugins installed and install plugins
$ vagrant plugin list
$ vagrant plugin install vagrant-berkshelf
$ vagrant plugin install vagrant-omnibus
$ vagrant up
Activity 3
Go to /activity3 directory
1. Run command
$ vagrant up
Vagrantfile has extra configuration that says it will use Chef (Omnibus
packaged) and Berkshelf to download cookbooks. But it doesn’t have plugins
and it will fail:
Vagrant:
* Unknown configuration section 'berkshelf'.
* Unknown configuration section 'omnibus'.
2. Check if plugins installed and install plugins
$ vagrant plugin list
$ vagrant plugin install vagrant-berkshelf
$ vagrant plugin install vagrant-omnibus
$ vagrant up
Retrospective
How many VMs will this file run?
Vagrantfile
Vagrant.configure "2" do |config|
config.vm.box = “my-vm"
config.vm.box_url = “box-url“
(1..3).each do |i|
config.vm.define "slave-#{i}" do |slave|
slave.vm.provision "shell",
inline: "echo hello from slave #{i}"
end
end
end
Synced folder tricks
Vagrantfile
require 'rbconfig'
is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
Vagrant.configure "2" do |config|
config.vm.box = “my-vm"
config.vm.box_url = “box-url“
config.vm.synced_folder
"webapp/",
"/var/www/html",
nfs: is_windows
end
Synced folder in windows synchronizes in one direction. To enable it to
synchronize in both directions we need to say that host system is
Windows by setting parameter nfs to true
Synced folder tricks
Vagrantfile
require 'rbconfig'
is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
Vagrant.configure "2" do |config|
config.vm.box = “my-vm"
config.vm.box_url = “box-url“
config.vm.synced_folder
"webapp/",
"/var/www/html",
nfs: is_windows
end
Synced folder in windows synchronizes in one direction. To enable it to
synchronize in both directions we need to say that host system is
Windows by setting parameter nfs to true
Synced folder tricks
If Windows host machine you cannot create symlinks in synced directory
However there is a workaround.
1. Add vm customization parameter to Vagrantfile
Vagrantfile
config.vm.customize ["setextradata", :id,
"VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"] if
is_windows
2. Run vagrant up as user Administrator
Shell
$ git clone https://github.com/opscode/bento.git
$ cd bento/packer
bento/packer $ packer build ubuntu-13.10-amd64.json
Creating VM from scratch
Shell
bento/packer $ packer build 
-only=virtualbox 
-var-file=variables.json
ubuntu-13.10-amd64.json
Packer with extra params
variables.json
{
"chef_version": "latest",
"mirror": "../builds/iso/"
}

More Related Content

What's hot

Multi-provider Vagrant and Chef: AWS, VMware, and more
Multi-provider Vagrant and Chef: AWS, VMware, and moreMulti-provider Vagrant and Chef: AWS, VMware, and more
Multi-provider Vagrant and Chef: AWS, VMware, and moreChef Software, Inc.
 
Test-Driven Infrastructure with Chef
Test-Driven Infrastructure with ChefTest-Driven Infrastructure with Chef
Test-Driven Infrastructure with ChefMichael Lihs
 
Docker Docker Docker Chef
Docker Docker Docker ChefDocker Docker Docker Chef
Docker Docker Docker ChefSean OMeara
 
Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3kognate
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Puppet
 
Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11Yury Pliashkou
 
Vagrant crash course
Vagrant crash courseVagrant crash course
Vagrant crash courseMarcus Deglos
 
Automation and Ansible
Automation and AnsibleAutomation and Ansible
Automation and Ansiblejtyr
 
Deploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleDeploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleOrestes Carracedo
 
It Works On My Machine: Vagrant for Software Development
It Works On My Machine: Vagrant for Software DevelopmentIt Works On My Machine: Vagrant for Software Development
It Works On My Machine: Vagrant for Software DevelopmentCarlos Perez
 
Deploying an application with Chef and Docker
Deploying an application with Chef and DockerDeploying an application with Chef and Docker
Deploying an application with Chef and DockerDaniel Ku
 
Red Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with PuppetRed Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with PuppetMichael Lessard
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Michele Orselli
 
Linecook - A Chef Alternative
Linecook - A Chef AlternativeLinecook - A Chef Alternative
Linecook - A Chef Alternativethinkerbot
 
Orchestration? You Don't Need Orchestration. What You Want is Choreography.
Orchestration? You Don't Need Orchestration. What You Want is Choreography.Orchestration? You Don't Need Orchestration. What You Want is Choreography.
Orchestration? You Don't Need Orchestration. What You Want is Choreography.Julian Dunn
 
Python virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesPython virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesLarry Cai
 

What's hot (20)

Multi-provider Vagrant and Chef: AWS, VMware, and more
Multi-provider Vagrant and Chef: AWS, VMware, and moreMulti-provider Vagrant and Chef: AWS, VMware, and more
Multi-provider Vagrant and Chef: AWS, VMware, and more
 
Test-Driven Infrastructure with Chef
Test-Driven Infrastructure with ChefTest-Driven Infrastructure with Chef
Test-Driven Infrastructure with Chef
 
Docker Docker Docker Chef
Docker Docker Docker ChefDocker Docker Docker Chef
Docker Docker Docker Chef
 
Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
 
IT Automation with Chef
IT Automation with ChefIT Automation with Chef
IT Automation with Chef
 
Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11
 
Ansible - A 'crowd' introduction
Ansible - A 'crowd' introductionAnsible - A 'crowd' introduction
Ansible - A 'crowd' introduction
 
Vagrant crash course
Vagrant crash courseVagrant crash course
Vagrant crash course
 
Automation and Ansible
Automation and AnsibleAutomation and Ansible
Automation and Ansible
 
Deploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleDeploying PHP Applications with Ansible
Deploying PHP Applications with Ansible
 
Vagrant
VagrantVagrant
Vagrant
 
It Works On My Machine: Vagrant for Software Development
It Works On My Machine: Vagrant for Software DevelopmentIt Works On My Machine: Vagrant for Software Development
It Works On My Machine: Vagrant for Software Development
 
Deploying an application with Chef and Docker
Deploying an application with Chef and DockerDeploying an application with Chef and Docker
Deploying an application with Chef and Docker
 
Red Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with PuppetRed Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with Puppet
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)
 
Linecook - A Chef Alternative
Linecook - A Chef AlternativeLinecook - A Chef Alternative
Linecook - A Chef Alternative
 
Orchestration? You Don't Need Orchestration. What You Want is Choreography.
Orchestration? You Don't Need Orchestration. What You Want is Choreography.Orchestration? You Don't Need Orchestration. What You Want is Choreography.
Orchestration? You Don't Need Orchestration. What You Want is Choreography.
 
Python virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesPython virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutes
 
Ansible intro
Ansible introAnsible intro
Ansible intro
 

Viewers also liked

DevOps Days Tel Aviv - Serverless Architecture
DevOps Days Tel Aviv - Serverless ArchitectureDevOps Days Tel Aviv - Serverless Architecture
DevOps Days Tel Aviv - Serverless ArchitectureAntons Kranga
 
DevTernity - DevOps with smell
DevTernity - DevOps with smellDevTernity - DevOps with smell
DevTernity - DevOps with smellAntons Kranga
 
Antons Kranga Building Agile Infrastructures
Antons Kranga   Building Agile InfrastructuresAntons Kranga   Building Agile Infrastructures
Antons Kranga Building Agile InfrastructuresAntons Kranga
 
Java Day Kharkiv - Next-gen engineering with Docker and Kubernetes
Java Day Kharkiv - Next-gen engineering with Docker and KubernetesJava Day Kharkiv - Next-gen engineering with Docker and Kubernetes
Java Day Kharkiv - Next-gen engineering with Docker and KubernetesAntons Kranga
 
JavaDay Lviv: Serverless Archtiectures
JavaDay Lviv: Serverless ArchtiecturesJavaDay Lviv: Serverless Archtiectures
JavaDay Lviv: Serverless ArchtiecturesAntons Kranga
 
Riga dev day: Lambda architecture at AWS
Riga dev day: Lambda architecture at AWSRiga dev day: Lambda architecture at AWS
Riga dev day: Lambda architecture at AWSAntons Kranga
 
OpenSlava Infrastructure Automation Patterns
OpenSlava   Infrastructure Automation PatternsOpenSlava   Infrastructure Automation Patterns
OpenSlava Infrastructure Automation PatternsAntons Kranga
 
DevOps Hackathon: Session 3 - Test Driven Infrastructure
DevOps Hackathon: Session 3 - Test Driven InfrastructureDevOps Hackathon: Session 3 - Test Driven Infrastructure
DevOps Hackathon: Session 3 - Test Driven InfrastructureAntons Kranga
 
OpenSlava 2014 - CloudFoundry inside-out
OpenSlava 2014 - CloudFoundry inside-outOpenSlava 2014 - CloudFoundry inside-out
OpenSlava 2014 - CloudFoundry inside-outAntons Kranga
 
Dev ops with smell v1.2
Dev ops with smell v1.2Dev ops with smell v1.2
Dev ops with smell v1.2Antons Kranga
 

Viewers also liked (11)

DevOps Days Tel Aviv - Serverless Architecture
DevOps Days Tel Aviv - Serverless ArchitectureDevOps Days Tel Aviv - Serverless Architecture
DevOps Days Tel Aviv - Serverless Architecture
 
Robert kiyosaki pdf
Robert kiyosaki pdfRobert kiyosaki pdf
Robert kiyosaki pdf
 
DevTernity - DevOps with smell
DevTernity - DevOps with smellDevTernity - DevOps with smell
DevTernity - DevOps with smell
 
Antons Kranga Building Agile Infrastructures
Antons Kranga   Building Agile InfrastructuresAntons Kranga   Building Agile Infrastructures
Antons Kranga Building Agile Infrastructures
 
Java Day Kharkiv - Next-gen engineering with Docker and Kubernetes
Java Day Kharkiv - Next-gen engineering with Docker and KubernetesJava Day Kharkiv - Next-gen engineering with Docker and Kubernetes
Java Day Kharkiv - Next-gen engineering with Docker and Kubernetes
 
JavaDay Lviv: Serverless Archtiectures
JavaDay Lviv: Serverless ArchtiecturesJavaDay Lviv: Serverless Archtiectures
JavaDay Lviv: Serverless Archtiectures
 
Riga dev day: Lambda architecture at AWS
Riga dev day: Lambda architecture at AWSRiga dev day: Lambda architecture at AWS
Riga dev day: Lambda architecture at AWS
 
OpenSlava Infrastructure Automation Patterns
OpenSlava   Infrastructure Automation PatternsOpenSlava   Infrastructure Automation Patterns
OpenSlava Infrastructure Automation Patterns
 
DevOps Hackathon: Session 3 - Test Driven Infrastructure
DevOps Hackathon: Session 3 - Test Driven InfrastructureDevOps Hackathon: Session 3 - Test Driven Infrastructure
DevOps Hackathon: Session 3 - Test Driven Infrastructure
 
OpenSlava 2014 - CloudFoundry inside-out
OpenSlava 2014 - CloudFoundry inside-outOpenSlava 2014 - CloudFoundry inside-out
OpenSlava 2014 - CloudFoundry inside-out
 
Dev ops with smell v1.2
Dev ops with smell v1.2Dev ops with smell v1.2
Dev ops with smell v1.2
 

Similar to DevOps Hackathon - Session 1: Vagrant

Cooking Perl with Chef: Hello World Tutorial
Cooking Perl with Chef: Hello World TutorialCooking Perl with Chef: Hello World Tutorial
Cooking Perl with Chef: Hello World TutorialDavid Golden
 
Create Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantCreate Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantBrian Hogan
 
Puppet and Vagrant in development
Puppet and Vagrant in developmentPuppet and Vagrant in development
Puppet and Vagrant in developmentAdam Culp
 
Chef Workshop: Setup Environment with Chef,Vagrant, and Berkshelf
Chef Workshop: Setup Environment with Chef,Vagrant, and BerkshelfChef Workshop: Setup Environment with Chef,Vagrant, and Berkshelf
Chef Workshop: Setup Environment with Chef,Vagrant, and BerkshelfJun Sakata
 
Node.js, Vagrant, Chef, and Mathoid @ Benetech
Node.js, Vagrant, Chef, and Mathoid @ BenetechNode.js, Vagrant, Chef, and Mathoid @ Benetech
Node.js, Vagrant, Chef, and Mathoid @ BenetechChristopher Bumgardner
 
Create Disposable Test Environments with Vagrant and Puppet
Create Disposable Test Environments with Vagrant and PuppetCreate Disposable Test Environments with Vagrant and Puppet
Create Disposable Test Environments with Vagrant and PuppetGene Gotimer
 
Create Disposable Test Environments with Vagrant and Puppet
Create Disposable Test Environments with Vagrant and Puppet Create Disposable Test Environments with Vagrant and Puppet
Create Disposable Test Environments with Vagrant and Puppet Coveros, Inc.
 
Preparation study of_docker - (MOSG)
Preparation study of_docker  - (MOSG)Preparation study of_docker  - (MOSG)
Preparation study of_docker - (MOSG)Soshi Nemoto
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierCarlos Sanchez
 
Quick & Easy Dev Environments with Vagrant
Quick & Easy Dev Environments with VagrantQuick & Easy Dev Environments with Vagrant
Quick & Easy Dev Environments with VagrantJoe Ferguson
 
Vagrant - Version control your dev environment
Vagrant - Version control your dev environmentVagrant - Version control your dev environment
Vagrant - Version control your dev environmentbocribbz
 
How To Set a Vagrant Development System
How To Set a Vagrant Development SystemHow To Set a Vagrant Development System
How To Set a Vagrant Development SystemPaul Bearne
 
Oracle Developers APAC Meetup #1 - Working with Wercker Worksheets
Oracle Developers APAC Meetup #1 -  Working with Wercker WorksheetsOracle Developers APAC Meetup #1 -  Working with Wercker Worksheets
Oracle Developers APAC Meetup #1 - Working with Wercker WorksheetsDarrel Chia
 
Vagrant-Overview
Vagrant-OverviewVagrant-Overview
Vagrant-OverviewCrifkin
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for DevelopersJohn Coggeshall
 
Setup a Dev environment that feels like $HOME on Windows 10
Setup a Dev environment that feels like $HOME on Windows 10Setup a Dev environment that feels like $HOME on Windows 10
Setup a Dev environment that feels like $HOME on Windows 10Stefan Scherer
 
Professional deployment
Professional deploymentProfessional deployment
Professional deploymentIvelina Dimova
 

Similar to DevOps Hackathon - Session 1: Vagrant (20)

Vagrant
VagrantVagrant
Vagrant
 
Vagrant Up in 5 Easy Steps
Vagrant Up in 5 Easy StepsVagrant Up in 5 Easy Steps
Vagrant Up in 5 Easy Steps
 
Cooking Perl with Chef: Hello World Tutorial
Cooking Perl with Chef: Hello World TutorialCooking Perl with Chef: Hello World Tutorial
Cooking Perl with Chef: Hello World Tutorial
 
Create Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantCreate Development and Production Environments with Vagrant
Create Development and Production Environments with Vagrant
 
Puppet and Vagrant in development
Puppet and Vagrant in developmentPuppet and Vagrant in development
Puppet and Vagrant in development
 
Chef Workshop: Setup Environment with Chef,Vagrant, and Berkshelf
Chef Workshop: Setup Environment with Chef,Vagrant, and BerkshelfChef Workshop: Setup Environment with Chef,Vagrant, and Berkshelf
Chef Workshop: Setup Environment with Chef,Vagrant, and Berkshelf
 
Node.js, Vagrant, Chef, and Mathoid @ Benetech
Node.js, Vagrant, Chef, and Mathoid @ BenetechNode.js, Vagrant, Chef, and Mathoid @ Benetech
Node.js, Vagrant, Chef, and Mathoid @ Benetech
 
Create Disposable Test Environments with Vagrant and Puppet
Create Disposable Test Environments with Vagrant and PuppetCreate Disposable Test Environments with Vagrant and Puppet
Create Disposable Test Environments with Vagrant and Puppet
 
Create Disposable Test Environments with Vagrant and Puppet
Create Disposable Test Environments with Vagrant and Puppet Create Disposable Test Environments with Vagrant and Puppet
Create Disposable Test Environments with Vagrant and Puppet
 
Preparation study of_docker - (MOSG)
Preparation study of_docker  - (MOSG)Preparation study of_docker  - (MOSG)
Preparation study of_docker - (MOSG)
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next Frontier
 
Intro to vagrant
Intro to vagrantIntro to vagrant
Intro to vagrant
 
Quick & Easy Dev Environments with Vagrant
Quick & Easy Dev Environments with VagrantQuick & Easy Dev Environments with Vagrant
Quick & Easy Dev Environments with Vagrant
 
Vagrant - Version control your dev environment
Vagrant - Version control your dev environmentVagrant - Version control your dev environment
Vagrant - Version control your dev environment
 
How To Set a Vagrant Development System
How To Set a Vagrant Development SystemHow To Set a Vagrant Development System
How To Set a Vagrant Development System
 
Oracle Developers APAC Meetup #1 - Working with Wercker Worksheets
Oracle Developers APAC Meetup #1 -  Working with Wercker WorksheetsOracle Developers APAC Meetup #1 -  Working with Wercker Worksheets
Oracle Developers APAC Meetup #1 - Working with Wercker Worksheets
 
Vagrant-Overview
Vagrant-OverviewVagrant-Overview
Vagrant-Overview
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
 
Setup a Dev environment that feels like $HOME on Windows 10
Setup a Dev environment that feels like $HOME on Windows 10Setup a Dev environment that feels like $HOME on Windows 10
Setup a Dev environment that feels like $HOME on Windows 10
 
Professional deployment
Professional deploymentProfessional deployment
Professional deployment
 

Recently uploaded

VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Christo Ananth
 

Recently uploaded (20)

VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 

DevOps Hackathon - Session 1: Vagrant

  • 1. Vagrant hackaton Session Activities can be found here: https://github.com/akranga/devops-hackathon-1
  • 2. Vagrant - Vagrant will mange VM for you - Describe VM in configuration file - Can put configuration in Source Control - You can allow other to contribute - You have full control on VM
  • 3. Vagrant - Ruby powered command line interface to VM hosted in your Computer - Supports multiple VM providers (VirtualBox by default) - Allows to create reproducible and portable environments
  • 4. Vagrant - Supports run of Multi-VM environments - Allows to create/restore snapshots of VM - Allows package environment - Environment configuration stored in file (you can put it in git)
  • 5. Installing Vagrant - Download and install latest VirtualBox for your OS: https://www.virtualbox.org/wiki/Downloads - Download and install latest vagrant for your OS: http://www.vagrantup.com/downloads.html - Update PATH Environment System Variable. Add entries: - VirtualBox location - C:Program FilesOracleVirtualBox - Vagrant location - C:DevOpsvagrantbin - Might require extra directories - C:DevOpsvagrantembeddedbin - C:DevOpsvagrantembeddedmingwbin - C:DevOpsvagrantembeddedgemsbin
  • 6. Vagrant Components - Command Line Interface - Vagrantfile - Boxes - Synced Folder - Provisioning - Multi Machine - Providers
  • 7. Command Line Interface Vagrant basic operating model through CLI vagrant command Running any vagrant subcommand with --help or –h prints context help $ vagrant init $ vagrant up $ vagrant halt $ vagrant reload $ vagrant provision $ vagrant destroy $ vagrant ssh $ vagrant ssh-config Create initial Vagrant configuratoin Start or create VM if not exists Power down VM Restart VM (useful when you change config) Run Chef or Puppet scripts Destroy VM as it never existed Connect to VM if it is running Prints SSH configuration
  • 8. Command Line Interface shell $ vagrant box list $ vagrant box add $ vagrant box remove $ vagrant box repackage $ vagrant box outdated $ vagrant box update List all vagrant environments on your PC Add basebox record to vagrant registry Remove basebox (doesn’t terminate VM) Make a snapshot of your VM Deprecates the VM Checks and updates a VM if it is out-dated Additional commands to manage your vagrant environments
  • 9. Vagrantfile All VM configuration stored in Ruby DSL file. This file can be placed in git. When you run vagrant up. Vagrant will check following directories. ./Vagrantfile /home/mitchellh/projects/foo/Vagrantfile /home/mitchellh/projects/Vagrantfile /home/mitchellh/Vagrantfile /home/Vagrantfile /Vagrantfile VAGRANT_CWD to change directory where Vagrant is looking for configuration
  • 10. Boxes Vagrantfile Vagrant.configure "2" do |config| config.vm.box = “my-vm" config.vm.box_url = “box-url" end Minimal Vagrantfile looks like this Vagrant file contains API versioning.
  • 11. Vagrantfile (cont) Vagrantfile Vagrant.configure "2" do |config| config.vm.box = “my-vm" config.vm.box_url = “box-url“ (1..3).each do |i| config.vm.define "slave-#{i}" do |slave| slave.vm.provision "shell", inline: "echo hello from slave #{i}" end end end How many machines will run this file?
  • 12. Modifying scripts config.vm – to mange VM parameters Vagrantfile config.vm.box config.vm.check_update config.vm.box_url config.vm.box_version config.vm.box.hostname config.vm.provider cofnig.vm.synced_folder Name to be associated with box By default true. Can disable update checks URL of the VM to download Version of the basebox file Hostname of the VM By default VirtualBox. Can be other By default current host dir mounted as /Vagrant. Can map additional directory inside VM
  • 13. Modifying scripts config.ssh – to customize SSH behavior Vagrantfile config.ssh.username config.ssh.password config.ssh.private_key_path config.ssh.insert_key config.ssh.shell By default vagrant No pass by default Path to your SSH key. By default /home/.vagrant.d/insecure_private_key By default true. Can disable to use pass Shell to open when ssh. By default bash -l
  • 14. Boxes To create a VM Vagrant needs a basebox file which is typically Just Enough Operating System. Baseboxes can be downloaded from Community websites www.vagrantbox.es Offsite for Vagrant boxes http://opscode.github.io/bento/ Vagrant boxes optimized for Chef You can create your own box using - Packer (http://packer.io) - Packer templates for Chef optimized boxes can be found: https://github.com/opscode/bento
  • 15. Synced Folder To enable Vagrant to sync files at your Host and Guest machine By default mapped directory: /vagrant Permissions: all files in synced folder are 0777
  • 16. Vagrant Plugins Vagrant is extremely pluggable. You can add/costomize almost everything in Vagrant (such as add VMWare, AWS or Docker providers), Chef or Puppet provisioning etc. Vagrant has tons of plugins. Official hosted here: https://github.com/mitchellh/vagrant/tree/master/plugins Dog Food: API for Vagrant plugins: http://en.wikipedia.org/wiki/Eating_your_own_dog_food Most useful Plugins: - vagrant-omnibus: Chef for Vagrant VMs - vagrant-cachier: Cache for packages (can be reused across VMs) - vagrant-berkshelf: Enable Chef cookbook dependency mechanism
  • 17. Vagrant plugins command CLI to manage vagrant plugins. Will be installed in /home/.vagrant.d/gems Shell $ vagrant plugin install $ vagrant plugin list $ vagrant plugin uninstall $ vagrant plugin update Install vagrant plugin List of installed plugins Erase plugin Check plugin and update with newer version
  • 18. Activity 1 Run a vagrant box.
  • 19. Activity 1 Go to /activity1 directory 1. Create a vagrant box file: $ vagrant init vagrant-hackaton http://opscode-vm- bento.s3.amazonaws.com/vagrant/vmware/opscode_ubuntu-14.04_chef- provisionerless.box 2. Run command: This will create a Vagrant configuration which is pointed to URL. This is a good manner to specify Valid URL so vagrant config can be repeatable out of box $ vagrant up This will start download image from Internet. Please spare our bandwidth and terminate this process (CTRL+C). We will add image from our local disk
  • 20. Activity 1 3. Check if nothing installed $ vagrant box list 5. Spin up VM: Vagrant should return no images. Otherwise we might overwrite one with this activity. Or you might want to change name of VM by modifying Vagrantfile 4. Add box manually with link to local file $ vagrant box add vagrant-hackaton PATH-TO-BOX/opscode_ubuntu- 14.04_chef-provisionerless.box $ vagrant up 6. Connect via SSH $ vagrant ssh
  • 21. Activity 1 7. Type command $ vagrant destroy 8. Destroy VM in VM $ uptime $ exit
  • 23. Activity 2 Go to /activity2 directory 1. Run command $ vagrant up This will bring VM to life. Vagrant will reuse basebox from local file because activity2 VM has same name as VM from activty1 2. In the VM run command You should get some HTML text on console. Before exiting SSH sesion in VM $ sudo apt-get install –y apache2 curl $ http://localhost $ exit
  • 24. Activity 2 3. Modify Vagrantfile This will instruct Vagrant to use cache on your Host machine all software installed inside VM (vagrant requires plugin vagrant-cachier) 4. Modify Vagrantfile as per instructions Vagrantfile: TODO2 config.vm.network :forwarded_port, guest: XXXXX, host: YYYYY Vagrantfile: TODO1 config.cache.auto_detect = true Vagrantfile: TODO3 config.vm.synced_folder "webapp/", "/var/www" 5. Modify Vagrantfile as per instructions
  • 25. Activity 2 5. after Vagrantfile changes we need to raload VM $ vagrant reload 6. With your browser open: http://localhost:80801 You will get something like this (on the right) This is allright. We need to create a HTML 7. Create file webapp/index.html webapp/index.html <html> <head><title>Hello World!</title><head> <body><h1>Hello Vagrant!</h1></body </html>
  • 26. Activity 2 No needs to reload VM (directory will be synced automagically ) 8. Refresh your browser at: http://localhost:80801 You will get something like this (on the right) 7. Destroy VM $ vagrant destroy
  • 28. Activity 3 Go to /activity3 directory 1. Run command $ vagrant up Vagrant will fail with Vagrant: * Unknown configuration section 'berkshelf'. * Unknown configuration section 'omnibus'. 2. You need to install additional plugins $ vagrant plugin install vagrant-berkshelf $ vagrant plugin install vagrant-omnibus $ vagrant up
  • 29. Activity 3 Go to /activity3 directory 1. Run command $ vagrant up Vagrantfile has extra configuration that says it will use Chef (Omnibus packaged) and Berkshelf to download cookbooks. But it doesn’t have plugins and it will fail: Vagrant: * Unknown configuration section 'berkshelf'. * Unknown configuration section 'omnibus'. 2. Check if plugins installed and install plugins $ vagrant plugin list $ vagrant plugin install vagrant-berkshelf $ vagrant plugin install vagrant-omnibus $ vagrant up
  • 30. Activity 3 Go to /activity3 directory 1. Run command $ vagrant up Vagrantfile has extra configuration that says it will use Chef (Omnibus packaged) and Berkshelf to download cookbooks. But it doesn’t have plugins and it will fail: Vagrant: * Unknown configuration section 'berkshelf'. * Unknown configuration section 'omnibus'. 2. Check if plugins installed and install plugins $ vagrant plugin list $ vagrant plugin install vagrant-berkshelf $ vagrant plugin install vagrant-omnibus $ vagrant up
  • 32. How many VMs will this file run? Vagrantfile Vagrant.configure "2" do |config| config.vm.box = “my-vm" config.vm.box_url = “box-url“ (1..3).each do |i| config.vm.define "slave-#{i}" do |slave| slave.vm.provision "shell", inline: "echo hello from slave #{i}" end end end
  • 33. Synced folder tricks Vagrantfile require 'rbconfig' is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/) Vagrant.configure "2" do |config| config.vm.box = “my-vm" config.vm.box_url = “box-url“ config.vm.synced_folder "webapp/", "/var/www/html", nfs: is_windows end Synced folder in windows synchronizes in one direction. To enable it to synchronize in both directions we need to say that host system is Windows by setting parameter nfs to true
  • 34. Synced folder tricks Vagrantfile require 'rbconfig' is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/) Vagrant.configure "2" do |config| config.vm.box = “my-vm" config.vm.box_url = “box-url“ config.vm.synced_folder "webapp/", "/var/www/html", nfs: is_windows end Synced folder in windows synchronizes in one direction. To enable it to synchronize in both directions we need to say that host system is Windows by setting parameter nfs to true
  • 35. Synced folder tricks If Windows host machine you cannot create symlinks in synced directory However there is a workaround. 1. Add vm customization parameter to Vagrantfile Vagrantfile config.vm.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"] if is_windows 2. Run vagrant up as user Administrator
  • 36. Shell $ git clone https://github.com/opscode/bento.git $ cd bento/packer bento/packer $ packer build ubuntu-13.10-amd64.json Creating VM from scratch
  • 37. Shell bento/packer $ packer build -only=virtualbox -var-file=variables.json ubuntu-13.10-amd64.json Packer with extra params variables.json { "chef_version": "latest", "mirror": "../builds/iso/" }