ruby_block "insert_line" do
block do
file = Chef::Util::FileEdit.new("/etc/hosts")
file.insert_line_if_no_match("/www.example.com/", "www.example.com")
file.write_file
end
end

Now this big question is, which is better or more readible. I guess this depends if you are more familiar with shell or ruby scripting.
One advantage of the ruby way is that the Chef::Util::FileEdit class offers a couple of other possibilities to manipulate files.

Everyone is talking about Continuous Delivery and DevOps these days. An elemental part of this is the move towards automation of recurring tasks that have been performed manually in many businesses in the past. Especially comprehensive deployment automation is one of the most desirable goals in this methodology.

The software build process is widely automized nowadays thanks to tools like Maven or Ant and Continuous Integration servers like Jenkins, TeamCity or GO. The Internet provides plenty of good technical instructions about how to setup and run these tools. But when it comes to the last mile, the actual deployment process, most literature doesn’t go into much detail about best practices and tools to use.

Currently I am trying to dig deeper into this field, and I’d like to share my learnings. The tools that support automated deployments are also called command dispatching frameworks. The ones I run into the most are (this list is not supposed to be complete):