【发布时间】:2017-04-06 15:53:47
【问题描述】:
我正在尝试创建一个解压缩某些文件的配方,然后行为取决于 zipfile 的内容。 但我不知道如何克服 Compile vs Converge 阶段。
在执行配方之前目录不存在,因此获取子目录的命令必须在 ruby 块内才能在运行时获取数据。
但是一旦命令在 ruby 块内,我就无法“读取”变量或属性的新值。
这是一个示例:
ruby_block 'update patch attributes' do
block do
OPatchPath="#{node[:oracle][:rdbms][:ora_home]}/OPatch/#{Patch_No}"
Subdir_list = Dir.glob("#{OPatchPath}/*/")
Subdir_list.each do |dir|
Subdir_list.map! {|dir| dir.sub("#{OPatchPath}/", "")}
Subdir_list.map! {|dir| dir.sub('/', "")}
end
node.set[:oracle][:rdbms][:oracle_patch_list]=Subdir_list
end
end
## if there are no directories with numberes
if Subdir_list.find { |e| /^\d+$/ =~ e } == nil
do something
else
if Subdir_list.count == 2
do something else
else
do some other something
end
end
我在网上做了深入的研究并尝试了很多建议,包括使用lazy、node.set、node.default node.run_state,但没有运气。 我错过了什么? 有什么建议吗?
谢谢,Ofir。
【问题讨论】:
标签: chef-infra