Hello all,
I am having hard time with a variable modification. See the snippet below:
subdir = ““
ruby_block “read target archive directory name” do
block do
Dir.foreach(”/snapshot/#{dbSnapshotId}”) do |f|
unless(f.to_s.eql? “.”)
unless (f.to_s.eql? “…”)
Chef::Log.info("Timestamp: " + f.to_s)
subdir = f.to_s
node[:RestoreSubdir] = subdir
node.save
end
end
end
end
action :create
end
After the ruby_block, subdir is still an empty string. However, Chef::Log shows
a value otherwise. I also tried these other method in order to get this String
outside the ruby_block scope:
- script resource => variable modification undone once out of scope
- ruby_block resource => variable modification undone once out of scope
- separate recipe with ruby code => ruby code still runs 1st before mounting
the drive - separate recipe with ruby_block/script => still cannot see the variable
modification once out of scope - node.save within ruby_block => save doesn’t occur until chef-client is done
running all the resources - databag.save within ruby_block => save doesn’t occur until chef-client is
done running all the resources
Any suggestion?
Regard,
Daniel K.