chef-rewind:解开上游食谱的一部分(ceph :: mon)

时间:2015-07-24 18:02:30

标签: chef chef-recipe rewind

我试图在我的包装食谱食谱中从上游食谱(ceph)中解开一份厨师食谱的一部分。简而言之,在某些必需的服务启动并运行之前,ceph用户池创建块在部署中过早执行。我将它移出一个新的包装器配方,当服务运行时,它将在运行列表中进一步执行。

为此,我试图从ceph :: mon上游配方中回放下面的块,然后在我的新包装配方中稍后执行它。我的代码目前如下:

include_recipe 'workday::chef-client'
require 'chef/rewind'
include_recipe 'ceph::mon'

if node['ceph']['user_pools']

   # Create user-defined pools
   node['ceph']['user_pools'].each do |pool|
     ceph_pool pool['name'] do
       unwind "pool"
       pg_num pool['pg_num']
       create_options pool['create_options'] if pool['create_options']
     end
   end
 end

来自chef-client的错误输出:

NoMethodError
-------------
undefined method `unwind' for Chef::Resource::CephPool

我尝试了各种展开声明: 例如

unwind "ceph_pool pool['name']"
unwind "pool['name']"

我以前在资源上使用了展开/快退(例如"执行x")但我不确定如何正确解开这个问题。我已经阅读了厨师倒带提供的有限文档,但我无法找到解决方案。

1 个答案:

答案 0 :(得分:1)

我已经解决了这个问题并将分享我的解决方案以防将来有人遇到类似的问题。正确的工作解决方案如下:

if node['ceph']['user_pools']

   # Create user-defined pools
   node['ceph']['user_pools'].each do |pool|
     # unwind user-defined pools
     unwind "ceph_pool[#{pool['name']}]"
   end
 end

它最初失败是因为我没有正确插入unwind属性:

即。我错误地使用了展开"ceph_pool pool['name']"而不是正确插补的表单:unwind "ceph_pool[#{pool['name']}]"

我希望这个答案对任何可能遇到类似问题的人都有帮助。