vagrant-vmhosts 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,16 +1,39 @@
1
1
  Vagrant VM Hosts Plugin
2
2
  =======================
3
3
 
4
- This Vagrant plugin allows you to add entries to the hosts file of the VM. This is particularly useful in a multi-VM environment to get all machines to know each other by name.
4
+ 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.
5
+
6
+ **NOTE:** This is the first release, containing only a proof-of-concept implementation. Functionality/configuration is bound to change in the future.
5
7
 
6
8
  Installation
7
9
  ------------
8
10
 
11
+ 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:
12
+
9
13
  vagrant gem install vagrant-vmhosts
10
14
 
11
15
  Usage
12
16
  -----
13
17
 
18
+ To let Vagrant add entries to the `/etc/hosts` file on a VM, use the `config.vmhosts.list` directive:
19
+
20
+ ```ruby
21
+ Vagrant::Config.run do |config|
22
+ config.vmhosts.list = hosts
23
+ end
24
+ ```
25
+
26
+ This directive takes an array of hashes, containing the entries you want to add:
27
+
28
+ ```ruby
29
+ hosts = [
30
+ { "ip" => "172.16.0.2",
31
+ "canonical" => "puppet.example.com",
32
+ "aliases" => ["puppet"] }
33
+ ]
34
+ ```
35
+
36
+ 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.
14
37
 
15
38
  TODO
16
39
  ----
@@ -10,7 +10,7 @@ module VagrantVmHosts
10
10
  hosts = env[:vm].config.vmhosts.list
11
11
  env[:ui].info I18n.t("vagrant.plugins.vmhosts.adding")
12
12
  hosts.each do |host|
13
- if !env[:vm].channel.test("grep '^#{host['ip']}' /etc/hosts")
13
+ if !env[:vm].channel.test("grep '^#{host['ip']}[[:space:]]' /etc/hosts")
14
14
  env[:vm].channel.sudo("printf '%s\t%s %s\n' '#{host['ip']}' '#{host['canonical']}' '#{host['aliases'].join(' ')}' >> /etc/hosts")
15
15
  end
16
16
  end
@@ -1,5 +1,9 @@
1
1
  module VagrantVmHosts
2
2
  class Config < Vagrant::Config::Base
3
3
  attr_accessor :list
4
+
5
+ def validate(errors)
6
+ # check hash format
7
+ end
4
8
  end
5
9
  end
@@ -1,3 +1,3 @@
1
1
  module VagrantVmHosts
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-vmhosts
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kristof Willaert
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-05-22 00:00:00 +02:00
18
+ date: 2012-05-23 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency