Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If a hostfile_entry block fails, /etc/hosts is left in a bad state #73

Open
synthesizerpatel opened this issue Oct 17, 2015 · 0 comments

Comments

@synthesizerpatel
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant