saltstack-formulas / hostsfile-formula

Use minion IDs to keep /etc/hosts and hostnames consistent for clusters without DNS
http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
33 stars 89 forks source link

trim back hostnames for IPs to only those given in pillar[hostsfile:only] #25

Closed 0xf10e closed 6 years ago

0xf10e commented 6 years ago

AFAICT there is no way to remove IPs from the hostsfile in this formula yet. And also none to trim back superfluous hostnames for a given IP.

By using the hosts.only state we can both remove IPs from the hostsfile and reduce the hostnames for a given IP to the ones listed in pillar[hostsfile:only].

An example:

hostsfile:
    hosts:
        my.host.my.domain: 192.0.2.45
    only:
        127.0.0.1: localhost
        127.0.1.1: []

Oh, and you also can set multiple hostnames for an IP properly (something I wanted since #12). So no { myhostname: 192.0.2.17, myhostname.localdomain: 192.0.2.17 } silliness to add to your pillar.

If someone can come up with a better pillar key than hostfile:only I'm all for it.