用 Vagrant 的技巧

在「Ten Things I Wish I’d Known Before Using Vagrant」這邊作者整理了使用 Vagrant 的十個技巧,有些以前就知道,有些是每次遇到都要查一次,有些則是新發現的工具...

其中第四點提到的工具「vagrant-landrush/landrush」之前沒看過:

A Vagrant plugin that provides a simple DNS server for Vagrant guests

Landrush is a simple cross-platform DNS for Vagrant VMs that is visible on both, the guest and the host.

It spins up a small DNS server and redirects DNS traffic from your VMs to use it, automatically registering/unregistering IP addresses of guests as they come up and go down.

也可以從範例知道實際用途:

Vagrant.configure("2") do |config|
  config.vm.box = "hashicorp/precise64"

  config.landrush.enabled = true

  config.vm.hostname = "myhost.vagrant.test"

  config.landrush.host 'static1.example.com', '1.2.3.4'
  config.landrush.host 'static2.example.com', '2.3.4.5'
end

以前有遇到這樣的需求時都還傻傻的去寫 /etc/hosts... (也是會動啦,而且每一台都寫一樣的東西是還好,但有種很 workaround 的感覺 XD)

之後有遇到時用看看...

Leave a Reply

Your email address will not be published. Required fields are marked *