module Vagrant::Util::GuestHosts::Linux

Linux specific inspection helpers

Public Instance Methods

replace_host(comm, name, ip) click to toggle source

Remove any line in /etc/hosts that contains hostname, then add hostname with associated ip

@param [Communicator] @param [String] full hostanme @param [String] target ip

# File lib/vagrant/util/guest_hosts.rb, line 40
        def replace_host(comm, name, ip)
          basename = name.split(".", 2)[0]
          comm.sudo <<-EOH.gsub(/^ {14}/, '')
          sed -i '/#{name}/d' /etc/hosts
          sed -i'' '1i '#{ip}'\\t#{name}\\t#{basename}' /etc/hosts
          EOH
        end