customink-webops / hostsfile

Easily manage your hosts file with Chef
Apache License 2.0
155 stars 82 forks source link

Entries can only be appended, unless explicitly removed with "remove" action #91

Open prein opened 7 years ago

prein commented 7 years ago

The way I use the resource is that I iterate over chef search results and run hostsfile_entry resource for each result (node). The problem is that when a node gets removed from chef or stops meeting search criteria, it is not removed from /etc/hosts. I'm wondering, would it be possible to make the resource manage the entire collection of entries it manages. Maybe use comment (or it's part) as identifier rather than (only) ip_address?

bby-bishopclark commented 6 years ago

I suspect it may require hostsfile code similar to the directory code here (but for hostnames instead):

https://github.com/zts/chef-cookbook-managed_directory/blob/master/resources/managed_directory.rb#L44

OR, when switched on, the cookbook would need to only accumulate hostsfile entries and converge the content later.