Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Tamed Localized Development with Vagrant

Tamed Localized Development with Vagrant

Talk given at DrupalCampCT 2012.

Tamed Localized Development with Vagrant
Nick Silkey Senior UNIX Systems Engineer, Yale University

Vagrant, a free open-source tool with multi-platform support, facilitates the manipulation of local, virtualized environments. It lowers development environment setup time, maximizes dev/prod parity, and maintains consistent development environments over multiple projects. This talk is aimed at Drupal developers of all levels (themers, core hackers) along with ops engineers whom support Drupal as a service. More info on Vagrant at http://vagrantup.com/.

Nick Silkey

August 18, 2012
Tweet

More Decks by Nick Silkey

Other Decks in Technology

Transcript

  1. Tamed Localized
    Development
    with Vagrant

    View full-size slide

  2. Nick Silkey
    @filler

    View full-size slide

  3. http://www.core77.com/hack2school/cheatsheet.asp

    View full-size slide

  4. http://www.flickr.com/photos/22274117@N08/4234271994/

    View full-size slide

  5. http://pineapplesqueen.deviantart.com/art/Infinite-Loop-145899130

    View full-size slide

  6. Vagrant is open-source software for
    creating and configuring virtual
    development environments. It can be
    considered a wrapper around
    VirtualBox and configuration
    management software such as Chef and
    Puppet. Although written in Ruby, it
    is usable in other programming
    projects such as PHP, Python, Java,
    and C#.
    - http://en.wikipedia.org/wiki/
    Vagrant_(software)

    View full-size slide

  7. Vagrant lowers development
    environment setup time,
    maximizes dev/prod parity,
    and makes the "works on my
    machine" excuse a relic of
    the past.
    - http://vagrantup.com/

    View full-size slide

  8. $ vagrant init
    $ vagrant up
    $ vagrant provision
    $ vagrant ssh
    $ vagrant reload
    $ vagrant destroy

    View full-size slide

  9. # Every Vagrant virtual environment
    # requires a box to build off of.
    #
    config.vm.box = "base"
    # The url from where the 'config.vm.box'
    # box will be fetched if it doesn't already
    # exist on the user's system.
    #
    config.vm.box_url = "http://domain.com/
    path/to/above.box"

    View full-size slide

  10. # Boot with a GUI so you can
    # see the screen. (Default is
    # headless)
    #
    # config.vm.boot_mode = :gui

    View full-size slide

  11. # Assign this VM to a host-only network
    # IP, allowing you to access it via the IP.
    # Host-only networks can talk to the host
    # machine as well as any other machines on
    # the same network, but cannot be accessed
    # (through this network interface) by any
    # external networks.
    #
    # config.vm.network :hostonly,
    "33.33.33.10"

    View full-size slide

  12. # Assign this VM to a bridged network,
    # allowing you to connect directly to a
    # network using the host's network device.
    # This makes the VM appear as another
    # physical device on your network.
    #
    # config.vm.network :bridged

    View full-size slide

  13. # Forward a port from the guest to the
    # host, which allows for outside
    # computers to access the VM, whereas host
    # only networking does not.
    #
    # config.vm.forward_port 80, 8080

    View full-size slide

  14. # Share an additional folder to the guest
    # VM. The first argument is an identifier,
    # the second is the path on the guest to
    # mount the folder, and the third is the
    # path on the host to the actual folder.
    #
    # config.vm.share_folder "v-data", "/
    vagrant_data", "../data"
    config.vm.share_folder "drupal-7.15", "/
    var/www/html", "./drupal-7.15"

    View full-size slide

  15. Vagrant::Config.run do |config|
    config.vm.define :web do |web_config|
    web_config.vm.box = "web"
    web_config.vm.forward_port 80, 8080
    end
    config.vm.define :db do |db_config|
    db_config.vm.box = "db"
    db_config.vm.forward_port 3306, 3306
    end
    end

    View full-size slide

  16. Vagrant::Config.run do |config|
    config.vm.define :varnish do |varnish_config|
    varnish_config.vm.box = "varnish"
    varnish_config.vm.forward_port 6081, 6081
    end
    config.vm.define :web do |web_config|
    web_config.vm.box = "web"
    web_config.vm.forward_port 80, 8080
    end
    config.vm.define :db do |db_config|
    db_config.vm.box = "db"
    db_config.vm.forward_port 3306, 3306
    end
    end

    View full-size slide

  17. Vagrant::Config.run do |config|
    config.vm.define :varnish do |varnish_config|
    varnish_config.vm.box = "varnish"
    varnish_config.vm.forward_port 6081, 6081
    end
    config.vm.define :web1 do |web1_config|
    web1_config.vm.box = "web1"
    web1_config.vm.forward_port 80, 8081
    end
    config.vm.define :web2 do |web2_config|
    web2_config.vm.box = "web2"
    web2_config.vm.forward_port 80, 8082
    end
    config.vm.define :db do |db_config|
    db_config.vm.box = "db"
    db_config.vm.forward_port 3306, 3306
    end
    end

    View full-size slide

  18. Treat your infrastructure as
    code.
    * Programmable
    * Testable
    * Deployable

    View full-size slide

  19. Enable reconstruction of the
    business from nothing but
    * a source code repository,
    * application data backup,
    * and bare metal resources

    View full-size slide

  20. * veewee
    \_ basebox templating
    * sahara
    \_ sandbox mode (cli snaps)
    \_ vagrant sandbox on
    vagrant ssh
    * hack hack hack
    vagrant sandbox commit
    or
    vagrant sandbox rollback
    vagrant sandbox off
    * vagrant-vbguest
    \_ update base vbox extensions

    View full-size slide

  21. $ vagrant box add base \
    http://files.vagrantup.com/lucid32.box
    $ vagrant init
    $ vagrant up

    View full-size slide

  22. show me the money machines workflow ...

    View full-size slide