Chef infra Chef客户端没有名为“source';
我在尝试配置新服务器时遇到以下错误。以前一切都很好,所以我不知道为什么我会得到这个。这是否意味着我在使用模板时无法再使用源代码Chef infra Chef客户端没有名为“source';,chef-infra,Chef Infra,我在尝试配置新服务器时遇到以下错误。以前一切都很好,所以我不知道为什么我会得到这个。这是否意味着我在使用模板时无法再使用源代码 NoMethodError ------------- No resource or method named `source' for `Chef::Recipe "default"' Cookbook Trace: --------------- /var/chef/cache/cookbooks/switch/recipes/default.rb:15:in
NoMethodError
-------------
No resource or method named `source' for `Chef::Recipe "default"'
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/switch/recipes/default.rb:15:in `from_file'
Relevant File Content:
----------------------
/var/chef/cache/cookbooks/switch/recipes/default.rb:
13: if node.chef_environment == 'uk'
14: template "/etc/odbc.ini"
15>> source "odbc.ini.erb"
16: mode 0644
17: end
18:
19: case node['switch']['install_method']
20: when 'package'
21: include_recipe 'switch::package'
22: when 'source'
23: include_recipe 'switch::source'
24: end
System Info:
------------
chef_version=12.21.31
platform=debian
platform_version=8.10
ruby=ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-linux]
program_name=chef-client worker: ppid=2913;start=14:31:46;
executable=/opt/chef/bin/chef-client`
您的代码似乎错误,请尝试以下操作:
if node.chef_environment == 'uk'
template "/etc/odbc.ini" do
source "odbc.ini.erb"
mode 0644
end
end
您的模板资源缺少它的do
和end
,因此Chef试图自己调用source
。您可以查看资源语法:
资源是一个包含四个组件的Ruby块:类型、名称和名称
(或多个)属性(带值)和一个(或多个)操作。这个
资源的语法如下所示:
type 'name' do
attribute 'value'
action :type_of_action
end