diff --git a/lib/vagrant-hostmanager/hosts_file.rb b/lib/vagrant-hostmanager/hosts_file.rb index 582ba53..703e7db 100644 --- a/lib/vagrant-hostmanager/hosts_file.rb +++ b/lib/vagrant-hostmanager/hosts_file.rb @@ -80,7 +80,9 @@ module VagrantPlugins ip = get_ip_address(machine, resolving_machine) host = machine.config.vm.hostname || machine.name aliases = machine.config.hostmanager.aliases.join(' ').chomp - "#{ip}\t#{host} #{aliases}\n" + if ip != nil + "#{ip}\t#{host} #{aliases}\n" + end end def get_ip_address(machine, resolving_machine) diff --git a/test/Vagrantfile b/test/Vagrantfile index 24683e6..59ca656 100644 --- a/test/Vagrantfile +++ b/test/Vagrantfile @@ -33,4 +33,9 @@ Vagrant.configure('2') do |config| server.vm.network :private_network, :ip => '10.0.5.4' server.vm.provision :hostmanager end -end \ No newline at end of file + + config.vm.define :server4 do |server| + server.vm.hostname = 'scruffy' + server.vm.provision :hostmanager + end +end