Problems using resources

I’ve got a chef server installed on CentOS 6, and am trying to get a recipe
working to configure NFS mounts on a client (also CentOS 6), and it keeps
failing:

[root@client ~]# chef-client
[Mon, 17 Oct 2011 10:12:56 -0400] INFO: *** Chef 0.10.4 ***
[Mon, 17 Oct 2011 10:12:57 -0400] INFO: Run List is [recipe[nfs]]
[Mon, 17 Oct 2011 10:12:57 -0400] INFO: Run List expands to [nfs]
[Mon, 17 Oct 2011 10:12:57 -0400] INFO: Starting Chef Run for client
[Mon, 17 Oct 2011 10:12:57 -0400] INFO: Loading cookbooks [nfs]
[Mon, 17 Oct 2011 10:12:57 -0400] INFO: Storing updated
cookbooks/nfs/resources/nfs1.rb in the cache.
[Mon, 17 Oct 2011 10:12:57 -0400] INFO: Storing updated
cookbooks/nfs/metadata.rb in the cache.
[Mon, 17 Oct 2011 10:12:57 -0400] ERROR: Running exception handlers
[Mon, 17 Oct 2011 10:12:57 -0400] FATAL: Saving node information to
/var/chef/cache/failed-run-data.json
[Mon, 17 Oct 2011 10:12:57 -0400] ERROR: Exception handlers complete
[Mon, 17 Oct 2011 10:12:57 -0400] FATAL: Stacktrace dumped to
/var/chef/cache/chef-stacktrace.out
[Mon, 17 Oct 2011 10:12:57 -0400] FATAL: NoMethodError: undefined method
`mount’ for #Class:0x7fa423126398

The contents of my nfs1.rb resource are

[~/Library/Chef/chef-repo/cookbooks/] % egrep -v ‘^#’ ./nfs/resources/nfs1.rb

mount “/nfsdir” do
device "nfs1.dom.ain.com:/ifs/nfs1"
fstype "nfs"
options "rw"
action [:mount, :enable]
end

The stack trace on the client is

Generated at Mon Oct 17 10:12:57 -0400 2011
NoMethodError: undefined method mount' for #<Class:0x7fa423126398> /var/chef/cache/cookbooks/nfs/resources/nfs1.rb:8:inclass_from_file’
/usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/…/lib/chef/resource.rb:533:in
build_from_file' /usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/resource.rb:500:ininitialize’
/usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/…/lib/chef/resource.rb:500:in
new' /usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/resource.rb:500:inbuild_from_file’
/usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/…/lib/chef/run_context.rb:96:in
load_lwrp_resources' /usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/run_context.rb:120:incall’
/usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/…/lib/chef/run_context.rb:120:in
foreach_cookbook_load_segment' /usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/run_context.rb:119:ineach’
/usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/…/lib/chef/run_context.rb:119:in
foreach_cookbook_load_segment' /usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/run_context.rb:117:ineach’
/usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/…/lib/chef/run_context.rb:117:in
foreach_cookbook_load_segment' /usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/run_context.rb:94:inload_lwrp_resources’
/usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/…/lib/chef/run_context.rb:59:in
load' /usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/client.rb:195:insetup_run_context’
/usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/…/lib/chef/client.rb:159:in
run' /usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:239:inrun_application’
/usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/…/lib/chef/application/client.rb:229:in
loop' /usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:229:inrun_application’
/usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/…/lib/chef/application.rb:67:in
run' /usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/chef-client:26 /usr/bin/chef-client:19:inload’
/usr/bin/chef-client:19

I also get the same sort of error when I try to use the “directory” directive.
Any thoughts on what I’m doing wrong, here?

-Mike

steeves@raingods.net

On Monday, October 17, 2011 at 7:22 AM, steeves@raingods.net wrote:

I've got a chef server installed on CentOS 6, and am trying to get a recipe
working to configure NFS mounts on a client (also CentOS 6), and it keeps
failing:

[root@client ~]# chef-client
[Mon, 17 Oct 2011 10:12:56 -0400] INFO: *** Chef 0.10.4 ***
[Mon, 17 Oct 2011 10:12:57 -0400] INFO: Run List is [recipe[nfs]]
[Mon, 17 Oct 2011 10:12:57 -0400] INFO: Run List expands to [nfs]
[Mon, 17 Oct 2011 10:12:57 -0400] INFO: Starting Chef Run for client
[Mon, 17 Oct 2011 10:12:57 -0400] INFO: Loading cookbooks [nfs]
[Mon, 17 Oct 2011 10:12:57 -0400] INFO: Storing updated
cookbooks/nfs/resources/nfs1.rb in the cache.
[Mon, 17 Oct 2011 10:12:57 -0400] INFO: Storing updated
cookbooks/nfs/metadata.rb in the cache.
[Mon, 17 Oct 2011 10:12:57 -0400] ERROR: Running exception handlers
[Mon, 17 Oct 2011 10:12:57 -0400] FATAL: Saving node information to
/var/chef/cache/failed-run-data.json
[Mon, 17 Oct 2011 10:12:57 -0400] ERROR: Exception handlers complete
[Mon, 17 Oct 2011 10:12:57 -0400] FATAL: Stacktrace dumped to
/var/chef/cache/chef-stacktrace.out
[Mon, 17 Oct 2011 10:12:57 -0400] FATAL: NoMethodError: undefined method
`mount' for #Class:0x7fa423126398

The contents of my nfs1.rb resource are

[~/Library/Chef/chef-repo/cookbooks/] % egrep -v '^#' ./nfs/resources/nfs1.rb

mount "/nfsdir" do
device "nfs1.dom.ain.com (http://nfs1.dom.ain.com):/ifs/nfs1"
fstype "nfs"
options "rw"
action [:mount, :enable]
end

The stack trace on the client is

Generated at Mon Oct 17 10:12:57 -0400 2011
NoMethodError: undefined method mount' for #<Class:0x7fa423126398> /var/chef/cache/cookbooks/nfs/resources/nfs1.rb:8:in class_from_file'
/usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/resource.rb:533:in
build_from_file' /usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/resource.rb:500:in initialize'
/usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/resource.rb:500:in
new' /usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/resource.rb:500:in build_from_file'
/usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/run_context.rb:96:in
load_lwrp_resources' /usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/run_context.rb:120:in call'
/usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/run_context.rb:120:in
foreach_cookbook_load_segment' /usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/run_context.rb:119:in each'
/usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/run_context.rb:119:in
foreach_cookbook_load_segment' /usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/run_context.rb:117:in each'
/usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/run_context.rb:117:in
foreach_cookbook_load_segment' /usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/run_context.rb:94:in load_lwrp_resources'
/usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/run_context.rb:59:in
load' /usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/client.rb:195:in setup_run_context'
/usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/client.rb:159:in
run' /usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:239:in run_application'
/usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:229:in
loop' /usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application/client.rb:229:in run_application'
/usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/../lib/chef/application.rb:67:in
run' /usr/lib64/ruby/gems/1.8/gems/chef-0.10.4/bin/chef-client:26 /usr/bin/chef-client:19:in load'
/usr/bin/chef-client:19

I also get the same sort of error when I try to use the "directory" directive.
Any thoughts on what I'm doing wrong, here?

-Mike

steeves@raingods.net (mailto:steeves@raingods.net)
Files in the resources directory are for LWRPs: http://wiki.opscode.com/display/chef/Lightweight+Resources+and+Providers+(LWRP) (tl;dr: DSL for creating your own resource types and provider back-ends)

If you're looking to use existing types to configure a system, you want a recipe instead. You might find this page handy: http://wiki.opscode.com/display/chef/Chef+Basics and this one: http://wiki.opscode.com/display/chef/Recipes

HTH,

--
Dan DeLeo