I ran into this as I was putting together a kitchen test where I had created my nodes incorrectly. They had ipaddresses, but not fqdn (which I was using as the hostname argument).
This resulted in chef crashing out and the hosts file having a line with just an ip address without any hostname to the right of it.
I'll see if I can come up with a patch to fix this - I'm still learning chef/ruby. But the correct behavior for the file modification should be to (Using shell for clarity)
cp /etc/hosts to /etc/hosts.tmp
Make your modifications on hosts.tmp, and only if all the modification operations succeed would you then
mv hosts.tmp hosts
A mv operation on linux and osx is an atomic operation guaranteed(*) to succeed. Otherwise, this cookbook was exactly what I was looking for and a perfect resource. Thanks for sharing your work!
I ran into this as I was putting together a kitchen test where I had created my nodes incorrectly. They had ipaddresses, but not fqdn (which I was using as the hostname argument).
This resulted in chef crashing out and the hosts file having a line with just an ip address without any hostname to the right of it.
I'll see if I can come up with a patch to fix this - I'm still learning chef/ruby. But the correct behavior for the file modification should be to (Using shell for clarity)
cp /etc/hosts to /etc/hosts.tmp
Make your modifications on hosts.tmp, and only if all the modification operations succeed would you then
mv hosts.tmp hosts
A mv operation on linux and osx is an atomic operation guaranteed(*) to succeed. Otherwise, this cookbook was exactly what I was looking for and a perfect resource. Thanks for sharing your work!