I’ve had some difficulties with hostsfile. Not that it’s a bad approach, but managing /etc/hosts by configuring individual entries gets very confusing , very quickly, if you have old entries that are not in your current cookbooks. And the “fqdn” cookbooks is particularly problematic with it, mishandling a number of optional attributes and putting the FQDN on the same line as the standard loopback address.
The result is that I’ve written a complete /etc/hosts deployment cookbook, able to use roles or environment attributes for complete /etc/hosts deployment, and would welcome any testing and code review. It’s at:
Lead DevOps Engineer