A Vagrant plugin for adding entries to the hosts file of the VM
Latest commit 5c90f2a May 24, 2012 @willaerk willaerk Bump version to 0.0.4.


Vagrant VM Hosts Plugin

This Vagrant plugin allows you to add entries to the hosts file of the VM. This is mostly useful in a multi-VM environment, where you might want the virtual machines to reach each other by name through the host-only interface. There are a few other solutions available, but these mostly require OS X, which I do not have.

NOTE: This is the first release, containing only a proof-of-concept implementation. Functionality/configuration is bound to change in the future.


This plugin has been tested on Vagrant 1.0, but will probably also work on somewhat older versions. The easiest way to install it, is through the vagrant gem command:

vagrant gem install vagrant-vmhosts


To let Vagrant add entries to the /etc/hosts file on a VM, use the config.vmhosts.list directive:

Vagrant::Config.run do |config|
  config.vmhosts.list = hosts

This directive takes an array of hashes, containing the entries you want to add:

hosts = [
          { "ip" => "",
            "canonical" => "puppet.example.com",
            "aliases" => ["puppet"] }

The plugin runs at the end of the boot sequence, before the provisioners. So you can use any hostname defined in the array while provisioning. For example, if you have a multi-VM setup with a puppetmaster VM and a VM with a puppet agent pointing to this master, you can use the host entry pointing to the puppetmaster.


  • command
  • unit tests
  • hosts format
  • validate config


Copyright (c) 2012 Cegeka NV


Vagrant-vmhosts is licensed under the Apache License, Version 2.0. See the LICENSE file for more details.