我有自己的食谱,从AWS S3存储桶下载文件并尝试重新启动tomcat服务。
我正在使用https://github.com/opscode-cookbooks/tomcat
FILE: myapp/recipes/default.rb
include_recipe 's3_file'
include_recipe 'tomcat::default'
s3_file "/var/lib/tomcat6/webapps/ROOT.war" do
remote_path node['myapp']['packages_s3_bucket_path'] + 'myapp.war'
bucket node['myapp']['packages_s3_bucket']
aws_access_key_id node['myapp']['packages_s3_bucket_aws_access_key']
aws_secret_access_key node['myapp']['packages_s3_bucket_aws_secret_key']
notifies :restart, "service[tomcat]", :immediately
end
问题是在编译时找不到service[tomcat]
(tomcat在myapp的metadata.rb中也被引用)
Compiling Cookbooks...
[2015-01-14T00:56:14+00:00] WARN: Using java::default instead is recommended.
Converging 112 resources
[2015-01-14T00:56:15+00:00] INFO: Running queued delayed notifications before re-raising exception
[2015-01-14T00:56:15+00:00] ERROR: Running exception handlers
[2015-01-14T00:56:15+00:00] ERROR: Exception handlers complete
[2015-01-14T00:56:15+00:00] FATAL: Stacktrace dumped to /var/cache/chef/chef-stacktrace.out
Chef Client failed. 0 resources updated
[2015-01-14T00:56:15+00:00] ERROR: resource s3_file[/var/lib/tomcat6/webapps/ROOT.war] is configured to notify resource service[tomcat] with action restart, but service[tomcat] cannot be found in the resource collection. s3_file[/var/lib/tomcat6/webapps/ROOT.war] is defined in /var/cache/chef/cookbooks/uaa/recipes/default.rb:69:in `from_file'
[2015-01-14T00:56:15+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
有什么想法吗? 感谢
答案 0 :(得分:3)
假设您使用默认设置中的基本实例,那应该是service[tomcat6]
。服务资源为defined inside the LWRP。这只能起作用,因为提供的不是use_inline_resources
,所以在将来的某个时候这可能不再起作用。
编辑:
我在下面提到的黑客攻击。
ruby_block 'restart tomcat' do
action :nothing
block do
resources('service[tomcat6]').run_action(:restart)
end
end
或类似的东西。通知ruby块,它将查找真实资源并重新启动它。