(对不起链接,我不能发布超过两个..)我正在尝试将提供程序添加到包含另一个包含 LWRP 的食谱的食谱中。
包装好的食谱是平衡 Python 主管:[github.com/poise/supervisor.git][1] 我正在使用 Berkshelf 指向 Chef 来导入它:
source "...api.berkshelf.com"
source '....<my chef/berkshelf server>:26200'
cookbook 'supervisor', github: "poise/supervisor"
metadata
在我的食谱中:
.
.
include_recipe 'supervisor'
.
.
..我希望通过“新”操作向其中一个主管资源添加提供者。
以下是“导入”的提供者:[github.com/poise/supervisor/blob/master/providers/service.rb][1]
我希望添加另一个名为 action “reload” 的提供程序,最终将调用supervisorctl reread。
我在这里和那里尝试了很多例子,但没有运气:来自 gitHub:chef_extend_lwrp
我试过 docs.chef.io lwrp_custom_provider_ruby 和 neethack.com/2013/10/understand-chef-lwrp-heavy-version/
并试图模仿 Seth Vargo 的答案和示例:github.com/opscodecookbooks/jenkins/blob/8a2fae71cd994704b09924e9a14b70b9093963a3/libraries/credentials_password.rb
github.com/poise/supervisor/blob/master/providers/service.rb
github.com/poise/supervisor.git
但看起来 Chef 没有正确导入代码:
ERROR: undefined method `action' for Chef::Resource::SupervisorServices:Class
当我将我的库导入写为:(my_enable_service 已定义但我已将其从本示例中删除)
def whyrun_supported?
true
end
class Chef
class Resource::MyupervisorService < Resource::SupervisorService
provides :my_supervisor_service
actions :reload
@resource_name = :my_supervisor_service
end
end
class Chef
class Provider::MyupervisorService < Provider::SupervisorService
action :reload do
converge_by("Enabling #{ new_resource }") do
my_enable_service
end
end
end
end
Chef::Platform.set(
resource: :my_supervisor_service,
provider: Chef::Provider::MyupervisorService
)
我的食谱名称是:“my_supervisor”,我的库文件是“service.rb”
我也尝试过来自 stackoverflow 的许多答案,但我无法在此处发布,因为我缺乏声誉点 :( 我已经看到了很多来自 Seth Vargo 的参考资料,我希望他会看到我的问题;)