How do I modify a local variable through ruby_block?

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:

  1. script resource => variable modification undone once out of scope
  2. ruby_block resource => variable modification undone once out of scope
  3. separate recipe with ruby code => ruby code still runs 1st before mounting
    the drive
  4. separate recipe with ruby_block/script => still cannot see the variable
    modification once out of scope
  5. node.save within ruby_block => save doesn’t occur until chef-client is done
    running all the resources
  6. databag.save within ruby_block => save doesn’t occur until chef-client is
    done running all the resources

Any suggestion?

Regard,

Daniel K.