Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

up vote 0 down vote accepted

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

share|improve this answer

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.

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.