我正在尝试创建一个取决于tomcat
食谱的厨师食谱,例如
tomcat_user = node[:tomcat][:user]
tomcat_user_home_folder = node[:etc][:passwd][tomcat_user][:dir]
execute "Install jasper license" do
command "cp jasperserver.license #{tomcat_user_home_folder}/"
cwd "#{node["install-jasper-license"]["license-location"]}"
end
在节点上运行sudo chef-client
时,出现以下错误:
================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/install-jasper-license/recipes/default.rb
================================================================================
NoMethodError
-------------
undefined method `[]' for nil:NilClass
在我看来,这个食谱是找不到的node[:etc][:passwd][tomcat_user]
。当 tomcat recipe 运行时,将安装一个 tomcat 用户。我还在depends 'tomcat'
这本食谱的 metadata.rb 中添加了内容。我的意图是在运行 tomcat 的用户的主位置安装一个文件。我该怎么做?