【发布时间】:2015-01-19 23:53:09
【问题描述】:
(对不起链接,我不能发布超过两个..) 我正在尝试将提供程序添加到包含另一个包含 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]
我希望添加另一个名为“reload”的提供程序,它最终会调用 supervisorctl reread。
我在这里和那里尝试了很多例子,但没有运气: 来自 gitHub:chef_extend_lwrp
我试过 docs.chef.io lwrp_custom_provider_ruby 和neethack.com/2013/10/understand-chef-lwrp-heavy-version/
并试图模仿赛斯瓦戈的答案和示例: 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 的推荐信,我希望他能看到我的问题;)
【问题讨论】:
-
我已经尝试过没有运气的参考:stackoverflow.com/questions/16114469/…
-
neethack.com/2013/10/understand-chef-lwrp-heavy-version 也是。我一定错过了什么……
-
为什么不提出拉取请求来添加功能? coderanger 维护着那本食谱,并且对写得很好的拉取请求非常敏感。
-
我刚刚和他谈过了,可能就是这个了 :) 干杯。
标签: ruby import chef-infra lwrp