theforeman / puppet-foreman_proxy

Puppet module for Foreman Smart Proxy
GNU General Public License v3.0
43 stars 130 forks source link

dns_interface defaults to eth0, which may not be always present #143

Closed cristifalcas closed 8 years ago

cristifalcas commented 9 years ago

I think it would be saner to use the default gateway instead of eth0. Currently I'm using those facts to set the default interface to an existing value:

https://github.com/kwilczynski/facter-facts/blob/master/default_gateway.rb

Maybe they could be added to foreman and default the interface to $::default_gateway_interface?

domcleal commented 9 years ago

Yeah, I'd prefer that. I understand the argument against a "default gateway" fact, but for us it's a sane default. Ideally we'd find a Forge module that provides it to save us directly maintaining it - I don't suppose that one's available somewhere that I can't see?

cristifalcas commented 9 years ago

I couldn't find any module providing this. There is the fact linked above.

Also this from coreos, which seems reasonable and has the response from ip command directly:

ip route get 8.8.8.8 2>/dev/null | awk '{print  $3,$5,$7}';

Explanation from upstream (http://linux-ip.net/html/tools-ip-route.html):

By simulating a request for the specified destination, ip route get causes the routing selection algorithm to be run. When this is complete, it prints out the resulting path to the destination. In one sense, this is almost equivalent to sending an ICMP echo request packet and then using ip route show cache.

ekohl commented 9 years ago

I think that's too complex. We're trying to determine the interface where to listen and I think there are a few cases in network which I'll describe. It's also important to remember it's only to build the initial DNS zone.

In the case of the new naming scheme (enp4s0 for example) it's sufficient to parse $::interfaces and take the first value that's not lo.

When there are multiple interfaces, I don't think we can reasonably assume any interface. There may be the case of an internal one without a default gateway, but what do you do when there are multiple gateways specified? IMHO we shouldn't guess here. Possibly fall back to $::ipaddress?

cristifalcas commented 9 years ago

I think that if you parse $::interfaces, in case of a docker machine the first interface will be docker0. Which is not what most people want. Actually we had this problem on our network and realized that we don't want to maintain an array of "ignored interfaces", so we switch to the "default interface".

Disclaimer: I know that openstack compute or docker node is not where a puppet master is installed usually.

ekohl commented 9 years ago

I agree parsing is nasty, but it is only for the IP where the server should be reachable. In case of docker (and possibly openstack compute) this can be wrong because of IP forwarding. I'd rather try to minimize this and maybe make it an explicit ip instead of interface.

How many users are setting up an authoritative nameserver as part of foreman anyway? Do we have any numbers on that?

cristifalcas commented 9 years ago

Regarding this issue, a facter with the result from ip route get 8.8.8.8 2>/dev/null | awk '{print $3,$5,$7}' will be accepted?

Or should I close this?

mmoll commented 8 years ago

I'd prefer to close this, as there's no default fact coming with facter that's usable and e.g. the custom fact proposed won't work on FreeBSD.