For this, you have 2 ways
Option1:
File resource can also put inside the ruby block for that you can use like this to your example mentioned in the question
ruby_block "get_file_list" do
block do
files = Dir['/some/dir/*']
files.each do |f|
t = Chef::Resource::File.new(f)
t.owner("woohoo")
t.group("woohoo")
t.mode("0600")
t.action(:create)
t.run_context=(rc)
t.run_action(:create)
end
end
end
Option 2:
In this type you can use node.run_state to pass data around. For this let’s see how to pass data with respect to example
ruby_block "get_file_list" do
block do
node.run_state['transferred_files'] = Dir['/some/dir/*']
end
end
node.run_state['transferred_files'].each do |file|
file "#{file}" do
group "woohoo"
user "woohoo"
end
end