You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure if this is intentional or not but the hostname of the guest end up duplicated in /etc/hosts. See the Vagrantfile and the resulting /etc/hosts below. Notice how vm.local is present in both the 127.0.0.1 and 192.168.200.100 line. I was expecting/hoping that vm.local and vm would be removed from 127.0.0.1 and both would end up on 192.168.200.100. I do understand that I could add an alias to get vm on 192.168.200.100.
A potential suggestion could be to add a config option like config.hostmanager.manage_guest_localhost = true
This would result in the 127.0.0.1 line being "cleansed" of values from config.vm.hostname.
For now I added a shell provisioner that does this sed -i 's/\(127\.0\.0\.1\)\s*.*\s*\(localhost\)\s/\1\t\2 /' /etc/hosts
Perhaps there is a better way I should be doing this.
Hi @kminder, the 127.0.0.1 ... line in the hosts file is changed by vagrant itself when it configures the guest's hostname. vagrant-hostmanager only touches the lines that it adds.
Cleaning the 127.0.0.1 line could be done, as you suggested, but at a first glance it looks to me like this is a very specific case of a more general issue.
At the moment, there are two guests OS types where vagrant updates /etc/hosts in a similar way: Redhat/Centos and Debian/Ubuntu. In the Debian case, it actually adds a 127.0.1.1 line - I'm not exactly sure why. I think if we were to edit only the 127.0.0.1 line, we would still have this issue in Debian/Ubuntu guests.
It seems to me that in general we would want hostmanager to remove any names in /etc/hosts that conflict with the ones it is to add.
I think this would involve some parsing etc/hosts to find these entries, and for each one, take out the conflicting names in that line while leaving the rest of the entry if there are other names, (skipping comment lines and so on).
What do you think?
Is this something you would be interested in contributing?
I'm not sure if this is intentional or not but the hostname of the guest end up duplicated in /etc/hosts. See the Vagrantfile and the resulting /etc/hosts below. Notice how vm.local is present in both the 127.0.0.1 and 192.168.200.100 line. I was expecting/hoping that vm.local and vm would be removed from 127.0.0.1 and both would end up on 192.168.200.100. I do understand that I could add an alias to get vm on 192.168.200.100.
A potential suggestion could be to add a config option like
config.hostmanager.manage_guest_localhost = true
This would result in the 127.0.0.1 line being "cleansed" of values from config.vm.hostname.
For now I added a shell provisioner that does this
sed -i 's/\(127\.0\.0\.1\)\s*.*\s*\(localhost\)\s/\1\t\2 /' /etc/hosts
Perhaps there is a better way I should be doing this.
These are my versions.
This is my Vagrantfile.
This is the resulting /etc/hosts on my guest vm.
The text was updated successfully, but these errors were encountered: