Monthly Archives: September 2011

Opscode Chef notes

Mostly for my benefit.


I was getting this error on a server:

FATAL: NoMethodError: private method `gsub' called for nil:NilClass

Turned out I didn’t have my hostname set.

# hostname -f
hostname: Unknown host

After setting my hostname the error went away.


Attributes.

I wanted to set some attributes in a role that could be used by a bunch of recipes.

This is the syntax I used.

#roles/myrole.rb
default_attributes(
:ganglia_server => "ganglia.example.com",
:serveradmin => "david@example.com"
)

Then in a template I used.

#cookbooks/ganglia/templates/default/gmond.conf.erb

...
 owner = "<%= node.serveradmin %>"
...
 host = "<%= node.ganglia_server %>"


Maybe is should have been obvious to do it this way. But for me it wasn’t.

Advertisements

2 Comments

Filed under Uncategorized