Hi,
New to chef, be gentle.
I'm trying to write output from a web server into a template, but for
some reason can't make the data available to the template.
In my recipe I have:
# Set a location for the grabbed data
my_file = Chef::Config[:file_cache_path] + '/http_output.php'
# Grab the data and write the file if it doesn't exist
remote_file my_file do
source 'http://example.com/data_to_grab.html'
action :create_if_missing
mode 0644
end
#declare globally
gabbed_data = ''
#read the data into a variable
ruby_block 'read-grabbed-data' do
block do
grabbed_data = File.read(my_file)
end
action :create
end
# use the grabbed data in a template
template node['myapp']['path'] + '/config.php' do
source 'config.php.erb'
mode 0755
owner 'root'
group 'root'
variables(
:password => node['myapp']['password'],
:my_file => grabbed_data)
end
The template creates the config.php but doesn't output anything for
the my_file part. I've checked inside the block that the data is read,
and it is. I've also replaced grabbed_data with a string in the
template, and it makes it into the config.php output so the template
is good. I'm guessing it's something to do with the scope of the
variable not being available to the template.
Any ideas?
N
Archive powered by MHonArc 2.6.16.