具有多个可寻址的domain.locals的stream浪单箱

我目前利用Vagrant和Chef为不同的应用程序configuration单独的linux虚拟机。

这些应用程序可以从主机进行域寻址,而不需要在主机上设置其他任何东西。 这是使用linux客户端上的avahi实现的。 主机然后通过访客的主机名访问,例如:

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

我现在有另一个应用程序即将安装,复制生产服务器,应该有一个虚拟机内的2个Apache虚拟主机寻址,如:

 myguest3.local -> VM#3 myguest4.local 

我也可以用Vagrant / Chef完全做到这一点,而不需要对主机进行任何修改?

您可以通过Avahi API与Avahi.EntryGroup.AddRecord: python示例通知别名。

在SO上提供了使用该脚本的详细解决scheme

这肯定会起作用,但是您需要手动为主机的/ etc / hosts文件中的虚拟主机设置条目。 这应该是主机上唯一需要的步骤。

有一个stream浪汉插件: vagrant-hostsupdater

从github页面提取:

 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. 

还有vagrant-hostmanager ,它支持Windows机器。 我没有使用它,所以任何反馈是值得欢迎的。

从它的github页面中提取:

 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. 

所以看起来,这两个插件自动将条目添加到/etc/hosts