[Rails] 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 Chef).
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:
Code:
ruby_block "edit etc hosts" do block do rc = Chef::Util::FileEdit.new("/etc/hosts") rc.search_file_replace_line( /^127\.0\.0\.1 localhost$/, "127.0.0.1 #{new_fqdn} #{new_hostname} localhost" ) rc.write_file end end
-- Rodrigo de Campos Unix System Administrator
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home