Slide 1

Slide 1 text

Artūras Šmorgun, Inviqa Enlighten Lunch, 9th of May 2013 va·grant One who lives on the streets and constitutes a public nuisance.

Slide 2

Slide 2 text

$ vagrant a tool to manage virtual boxes sometimes annoying but easy and helpful (when works)

Slide 3

Slide 3 text

Versions 1.0.7 is widely used 1.2.2 is latest version 1.2.3 to be released soon

Slide 4

Slide 4 text

Vagrant 1.2.2 Compatibility Installation Configuration Plugins Windows support

Slide 5

Slide 5 text

1.1.x Fully compatible with 1.0.x (if you don’t use plugins)

Slide 6

Slide 6 text

1.x Fully compatible with 1.0.x Compatibility between 1.x not promised (until next stable release 2.0) (1.0 considered to be stable)

Slide 7

Slide 7 text

Installation No RubyGems since 1.0.x downloads.vagrantup.com Install as usual Logout and login back

Slide 8

Slide 8 text

Configuration Compatible with 1.0.x Versioning Vagrant.configure(“version#”) Vagrant.Config.run == Vagrant.configure(“1”)

Slide 9

Slide 9 text

Plugins Claimed to be compatible between version Many of them (and increasing)

Slide 10

Slide 10 text

vagrant-apache2, vagrant-aws, vagrant- berkshelf, vagrant-boxen, vagrant-bundler, vagrant-butcher, vagrant-digitalocean, vagrant- exec, vagrant-fog-box-storage, vagrant-host-path, vagrant-hostmaster, vagrant-hostmanager, vagrant-kvm, vagrant-librarian, vagrant- librarian-chef, vagrant-libvirt, vagrant-lxc, vagrant-mysql, vagrant-notify, vagrant-persistent- storage, vagrant-plugins, vagrant-rake, vagrant- rsync, vagrant-salt, vagrant-screenshot, vagrant- snap, vagrant-vbguest, nugrant, vagrant- sparseimage, vagrant-windows Last edited by p0deje, 10 days ago

Slide 11

Slide 11 text

vagrant-librarian-chef Automatically runs librarian-chef You will still need to have in installed git://github.com/jimmycuadra/vagrant-librarian-chef.git Vagrant 1.2.0+

Slide 12

Slide 12 text

vagrant-aws Provisioner Amazon EC2 git://github.com/mitchellh/vagrant-aws.git Vagrant 1.2.0+

Slide 13

Slide 13 text

usage: step #1 vagrant plugin install vagrant-aws

Slide 14

Slide 14 text

usage: step #2 Create box file metadata.json Vagrantfile Tar-gzip it

Slide 15

Slide 15 text

metadata.json { "provider": "aws" }

Slide 16

Slide 16 text

Vagrantfile # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| config.vm.provider :aws do |aws| aws.ami = "ami-7747d01e" end end

Slide 17

Slide 17 text

tar-gzip it! tar cvzf aws.box ./metadata.json \ ./Vagrantfile

Slide 18

Slide 18 text

usage: step #3 Project configuration with Vagrantfile Source box from last step Access details Configuration

Slide 19

Slide 19 text

Project structure > tools/ > vagrant/ > Vagrantfile

Slide 20

Slide 20 text

Vagrantfile # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| config.vm.provider :aws do |aws, override| end end

Slide 21

Slide 21 text

Vagrantfile: box # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| config.vm.box = "vagrant122-aws" config.vm.box_url = "file:///home/arturas/ Downloads/vagrant122-aws.box" <..> end

Slide 22

Slide 22 text

Vagrantfile: aws <..> config.vm.provider :aws do |aws, override| aws.access_key_id = 'key_id' aws.secret_access_key = 'secret_access_key' aws.keypair_name = 'Vagrant122' aws.region = 'eu-west-1' aws.instance_type = 'm1.micro' aws.ami = 'ami-f2191786' override.ssh.username = 'ubuntu' override.ssh.private_key_path = "path_to_pem" end <..>

Slide 23

Slide 23 text

https://portal.aws.amazon.com/gp/aws/securityCredentials

Slide 24

Slide 24 text

https://console.aws.amazon.com/ec2/home

Slide 25

Slide 25 text

usage: step #4 Project provisioning with Vagrantfile Shell script to install chef Add shell provision Add chef provision

Slide 26

Slide 26 text

Project structure > tools/ > vagrant/ > Vagrantfile > install_chef_solo.sh

Slide 27

Slide 27 text

install_chef_solo.sh #!/bin/bash sudo apt-get update sudo apt-get -y install rubygems sudo gem install chef

Slide 28

Slide 28 text

Project structure > tools/ > vagrant/ > Vagrantfile > install_chef_solo.sh

Slide 29

Slide 29 text

Vagrantfile: shell <..> config.vm.provision :shell do |shell| shell.path = "install_chef_solo.sh" end <..>

Slide 30

Slide 30 text

Project structure > tools/ > vagrant/ > Vagrantfile > install_chef_solo.sh > Cheffile > cookbooks/

Slide 31

Slide 31 text

Cheffile #!/usr/bin/env ruby #^syntax detection site 'http://community.opscode.com/api/v1' cookbook 'apache2', '>= 1.0.0' cookbook 'php', '>= 1.0.0' cookbook 'mysql', '>= 1.0.0'

Slide 32

Slide 32 text

Project structure > tools/ > vagrant/ > Vagrantfile > install_chef_solo.sh > Cheffile > cookbooks/

Slide 33

Slide 33 text

Vagrantfile: chef <..> config.vm.provision :chef_solo do |chef| chef.cookbooks_path = ["cookbooks"] chef.add_recipe "apache2" chef.add_recipe "php" chef.add_recipe "apache2::mod_php5" chef.add_recipe "mysql::server" chef.add_recipe "php::module_mysql" end <..>

Slide 34

Slide 34 text

usage: step #5 vagrant up --provider aws vagrant provision

Slide 35

Slide 35 text

Demonstration?

Slide 36

Slide 36 text

Questions? Artūras Šmorgun [email protected] @asarturas

Slide 37

Slide 37 text

Thank you! Artūras Šmorgun [email protected] @asarturas