From 0b3e60cb5db2789885dfdb5b7eb9d09cfa1b4b82 Mon Sep 17 00:00:00 2001 From: Jan Vansteenkiste Date: Mon, 6 May 2013 08:31:31 +0200 Subject: [PATCH] Added new include_offline configuration item --- README.md | 5 +++++ lib/vagrant-hostmanager/config.rb | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 16ae137..0f11188 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,10 @@ 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. +When using include_offline set to true, only boxes that are up or have a +private ip configured will be added to the hosts file. You will receive a +warning on skipped boxes. + In addition, the `hostmanager.aliases` configuration attribute can be used to provide aliases for your host names. @@ -49,6 +53,7 @@ Example configuration: Vagrant.configure("2") do |config| config.hostmanager.enabled = true config.hostmanager.ignore_private_ip = false + config.hostmanager.include_offline = true config.vm.define "example-box" do |node| node.vm.hostname = "example-box-hostname" node.vm.network :private_network, ip: "192.168.42.42" diff --git a/lib/vagrant-hostmanager/config.rb b/lib/vagrant-hostmanager/config.rb index 20be3c8..5244db3 100644 --- a/lib/vagrant-hostmanager/config.rb +++ b/lib/vagrant-hostmanager/config.rb @@ -4,13 +4,16 @@ module VagrantPlugins attr_accessor :enabled attr_accessor :ignore_private_ip attr_accessor :aliases + attr_accessor :include_offline alias_method :enabled?, :enabled + alias_method :include_offline?, :include_offline def initialize @enabled = false @ignore_private_ip = UNSET_VALUE @aliases = Array.new + @include_offline = false end def finalize! @@ -24,6 +27,9 @@ module VagrantPlugins # check if enabled option is either true or false errors << validate_bool('hostmanager.enabled', enabled) + # check if include_offline is either true or false + errors << validate_bool('hostmanager.include_offline', include_offline) + # check if ignore_private_ip option is either true or false (or UNSET_VALUE) if @ignore_private_ip != UNSET_VALUE errors << validate_bool('hostmanager.ignore_private_ip', ignore_private_ip)