4

I currently utilize Vagrant and Chef to provision individual linux VMs for different apps.

These apps are domain addressable from host, without requiring anything else set up on the host. This is achieved using avahi on the linux guest. Host then accesses via guest's hostname, such as:

myguest1.local -> VM#1
myguest2.local -> VM#2

I now have another app about to install, which to replicate the production server, should have 2 Apache virtual hosts addressable within the one VM, such as:

myguest3.local    
               -> VM#3
myguest4.local    

Can I also achieve this completely with Vagrant/Chef, without needing any modification to the host machine?

3 Answers 3

0

You can announce the alias via the Avahi API with Avahi.EntryGroup.AddRecord: python example.

A detailed solution for using the script is provided on SO

1

There is a Vagrant plugin for that : vagrant-hostsupdater

Extract from the github page :

This plugin adds an entry to your /etc/hosts file on the host system.
On up, resume and reload commands, it tries to add the information, if its not already existant in your hosts file. If it needs to be added, you will be asked for an administrator password, since it uses sudo to edit the file.

On halt and destroy, those entries will be removed again.

There is also vagrant-hostmanager, which supports Windows machines. I have not use it, so any feedback is welcome.

Extract from it's github page :

vagrant-hostmanager is a Vagrant 1.1+ plugin that manages the /etc/hosts file on guest machines (and optionally the host). Its goal is to enable resolution of multi-machine environments deployed with a cloud provider where IP addresses are not known in advance.

So it seems that both plugins automate the process of adding entries to /etc/hosts

0

It'll certainly work, but you will need to manually set entries for the virtual hosts in your hosts' /etc/hosts file. That should be the only step required on the host machine.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .