SUSE / caasp-salt

A collection of salt states used to provision a kubernetes cluster
Apache License 2.0
64 stars 29 forks source link

Sort nodenames first when generating /etc/hosts entries #728

Closed ereslibre closed 5 years ago

ereslibre commented 5 years ago

Salt will pick the first name on the current default interface to determine the hostname of the machine. Since we are sorting with all entries for each machine there's a high change that a salt minion id will win the first position, affecting certain grains that we use to determine the hostname of the node.

With this change we are not only sorting alphabetically by the name of each column in each entry, but also adding weight to each column on each entry. This means that the nodename will always win, as its primary weight will be lower than the rest, while the second sorting strategy is purely alphabetical.

Fixes: bsc#1117339

mssola commented 5 years ago

Could you add some tests to check that the resulting /etc/hosts entries are sorted as expected?

ereslibre commented 5 years ago

Tests added. @inercia PTAL when you can, thanks!

MalloZup commented 5 years ago

:rocket: