bloomberg/chef-bcpc — pull request #212 by dspadea (2014-07-17 20:08:37+00:00)
Title: Immediately update /etc/resolv.conf to match float interface file

Chef updates /etc/network/interfaces.d/iface-{float interface} with the "dns_servers" from the environment file. However, this does not get propagated to /etc/resolv.conf until:

1. Reboot
2. ifdown/ifup

Both of these are disruptive to service. 'service networking restart' does not interrupt services, but it does not make these changes effective, either.

The only non-disruptive way I found to update this without severing connections or rebooting the machine is to feed the values into resolvconf -a. This will put the changes into effect via roughly the same mechanism that would normally be used, ensuring that the system is configured properly and should not produce any surprises after a reboot. I think this is preferable to modifying /etc/resolv.conf directly.

This change adds a bash block which egreps out the proper lines from the floating interface file and feeds them to resolv.conf after the interface file is updated.

This was tested successfully in a VM environment. The interface names are different in a VM environment, but I'm using the node[] value, so it should work consistently.