When using chef, I have often faced the problem of having to insert a line into an existing file. The way I solved this before, was to use bash. bash "insert_line" do user "root" code <<-EOS echo "172.22.0.47 www.example.com" >> /etc/hosts EOS not_if "grep -q www.example.com /etc/hosts" end The Chef (or better the Ruby) way to do this is the following: ruby_block "insert_line" do block do file