我写了几本 LWRP 手册来安装和管理一些服务(Monit 和 Omnicheck)。它们提供的功能之一是让您提供将与模板或 cookbook_file 资源一起使用的文件。
我发现当我调用这些资源中的任何一个时,我必须提供“cookbook new_resource.cookbook”才能让它在给定文件的调用说明书中而不是在 LWRP 的说明书中查找。
这一切都很好,直到显然调用嵌套。在这种情况下,如果您使用 Omnicheck LWRP 设置新实例并选择通过 Monit 运行它,它将通过 Monit LWRP 为您更新 Monit。这适用于作为 LWRP 食谱的一部分创建的默认 Omnicheck 作业,但是当我尝试从另一本食谱创建新的 Omnicheck 作业时,Monit LWRP 阻塞并抱怨无法找到模板资源的文件.
问题是有问题的模板文件在 Omnicheck 食谱中,但 Monit LWRP 中的 new_resource.cookbook 正在评估顶级食谱而不是 Omnicheck 食谱。
所以路径看起来像:
应用程序 -> Omnicheck -> 监控
在此实例中,Monit LWRP 中的 new_resource.cookbook 值为“application”而不是“Omnicheck”。
由于 new_resource.cookbook 似乎不是我需要/想要的,我如何确定 LWRP 调用者的食谱?
相关错误类似于:
[2014-08-21T00:46:15+00:00] ERROR: my_omnicheck_service[chef] (application::default line 30) had an error: Chef::Exceptions::FileNotFound: template[/some/path/omnicheck/etc/stage/chef.conf] (/var/chef/cache/cookbooks/my_omnicheck/providers/service.rb line 10) had an error: Chef::Exceptions::FileNotFound: Cookbook 'application' (0.1.5) does not contain a file at any of these locations:
templates/centos-5.8/omnicheck.erb
templates/centos/omnicheck.erb
templates/default/omnicheck.erb