Scott Boring
Scott Boring

Reputation: 2781

Simple chef resource not being included

I'm trying to create a custom chef resource; and to start with I have basically a hello world example that is not working for me. It seems really simple; so I don't understand what I'm doing wrong.

I have a cookbook called 'couchbase' with the following directory structure

couchbase
  resources
     nodes.rb
  providers
     nodes.rb
  recipes
     default.rb

Here are the files

default.rb

nodes "update" do 

end

nodes.rb (resource)

actions :update
default_action :update

nodes.rb (providers)

def whyrun_supported?
  true
end

use_inline_resources

action :update do

  Chef::Log.info "Success in loading resource"

end

Here is the error I get with running the recipe

vagrant@precise64:/var/chef/cache/cookbooks/couchbase$ sudo chef-client -l info
[2014-08-27T21:04:57+00:00] INFO: Forking chef instance to converge...
[2014-08-27T21:04:57+00:00] WARN: 
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
SSL validation of HTTPS requests is disabled. HTTPS connections are still
encrypted, but chef is not able to detect forged replies or man in the middle
attacks.

To fix this issue add an entry like this to your configuration file:

```
  # Verify all HTTPS connections (recommended)
  ssl_verify_mode :verify_peer

  # OR, Verify only connections to chef-server
  verify_api_cert true
```

To check your SSL configuration, or troubleshoot errors, you can use the
`knife ssl check` command like so:

```
  knife ssl check -c /etc/chef/client.rb
```

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Starting Chef Client, version 11.14.6
[2014-08-27T21:04:57+00:00] INFO: *** Chef 11.14.6 ***
[2014-08-27T21:04:57+00:00] INFO: Chef-client pid: 4377
[2014-08-27T21:04:58+00:00] INFO: Run List is [recipe[couchbase]]
[2014-08-27T21:04:58+00:00] INFO: Run List expands to [couchbase]
[2014-08-27T21:04:58+00:00] INFO: Starting Chef Run for client1
[2014-08-27T21:04:58+00:00] INFO: Running start handlers
[2014-08-27T21:04:58+00:00] INFO: Start handlers complete.
[2014-08-27T21:04:58+00:00] INFO: HTTP Request Returned 404 Object Not Found: 
resolving cookbooks for run list: ["couchbase"]
[2014-08-27T21:04:58+00:00] INFO: Loading cookbooks [[email protected]]
Synchronizing Cookbooks:
[2014-08-27T21:04:58+00:00] INFO: Storing updated cookbooks/couchbase/recipes/default.rb in the cache.
  - couchbase
Compiling Cookbooks...

================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/couchbase/recipes/default.rb
================================================================================

NoMethodError
-------------
No resource or method named `nodes' for `Chef::Recipe "default"'

Cookbook Trace:
---------------
  /var/chef/cache/cookbooks/couchbase/recipes/default.rb:5:in `from_file'

Relevant File Content:
----------------------
/var/chef/cache/cookbooks/couchbase/recipes/default.rb:

  1:  #
  2:  # Cookbook Name:: couchbase
  3:  # Recipe:: default
  4:  #
  5>> nodes "update" do 
  6:      
  7:  end  8:  


Running handlers:
[2014-08-27T21:04:58+00:00] ERROR: Running exception handlers
Running handlers complete
[2014-08-27T21:04:58+00:00] ERROR: Exception handlers complete
[2014-08-27T21:04:58+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 1.767735946 seconds
[2014-08-27T21:04:58+00:00] ERROR: No resource or method named `nodes' for `Chef::Recipe "default"'
[2014-08-27T21:04:58+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

It appears that it can't find the 'node' resource; but as I understand it, it should be automatically loaded as part of the cookbook.

Any help would be appreciated.

Upvotes: 0

Views: 1095

Answers (1)

coderanger
coderanger

Reputation: 54211

The name of LWRP-based resources uses both the cookbook name and resource filename. In your case it would be couchbase_nodes.

Upvotes: 3

Related Questions