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 148 forks source link

FR: Option to append host aliases on a single line instead of every alias in its own line #294

Open danowar2k opened 4 months ago

danowar2k commented 4 months ago

I'm not sure if the current method can lead to bad behaviour.

Currently, using the aliases option...

Vagrantfile:

vm_config.vm.hostname = some-hostname
vm_config.hostmanager.aliases = %W(some-hostname.some-domain some-other-alias)

leads to the following lines (concrete IP not important):

1.2.3.4 some-hostname
1.2.3.4 some-hostname.some-domain
1.2.3.4 some-other-alias

I don't know if the resolving process will get problems with this, but I've heard that the stuff should be on the same line for an IP. Like this:

1.2.3.4 some-hostname some-hostname.some-domain some-other-alias

How about at least an option with which to select which way will be used?

danowar2k commented 4 months ago

It looks like if the option is defined, it would only be need to be used here: https://github.com/devopsgroup-io/vagrant-hostmanager/blob/fe00b37532057ac494c59fb306acb6f760ea6de1/lib/vagrant-hostmanager/hosts_file/updater.rb#L104

To decide whether to do newlines for each alias or not (and whether to prefix the entry with IP, okay, it's a little more complex to build the string)