customink-webops/hostsfile — pull request #26 by satiani (2013-08-13 14:42:22+00:00)
Title: Better /etc/hosts flattening and bug fixes

This includes several improvements and bug fixes:

1. Some host files include separate lines for the same IP with different hosts, I added functionality to flatten the host file by merging these lines into one line with a list of aliases.

2. The method "remove_existing_hostnames" makes some false assumptions, so I removed it:
* It says: "it doesn't make sense to allow multiple IPs to have the same host name or aliases". AFAIK, this is not true, since you can have the same host with multiple network interfaces (different IPs) and you can also have an IPv4 and IPv6 addresses for the same host. For example, vanilla Debian 7 installation includes these two lines in the /etc/hosts: `127.0.0.1 localhost` and `::1 localhost ip6-localhost ip6-loopback` out of the box. Currently this chef recipe causes one of these lines to be removed, breaking the loopback interface.
* It assumes that the `changed_entry` is always the first item in the `@entries` instance variable. This is only true when `add(entry)` is invoked, and is not true for `append(entry)` and `update(entry)`.