简单的厨师资源不包括在内

时间:2014-08-27 21:27:37

标签: ruby chef chef-recipe

我正在尝试创建自定义厨师资源;首先,我基本上有一个不适合我的hello world示例。看起来很简单;所以我不明白我做错了什么。

我有一本名为'couchbase'的食谱,其目录结构如下

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

以下是文件

default.rb

nodes "update" do 

end

nodes.rb(资源)

actions :update
default_action :update

nodes.rb(提供商)

def whyrun_supported?
  true
end

use_inline_resources

action :update do

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

end

以下是运行配方时出现的错误

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 [couchbase@0.1.0]
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)

似乎找不到'node'资源;但据我了解,它应该作为食谱的一部分自动加载。

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:3)

基于LWRP的资源的名称使用cookbook名称和资源文件名。在您的情况下,它将是couchbase_nodes