Updating host's /etc/hosts with 127.0.0.1 using the hostsupdater plugin?

88 views
Skip to first unread message

Andrew Leer

unread,
Jan 25, 2017, 4:39:59 PM1/25/17
to Vagrant
I read here and here that the vagrant hostsupdater plugin is supposed to update the host's /etc/hosts (or just hosts file as the case may be); I have a need to do this with forwarded ports instead of a private network, so, is that possible, or does my end-user (another developer) have to edit the hosts file themselves when setting up the dev environment?


Vagrant.configure("2") do |config| # ... # Forward guest port 80 to host port 8888 and name mapping config.vm.network :forwarded_port, guest: 80, host: 8888 config.vm.network :forwarded_port, guest: 443, host: 8443 # REMEMBER TO ADD THIS TO THE HOST's /etc/hosts as the loopback (127.0.0.1, or [::1]) config.vm.hostname = "dot.org" config.hostsupdater.aliases = ["www.dot.org"] # ... end

At the moment if I add the following manually, I can access the forwarded ports as expected but the hostsupdater plugin
doesn't do it automatically:

127.0.0.1 dot.org # VAGRANT ... 127.0.0.1 www.dot.org # VAGRANT ...

Is it possible to use the hostsupdater plugin or something else to add these lines automatically to /etc/hosts on vagrant up,
and remove them on vagrant destroy?

Thank you,
Andrew J. Leer

Alvaro Miranda Aguilera

unread,
Jan 26, 2017, 2:51:10 AM1/26/17
to vagra...@googlegroups.com

On Wed, Jan 25, 2017 at 10:39 PM, Andrew Leer <leea...@gmail.com> wrote:
# REMEMBER TO ADD THIS TO THE HOST's /etc/hosts as the loopback (127.0.0.1, or [::1]) config.vm.hostname = "dot.org" config.hostsupdater.aliases = ["www.dot.org"]

Hello

it seems the plugin requires these 2 options:

You currently only need the hostname and a :private_network network with a fixed IP address.

each developer can have the same private_network ip, and shoudln't be an issue

whats the reason you can't do that ?


--
Alvaro

Andrew Leer

unread,
Jan 26, 2017, 12:19:25 PM1/26/17
to Vagrant
I can do that...
Reply all
Reply to author
Forward
0 new messages