devopsgroup-io / vagrant-hostmanager

:pencil: A Vagrant plugin that manages hosts files within a multi-machine environment.
Mozilla Public License 2.0
1.46k stars 148 forks source link

How do you configure multiple VMs in one Vagrantfile with different hostnames? #247

Closed denizdogan closed 6 years ago

denizdogan commented 6 years ago

I use Vagrant 2.0.1 and VirtualBox 5.1.30 on macOS High Sierra 10.13.2 Developer Beta.

I have configured two VMs in the same Vagrantfile, one for a local VirtualBox-based VM and one for Google Compute Engine using vagrant-google.

I've booted both machines (local and cloud) using vagrant up but /etc/hosts only contains:

## vagrant-hostmanager-start id: 4679d3ea-9912-464c-b433-bccb62e8fb8f
10.11.12.13     local.project-generator.test

## vagrant-hostmanager-end

This is the relevant part of my Vagrantfile:

# vagrant-hostmanager
config.hostmanager.enabled = true
config.hostmanager.manage_host = true

# local centos VM
config.vm.define "local", primary: true do |node|
  node.vm.box = "bento/centos-7.4"
  node.vm.network "private_network", ip: "10.11.12.13"
  node.vm.hostname = "local.project-generator.test"
end

# compute engine VM
config.vm.define "prod", autostart: false do |node|
  node.vm.box = "google/gce"
  node.vm.hostname = "prod.project-generator.test"
  node.vm.provider "google" do |provisioner, override| ... end
end

What am I doing wrong?

denizdogan commented 6 years ago

No longer relevant to me, closing