vagrant-landrush / landrush

A Vagrant plugin that provides a simple DNS server for Vagrant guests
MIT License
666 stars 78 forks source link

config.vm.define <hostname> is not honoured #307

Open JPvRiel opened 7 years ago

JPvRiel commented 7 years ago

In a Vagrantfile config, the Vagrant hostnames given by config.vm.define are ignored and landrush tries to rename the host to the same thing for each instance. Instead, it's using the current folder's name?

E.g. I get:

$ vagrant up --provider=libvirt
...
==> h1: Creating image (snapshot of base box volume).
==> h2: Creating image (snapshot of base box volume).
...
==> h1: [landrush] adding machine entry: dev-cluster.vagrant.test => 192.168.121.20
==> h2: [landrush] adding machine entry: dev-cluster.vagrant.test => 192.168.121.133

Using a config like

Vagrant.configure(2) do |config|

  config.vm.provider :libvirt do |domain, override|
    override.vm.box = 'centos/7'
  end

  config.landrush.enabled = true
  config.landrush.tld = 'vagrant.test'
  config.landrush.guest_redirect_dns = false
  config.landrush.host_redirect_dns = false

  config.vm.define 'h1'
  config.vm.define 'h2'

end

I'd expect h1.vagrant.test and h2.vagrant.test, not dev-cluster.vagrant.test

JPvRiel commented 7 years ago

A workaround is to explicitly set the hostname.

E.g. untested example code

  hosts = ['h1', 'h2']
  hosts.each do |h|
    config.vm.define "#{h}" do | d |
       d.vm.hostname = "#{h}.#{config.landrush.tld}"
    end
  end

Obviously, that's less concise... but it helps landrush work.