在自定义食谱中找不到 LWRP
Cannot find the LWRP in custom cookbook
我正在构建一个安装我的节点 js 文件然后为它们设置 initd 脚本的食谱。不幸的是,我无法调用说明书中的非默认 LWRP。
这是 chef-client 的错误 运行:
26>> blah_node_as_service 'setting up pricing service' do
27: directory '/var/blah/blah-pricing/'
28: script 'pricing-http-server-cluster.js'
29: resource_name 'blah-pricing'
30: end
31:
Running handlers:
[2015-06-05T14:57:40-04:00] ERROR: Running exception handlers
Running handlers complete
[2015-06-05T14:57:40-04:00] ERROR: Exception handlers complete
[2015-06-05T14:57:40-04:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 1.961443247 seconds
[2015-06-05T14:57:40-04:00] ERROR: No resource or method named `frt_node_as_service' for `Chef::Recipe "default"'
[2015-06-05T14:57:40-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
这里是食谱中的关键文件。
blah@blah:~/chef-repo/cookbooks/blah-deploy$ ls resources/
default.rb blahNodeAsService.rb
blah@blah:~/chef-repo/cookbooks/blah-deploy$ cat resources/blahNodeAsService.rb
actions :install
default_action :install if defined?(default_action)
attribute :script, :kind_of => String, :required => true
attribute :directory, :kind_of => String, :required => true
attribute :resource_name, :kind_of => String, :required => true
blah@blah:~/chef-repo/cookbooks/blah-deploy$ cat providers/blahNodeAsService.rb
use_inline_resources
action :install do
converge_by("Installing.") do
resp = setUpService
@new_resource.updated_by_last_action(resp)
end
end
def load_current_resource
@current_resource = Chef::Resource::BlahNodeAsService.new(@new_resource.name)
@current_resource.directory(@new_resource.directory)
@current_resource.script(@new_resource.script)
@current_resource.resource_name(@new_resource.resource_name)
end
def setUpService
end
该说明书已包含在该服务的说明书中,并且该说明书中的默认 LWRP (default.rb) 工作正常。找不到第二个LWRP
谢谢
事实证明,您通过使用说明书名称和 LWRP 资源名称的组合来引用 LWRP:
<cookbook-name>_<resource-name>
在上面的例子中:
blah_deploy_blah_node_as_service
看来我应该给它起个更好的名字,但它至少在起作用。
我正在构建一个安装我的节点 js 文件然后为它们设置 initd 脚本的食谱。不幸的是,我无法调用说明书中的非默认 LWRP。
这是 chef-client 的错误 运行:
26>> blah_node_as_service 'setting up pricing service' do
27: directory '/var/blah/blah-pricing/'
28: script 'pricing-http-server-cluster.js'
29: resource_name 'blah-pricing'
30: end
31:
Running handlers:
[2015-06-05T14:57:40-04:00] ERROR: Running exception handlers
Running handlers complete
[2015-06-05T14:57:40-04:00] ERROR: Exception handlers complete
[2015-06-05T14:57:40-04:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 1.961443247 seconds
[2015-06-05T14:57:40-04:00] ERROR: No resource or method named `frt_node_as_service' for `Chef::Recipe "default"'
[2015-06-05T14:57:40-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
这里是食谱中的关键文件。
blah@blah:~/chef-repo/cookbooks/blah-deploy$ ls resources/
default.rb blahNodeAsService.rb
blah@blah:~/chef-repo/cookbooks/blah-deploy$ cat resources/blahNodeAsService.rb
actions :install
default_action :install if defined?(default_action)
attribute :script, :kind_of => String, :required => true
attribute :directory, :kind_of => String, :required => true
attribute :resource_name, :kind_of => String, :required => true
blah@blah:~/chef-repo/cookbooks/blah-deploy$ cat providers/blahNodeAsService.rb
use_inline_resources
action :install do
converge_by("Installing.") do
resp = setUpService
@new_resource.updated_by_last_action(resp)
end
end
def load_current_resource
@current_resource = Chef::Resource::BlahNodeAsService.new(@new_resource.name)
@current_resource.directory(@new_resource.directory)
@current_resource.script(@new_resource.script)
@current_resource.resource_name(@new_resource.resource_name)
end
def setUpService
end
该说明书已包含在该服务的说明书中,并且该说明书中的默认 LWRP (default.rb) 工作正常。找不到第二个LWRP
谢谢
事实证明,您通过使用说明书名称和 LWRP 资源名称的组合来引用 LWRP:
<cookbook-name>_<resource-name>
在上面的例子中:
blah_deploy_blah_node_as_service
看来我应该给它起个更好的名字,但它至少在起作用。