Ruby code on Chef as a "ruby_block" not working

Hi Ruby hackers,

I have very limited knowledge of the Ruby programming language,

however, I need to implement on Chef (check-solo) something similar
to “augeas” (which works with Puppet, but here I need a solution for

I got the example code below but it's not working and I am now for a

few days trying to figure out what is wrong.

Basically I need to be able to select specific strings in a text

file and modify these values. I could use sed but perhaps I can do
it in a more elegant way using the ruby_block from Chef.

Please let me know what can be possibly wrong with the code below.

Why is my /etc/hosts not being updated with new values?

Always when I re-run chef-solo, I get the following error:

**NoMethodError** **-------------** **undefined method `chef' for Chef::Resource::RubyBlock**

Thanks for your help.

Follows my **default.rb** file:


  ruby_block "edit etc hosts" do
block do
rc ="/etc/hosts")
/^127\.0\.0\.1 localhost$/,
" #{new_fqdn} #{new_hostname} localhost"

You should really ask about this in a chef support area, as it is something very specific to chef.

As it is, you cannot define local functions in chef recipes, they have to be defined in libraries and called from such.

Stackoverflow is really your best bet for help on chef things, or the #chef channel on