vagrant-hostmanager icon indicating copy to clipboard operation
vagrant-hostmanager copied to clipboard

[Help Wanted] Possible to add a list of hostnames and IPs?

Open optimizer404 opened this issue 8 years ago • 6 comments

Is it possible to add a list of hostnames and IPs to my vagrant box / hostsync with vagrant-hostmanager?

Eg. config.hostmanager.add_host '10.0.2.3', ['myotherhost.vagrantup.internal', 'myotherhost'] config.hostmanager.add_host '10.0.2.4', ['mysecondhost.vagrantup.internal', 'mysecondhost']

optimizer404 avatar Jan 10 '17 13:01 optimizer404

the attached commit allows to use:

config.hostmanager.extra_hosts  = [
      [
          '192.168.42.41', [
              'external-box.localdomain',
              'subdomain.external-box.localdomain',
          ]
      ],
  ]

To define external hosts entries within the vagrant-hostmanager plugin

javier-lopez avatar Dec 05 '17 23:12 javier-lopez

I'm very interested in this feature. I would like to test it and give you feedback. How can I install your version? Is there a command to install your version of the plugin?

utrotzek avatar Dec 27 '17 09:12 utrotzek

Hello @utrotzek , I can think of two approaches to install the plugin:

  1. Download/Compile/Install locally, based on https://github.com/hashicorp/vagrant/issues/1829#issuecomment-19394678

$ git clone https://github.com/javier-lopez/vagrant-hostmanager && cd vagrant-hostmanager $ rake build $ vagrant plugin install pkg/vagrant-hostmanager

  1. Download the upstream code and copy the modified files, https://github.com/devopsgroup-io/vagrant-hostmanager/pull/248/files

javier-lopez avatar Dec 28 '17 00:12 javier-lopez

@javier-lopez This patch is working for me. Would it be possible to get rid of the outer array structure?

config.hostmanager.extra_hosts = [ '172.28.128.100', ['db.dev']]

instead of

config.hostmanager.extra_hosts = [[ '172.28.128.100', ['db.dev']]]

foozmeat avatar Jan 04 '18 17:01 foozmeat

@foozmeat done, I've also uploaded the modified version to https://rubygems.org/gems/vagrant-hostmanager-ext while (if) the changes get merged.

To test it run:

vagrant plugin uninstall vagrant-hostmanager
vagrant plugin install   vagrant-hostmanager-ext

javier-lopez avatar Jan 23 '18 21:01 javier-lopez

@javier-lopez sorry for the late response. Thanks for the hint and uploading to rubygems.

Unfortunately I get the following error message when running vagrant hostmanager

Vagrant failed to initialize at a very early stage:

The plugins failed to load properly. The error message given is shown below.

cannot load such file -- vagrant-hostmanager-ext

With the original plugin hostmanager v1.8.7 everything works fine.

I installed it using

vagrant plugin uninstall vagrant-hostmanager vagrant plugin install vagrant-hostmanager-ext

Do you have an idea what could be wrong? I have vagrant v1.9.2 installed.

utrotzek avatar Jan 24 '18 07:01 utrotzek