devopsgroup-io / vagrant-hostmanager

:pencil: A Vagrant plugin that manages hosts files within a multi-machine environment.
Mozilla Public License 2.0
1.46k stars 146 forks source link

Prevent wiping of addresses of other providers #169

Open lomignet opened 9 years ago

lomignet commented 9 years ago

Hostmanager can only deal with one provider at a time.

If you vagrant up a virtualbox vm, then an aws, all information of your virtualbox vm will be removed from /etc/hosts on the host.

By adding the provider type in the header/footer of the hostmanager section of /etc/hosts, we can have one section per provider and thus keep all machines no matter the provider.

seth-reeser commented 8 years ago

This is only a partial solution - please expand.

lomignet commented 8 years ago

Hi,

Would you mind expanding on why this is only partial? :)

My understanding is that vagrant-hostmanager when updating a host file basically recreates its block from scratch every time. As Vagrant cannot manage more than one provider per run, this means that if I am dealing with a say virtualbox VM and hostmanager wipe outs all vagrant entries, there is no way to find again VMs backed up by another provider, AWS for instance.

My patch creates one block per provider, meaning that they all are independent and can be managed individually, fully recreated as required without impacting the other blocks.

Cheers,