Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Vagrant Virtual Development Environment Cookbook

You're reading from   Vagrant Virtual Development Environment Cookbook 35 solutions to help you utilize virtualization with Vagrant more effectively – learn how to develop and manage Vagrant in the cloud to improve collaboration

Arrow left icon
Product type Paperback
Published in Feb 2015
Publisher
ISBN-13 9781784393748
Length 250 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Chad O Thompson Chad O Thompson
Author Profile Icon Chad O Thompson
Chad O Thompson
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Vagrant Virtual Development Environment Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Setting Up Your Environment FREE CHAPTER 2. Single Machine Environments 3. Provisioning a Vagrant Environment 4. Provisioning with Configuration Management Tools 5. Networked Vagrant Environments 6. Vagrant in the Cloud 7. Packaging Vagrant Boxes Vagrant Plugins A Puppet Development Environment Using Docker with Vagrant Index

Appendix A. Vagrant Plugins

Vagrant itself has a highly extensible architecture that can be utilized to provide additional functionality. Vagrant extensions are written using Vagrant's plugin framework. Vagrant plugins are typically written to extend Vagrant by:

  • Creating new providers that can execute commands and configure resources within the guest operating systems

  • Adding or modifying resources on guest operating systems

  • Adding or modifying resources on the host operating system

Plugins can also create new commands that can be executed within the Vagrant executable.

Vagrant plugins are written in the language of Vagrant itself: the Ruby programming language. Writing Vagrant plugins utilizes a framework to get started, but will be rather difficult unless you have a basic grasp of the Ruby programming language. This appendix will create and explain a simple example of a custom provider, one that allows us to add a new provisioner block to say hello to the provisioner. In the end, this block of code can be added to our Vagrantfile:

  config.vm.provision :hello do |hello|
    hello.inline = 'Chad!'
  end

This will produce the output on provisioning:

==> default: Running provisioner: hello...
[stdout] Hello Chad!!

Extending Vagrant in this way can be useful to publish extensions to Vagrant itself. Users might want to take care in creating new plugins rather than using existing provisioners for a few reasons:

  • Provisioning operations are typically best done using existing provisioners. Ruby code written to support provisioning operations will not be typically portable in the way that provisioning code written using portable provisioning tools, such as Chef, Puppet, shell scripts, and so on.

  • Vagrant plugins require additional complexity for end users to manage. A written Vagrantfile that requires a plugin also requires users to install plugins before the Vagrantfile itself is usable.

  • When using Vagrant plugins, one must also take care to use Ruby features that are available in the Ruby runtime provided in Vagrant packages. There are ways of specifying these versions and failing the plugin, but care in compatibility is something that must be kept in mind. Developers should also note that the current versions of Vagrant are no longer distributed as RubyGems, so dependencies between Vagrant and Vagrant plugins (which are distributed as RubyGems) are implicit rather than explicitly defined in Gemfiles.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images