chrekh / puppet-hosts

A template-based module to manage /etc/hosts
5 stars 8 forks source link

Include/Exclude interfaces #15

Closed mrsdevo closed 3 years ago

mrsdevo commented 3 years ago

Currently, all interfaces get added in the hostfile. For example, if I installed docker, that would add this new interface in /etc/hosts file which is not really necessary.

Another example, when we install DELL iDRAC on physical servers, it add this interface to hostfile causing issues.

Is there a way to exclude/include certain entries?

chrekh commented 3 years ago

No, that is currently not possible

The module works by using ruby code in a custom fact to find all IP-adresses configured and use the list of local IP-adresses in the template for /etc/hosts.

I don't think it's possible to access hieradata or class parameters from the ruby-code in the custom fact, so a list of interfaces to include or exclude isn't possible.

What might be bossible to have a list of IP-addresses to include or exclude as a class-parameter. I'll investigate that when I get some time.

The reason for using ruby-code to list IP-addresses was that the (legacy) fact ipaddress couldn't list all ip-adresses or distinguish it's kind (loopback, multicast, linklocal) I have some loose plans to rewrite it using modern structured facts. That could possibly make a exclude/include list possible.

If you figure out a way to achive this, I'm happy to take a PR.

mrsdevo commented 3 years ago

Thanks Chrekh for considering this scenario. If we are able to include only certain IP ranges(with wildcards - 10.x.x.x), this could work as an optional feature.

chrekh commented 3 years ago

I have released version 3.2.0 With added ability to filter the lists of addresses with lists of regexps.

mrsdevo commented 3 years ago

Works great. Thanks Chrekh :smiley:

chrekh commented 2 years ago

In the latest version (4.0.0) it's now also possible to include/exclude addresses by interfaces.