我需要帮助解决以下厨师食谱的问题:
application = "edge-api"
remote_file "/usr/local/edge-api/#{application}-#{application_version}.jar" do
source "#{node.default["thecloud"]["repo_url"]}/#{application}/#{application}-#{application_version}.jar"
mode "0644"
checksum application_sha256
notifies :stop, "service[edge-api]", :delayed
notifies :start, "service[edge-api]", :delayed
end
我收到此错误:
> FATAL: Chef::Exceptions::ResourceNotFound: resource remote_file[/usr/local/edge-api/edge-api-0.1.9.jar] is configured to notify resource service[edge-api] with action stop, but service[edge-api] cannot be found in the resource collection. remote_file[/usr/local/edge-api/edge-api-0.1.9.jar] is defined in /var/chef/cache/cookbooks/edge-api/recipes/default.rb:40:in `from_file'
我是厨师初学者,正在尝试修改上述食谱。要求是将 upstart 转换为 systemd,因为我们正在从 centos 6 迁移到 7
该错误是抱怨缺少资源声明。在问题中,您显示了 1 个资源,这将导致服务“edge-api”在
remote_file
(jar 文件)更改时停止和启动。从错误来看,您似乎没有该服务的声明。
在这种情况下,以下添加内容应该会有所帮助。
application = "edge-api"
remote_file "/usr/local/edge-api/#{application}-#{application_version}.jar" do
source "#{node.default["thecloud"]["repo_url"]}/#{application}/#{application}-#{application_version}.jar"
mode "0644"
checksum application_sha256
notifies :stop, "service[edge-api]", :delayed
notifies :start, "service[edge-api]", :delayed
end
service application do
action :nothing
end
下面还有完整的食谱,请查看并让我知道缺少的内容。
application = "edge-api"
remote_file "/usr/local/edge-api/{application}-{application_version}.jar" do
source "{node.default["thecloud"]["repo_url"]}/{application}/{application}-{application_version}.jar"
mode "0644"
checksum application_sha256
notifies :stop, "service[edge-api]", :delayed
notifies :start, "service[edge-api]", :delayed
end
template "/usr/local/edge-api/application.properties" do
owner "root"
group "edge-api"
mode "0640"
variables(
:clouddbIp => node['tcDatabase']['clouddb']['ip'],
:clouddwhIp => node['tcDatabase']['clouddwh']['ip'],
:elasticnodes => elasticnodes
)
notifies :stop, "service[edge-api]", :delayed
notifies :start, "service[edge-api]", :delayed
end
template "/etc/init/edge-api.conf" do
owner "root"
group "edge-api"
mode "0750"
variables(
:application_jar => "{application}-{application_version}.jar",
:java_home => node['java']['8']['home']
)
notifies :stop, "service[edge-api]", :delayed
notifies :start, "service[edge-api]", :delayed
end
template "/usr/local/edge-api/logback.xml" do
owner "root"
group "edge-api"
mode "0640"
end
template '/etc/systemd/system/{application}.service' do
source "{application}.service.erb"
owner "root"
group "root"
mode "0644"
notifies :run, 'execute[daemon-reload]', :immediately
end
execute 'daemon-reload' do
command 'systemctl daemon-reload'
action :nothing
end