我正在尝试从我的包装器食谱食谱中的上游食谱(ceph)中解开一部分厨师食谱。简而言之,在某些必需的服务启动和运行之前,ceph用户池创建块在部署中执行得太早了。我将它移到一个新的包装器配方中,当服务运行时,它将在runlist下面执行。
为此,我尝试倒带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
endNoMethodError
-------------
undefined method `unwind' for Chef::Resource::CephPool我尝试过各种展开语句:例如:
unwind "ceph_pool pool['name']"
unwind "pool['name']"我以前在资源上使用过unwind/rewind (例如"execute x"),但我不确定如何正确地解开它。我已经阅读了chef-rewind提供的有限的文档,但我找不到解决方案。
发布于 2015-07-27 23:46:09
我已经解决了这个问题,并将分享我的解决方案,以防将来有人遇到类似的问题。正确的工作解决方案如下:
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它最初失败是因为我没有正确地插入展开属性:
也就是说,我错误地使用了展开"ceph_pool pool['name']"而不是正确的插值形式:unwind "ceph_pool[#{pool['name']}]"
我希望这个答案对任何其他可能遇到类似问题的人都有帮助。
https://stackoverflow.com/questions/31616985
复制相似问题