vagrant-hostmanager 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -21,17 +21,17 @@ Install the plugin following the typical Vagrant 1.1 procedure:
21
21
 
22
22
  Usage
23
23
  -----
24
- The plugin hooks into the `vagrant up` and `vagrant destroy` commands
25
- automatically. When a machine is created or destroyed, all active
26
- machines with the same provider will have their `/etc/hosts` file updated
27
- accordingly. Auto update may be disabled by setting the
28
- `config.hostmanager.auto_update` attribute to false in the Vagrantfile.
29
-
30
- To update the `/etc/hosts` file on each active machine manually, run the
31
- following command:
24
+ To update the `/etc/hosts` file on each active machine, run the following
25
+ command:
32
26
 
33
27
  $ vagrant hostmanager
34
28
 
29
+ The plugin may hook into the `vagrant up` and `vagrant destroy` commands
30
+ automatically. When a machine is created or destroyed, all active
31
+ machines with the same provider will have their `/etc/hosts` file updated
32
+ accordingly. Set the `hostmanager.enabled` attribute to `true` in the
33
+ Vagrantfile to activate this behavior.
34
+
35
35
  A machine's IP address is defined by either the static IP for a private
36
36
  network configuration or by the SSH host configuration. To disable
37
37
  using the private network IP address, set `config.hostmanger.ignore_private_ip`
@@ -47,7 +47,7 @@ Example configuration:
47
47
 
48
48
  ```ruby
49
49
  Vagrant.configure("2") do |config|
50
- config.hostmanager.auto_update = true
50
+ config.hostmanager.enabled = true
51
51
  config.hostmanager.ignore_private_ip = false
52
52
  config.vm.define "example-box" do |node|
53
53
  node.vm.hostname = "example-box-hostname"
@@ -17,7 +17,7 @@ module VagrantPlugins
17
17
  return @app.call(env) if @machine.id
18
18
 
19
19
  # check config to see if the hosts file should be update automatically
20
- return @app.call(env) if !@machine.config.hostmanager.auto_update
20
+ return @app.call(env) unless @machine.config.hostmanager.enabled?
21
21
  @logger.info 'Updating /etc/hosts file automatically'
22
22
 
23
23
  # continue the action stack so the machine will be created
@@ -1,31 +1,33 @@
1
1
  module VagrantPlugins
2
2
  module HostManager
3
3
  class Config < Vagrant.plugin('2', :config)
4
- attr_accessor :auto_update
4
+ attr_accessor :enabled
5
5
  attr_accessor :ignore_private_ip
6
6
  attr_accessor :aliases
7
7
 
8
+ alias_method :enabled?, :enabled
9
+
8
10
  def initialize
9
- @auto_update = UNSET_VALUE
11
+ @enabled = false
10
12
  @ignore_private_ip = UNSET_VALUE
11
- @aliases = Array.new
13
+ @aliases = Array.new
12
14
  end
13
15
 
14
16
  def finalize!
15
- @auto_update = true if @auto_update == UNSET_VALUE
16
17
  @ignore_private_ip = false if @ignore_private_ip == UNSET_VALUE
17
18
  end
18
19
 
19
20
  def validate(machine)
20
21
  errors = Array.new
21
22
 
22
- # check if auto_update option is either true or false
23
- if ![TrueClass, FalseClass].include?(auto_update.class)
24
- errors << "A value for hostmanager.auto_update can be true or false."
23
+ # check if enabled option is either true or false
24
+ if ![TrueClass, FalseClass].include?(enabled.class)
25
+ errors << "A value for hostmanager.enabled can be true or false."
25
26
  end
26
27
 
27
28
  # check if ignore_private_ip option is either true or false
28
- if ![TrueClass, FalseClass].include?(ignore_private_ip.class)
29
+ if ![TrueClass, FalseClass].include?(ignore_private_ip.class) &&
30
+ @ignore_private_ip != UNSET_VALUE
29
31
  errors << "A value for hostmanager.ignore_private_ip can be true or false."
30
32
  end
31
33
 
@@ -33,7 +35,7 @@ module VagrantPlugins
33
35
  if !machine.config.hostmanager.aliases.kind_of?(Array)
34
36
  errors << "A value for hostmanager.aliases must be an Array."
35
37
  end
36
-
38
+
37
39
  { "HostManager configuration" => errors }
38
40
  end
39
41
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module HostManager
3
- VERSION = '0.1.2'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
@@ -7,7 +7,7 @@ Vagrant.configure('2') do |config|
7
7
  config.vm.box = 'precise64-chef11.2'
8
8
  config.vm.box_url = 'https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_chef-11.2.0.box'
9
9
 
10
- config.hostmanager.auto_update = true
10
+ config.hostmanager.enabled = true
11
11
 
12
12
  config.vm.define :server1 do |server|
13
13
  server.vm.hostname = 'fry'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-hostmanager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-26 00:00:00.000000000 Z
12
+ date: 2013-04-27 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A Vagrant plugin that manages the /etc/hosts file within a multi-machine
15
15
  environment