3ofcoins / chef-cookbook-hostname

Chef cookbook to set node's hostname and FQDN.
MIT License
41 stars 90 forks source link

Set unique hosts file entry for hostname #43

Closed joelmoss closed 9 years ago

joelmoss commented 9 years ago

So in https://github.com/3ofcoins/chef-cookbook-hostname/blob/develop/recipes/default.rb#L106-L112 the hosts file entry is created for the hostname, however the unique parameter is not specified, so if the IP of the host has changed, a duplicate entry will be added for the hostname, resulting in all sorts of nasty funkiness.

This PR adds the unique param.

joelmoss commented 9 years ago

Also, as an aside, why is the hostname added to the hosts file?

flaccid commented 9 years ago

https://github.com/xhost-cookbooks/system/issues/17 is slightly related although that edge case was for localhost. I currently don't set unique on the fqdn hostfile entry with the system cookbook so I assume it would suffer from the same fail in this use case?

joelmoss commented 9 years ago

Yeah, I don't think this is related, as it is not localhost in use here. But if you don't specify it as unique, this is still broken. Any alternative solutions?

flaccid commented 9 years ago

@joelmoss happy to field a PR from you with the system cookbook (https://github.com/xhost-cookbooks/system).

joelmoss commented 9 years ago

Why would I do that? This cookbook does not use the system cookbook.

flaccid commented 9 years ago

@joelmoss because you asked for an alternative solution. Sorry if my context scope was too wide there sir.

joelmoss commented 9 years ago

Sorry, still confoozed :(

I don't want to use the system cookbook, as it does a more than I need/want. But I do use this cookbook. That is where I fail to see the relevance of the system cookbook.

flaccid commented 9 years ago

Nobody has to ever use 'the whole of a cookbook' if that cookbook is designed well. That is why recipes and LWRPs exist.

The relevance is that the system cookbook implements the change of /etc/hosts via the hostsfile cookbook (it depends on it) in essentially the same way, thus my original comment.

You can set the hostname with either cookbook. There is no reason why we can't learn from each other here - its the reason why I follow this cookbook.

mburns commented 9 years ago

:+1: wfm