Go to file
Brian Johnson 67644a6de0 Add management of hostsfile on the host machine. 2013-06-13 13:48:19 -07:00
lib Add management of hostsfile on the host machine. 2013-06-13 13:48:19 -07:00
locales Implement check for already active machine. 2013-04-08 13:20:22 -04:00
test Fix config validation. 2013-04-27 08:13:26 -04:00
.gitignore Proof-of-concept support for managing /etc/hosts. 2013-03-27 15:38:08 -04:00
Gemfile update vagrant dependency to 1.2.1 2013-04-26 10:24:01 -04:00
LICENSE.txt Proof-of-concept support for managing /etc/hosts. 2013-03-27 15:38:08 -04:00
README.md Fix config validation. 2013-04-27 08:13:26 -04:00
Rakefile Cleaned up project structure for running tests. 2013-03-27 16:13:22 -04:00
vagrant-hostmanager.gemspec Proof-of-concept support for managing /etc/hosts. 2013-03-27 15:38:08 -04:00

README.md

Vagrant Host Manager

vagrant-hostmanager is a Vagrant 1.1+ plugin that manages the /etc/hosts file on guest machines. Its goal is to enable resolution of multi-machine environments deployed with a cloud provider where IP addresses are not known in advance.

Status

The current implementation is a proof-of-concept supporting the larger objective of using Vagrant as a cloud management interface for development and production environments.

The plugin has been tested with Vagrant 1.1.5.

Installation

Install the plugin following the typical Vagrant 1.1 procedure:

$ vagrant plugin install vagrant-hostmanager

Usage

To update the /etc/hosts file on each active machine, run the following command:

$ vagrant hostmanager

The plugin may hook into the vagrant up and vagrant destroy commands automatically. When a machine is created or destroyed, all active machines with the same provider will have their /etc/hosts file updated accordingly. Set the hostmanager.enabled attribute to true in the Vagrantfile to activate this behavior.

A machine's IP address is defined by either the static IP for a private network configuration or by the SSH host configuration. To disable using the private network IP address, set config.hostmanger.ignore_private_ip to true.

A machine's host name is defined by config.vm.hostname. If this is not set, it falls back to the symbol defining the machine in the Vagrantfile.

In addition, the hostmanager.aliases configuration attribute can be used to provide aliases for your host names.

Example configuration:

Vagrant.configure("2") do |config|
  config.hostmanager.enabled = true
  config.hostmanager.ignore_private_ip = false
  config.vm.define "example-box" do |node|
    node.vm.hostname = "example-box-hostname"
    node.vm.network :private_network, ip: "192.168.42.42"
    node.hostmanager.aliases = %w(example-box.localdomain example-box-alias)
  end
end

Contribute

Contributions are welcome.

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request