我正在编写一个LWRP来为带有API密钥的redis数据库添加种子,以便进行身份验证。我的麻烦是用红宝石库做红宝石。我在网上搜索并找到了几个例子,但对我来说没有什么效果。
我在AWS OpsWorks上运行这个,所以它使用的是主厨-solo。
我尝试过在我的运行列表中包含一个安装红宝石(gem.rb)的菜谱。
我也尝试过在食谱中安装gem。
r = gem_package "redis" do
action :install
end
r.run_action(:install)或
r = chef_gem "redis" do
action :install
end
r.run_action(:install)这就是我在我的厨师长跑步时犯的错误
[2013-10-03T16:11:41+00:00] DEBUG: filtered backtrace of compile error:
[2013-10-03T16:11:41+00:00] DEBUG: filtered backtrace of compile error:
[2013-10-03T16:11:41+00:00] DEBUG: backtrace entry for compile error: '/opt/aws/opsworks/releases/20130926123105_208/site-cookbooks/ilnkmx/providers/add_app.rb:1:in `require''
[2013-10-03T16:11:41+00:00] DEBUG: Line number of compile error: '1'
[2013-10-03T16:11:42+00:00] ERROR: Caught exception while compiling OpsWorks custom run list: LoadError - no such file to load -- redis - /opt/aws/opsworks/releases/20130926123105_208/site-cookbooks/ilnkmx/providers/add_app.rb:1:in `require'我对露比很陌生,所以所有的帮助都很感激,谢谢你。
发布于 2013-10-08 21:18:47
因此,我似乎错过了一小块,我有一些东西在错误的地方。
首先,在我的菜谱中安装红宝石之后,我需要刷新宝石,如下所示。
r = chef_gem "redis" do
action :nothing
end
r.run_action(:install)
Gem.clear_paths我还要求在我的提供者库,这是不正确的。我需要在Gem.clear_paths之后在我的食谱中要求它,然后在我的提供者中,我会打开连接和预制件添加、删除或更新记录,如下所示。
action :create do
if @current_resource.exists
Chef::Log.info "#{ @new_resource } already exist - nothing to do."
else
converge_by("Create #{ @new_resource }") do
create_app_key
end
end
end
def create_app_key
redis = ::Redis.new
redis.set "#{@new_resource.app_name}", "#{@new_resource.api_key}"
endhttps://stackoverflow.com/questions/19164144
复制相似问题