Vagrantfileでのhostmanagerの設定

VCCW3.xでVagrantfileを利用してvagrant-hostmanagerによる自動でIPアドレスとURLのひもづけを行うには 以下のような変更が必要です。

config.vm.network :public_network, type: 'dhcp', bridge: 'en1: Wi-Fi (AirPort)'

config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.ip_resolver = proc do |vm, resolving_vm|
    ip_address = ''
    if hostname = (vm.ssh_info && vm.ssh_info[:host])
      vm.communicate.execute("/sbin/ifconfig enp0s8 | grep 'inet addr' | tail -n 1 | egrep -o '[0-9\.]+' | head -n 1 2>&1") do |type, contents|
        ip_address = contents.split("\n").first
      end
    end
    ip_address
  end

  config.vm.synced_folder ".", "/vagrant", :mount_options => ['dmode=755', 'fmode=644']
  config.vm.synced_folder _conf['sync_folder'], _conf['document_root'], :create => "true", :mount_options => ['dmode=755', 'fmode=644']