Skip to content

Instantly share code, notes, and snippets.

Created January 7, 2010 22:07
Show Gist options
  • Save anonymous/271627 to your computer and use it in GitHub Desktop.
Save anonymous/271627 to your computer and use it in GitHub Desktop.
module NtT
def node_to_text(hash_t, spacer)
output = ''
for k, v in hash_t
if v.is_a?(Hash)
output += spacer + "#{k.to_s} :\n"
output += node_to_text(v, spacer + ' ')
else
output += spacer + "#{k.to_s} : #{v.to_s}\n"
end
end
return output
end
end
class Chef::Recipe
include NtT
end
#class Chef::Recipe
# include NtT
#end
template "/tmp/node_hash.txt" do
source "node_hash.txt.erb"
action :create
variables :vars => node_to_text(node, '')
end
[Thu, 07 Jan 2010 14:08:15 -0800] DEBUG: Loading cookbook quick_start library file: /var/cache/chef/cookbooks/quick_start/libraries/node.rb
[Thu, 07 Jan 2010 14:08:15 -0800] DEBUG: Loading Recipe quick_start
[Thu, 07 Jan 2010 14:08:15 -0800] DEBUG: Found recipe default in cookbook quick_start
/usr/lib/ruby/gems/1.8/gems/chef-0.7.14/lib/chef/resource.rb:72:in `method_missing': undefined method `node_to_text' for Chef::Resource::Template (NoMethodError)
from /var/cache/chef/cookbooks/quick_start/recipes/default.rb:8:in `from_file'
from /usr/lib/ruby/gems/1.8/gems/chef-0.7.14/lib/chef/mixin/recipe_definition_dsl_core.rb:68:in `instance_eval'
from /usr/lib/ruby/gems/1.8/gems/chef-0.7.14/lib/chef/mixin/recipe_definition_dsl_core.rb:68:in `method_missing'
from /var/cache/chef/cookbooks/quick_start/recipes/default.rb:5:in `from_file'
from /usr/lib/ruby/gems/1.8/gems/chef-0.7.14/lib/chef/cookbook.rb:166:in `load_recipe'
from /usr/lib/ruby/gems/1.8/gems/chef-0.7.14/lib/chef/compile.rb:156:in `load_recipes'
from /usr/lib/ruby/gems/1.8/gems/chef-0.7.14/lib/chef/compile.rb:142:in `each'
from /usr/lib/ruby/gems/1.8/gems/chef-0.7.14/lib/chef/compile.rb:142:in `load_recipes'
... 7 levels...
from /usr/lib/ruby/gems/1.8/gems/chef-0.7.14/lib/chef/application.rb:57:in `run'
from /usr/lib/ruby/gems/1.8/gems/chef-0.7.14/bin/chef-client:26
from /usr/bin/chef-client:19:in `load'
from /usr/bin/chef-client:19
[daharon@chef-client tmp]$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment