Reputation: 279
I am trying to create a recipe where I will iterate over a set of values and on each iteration I will override an attribute that is used to output a template.
So, for this code.....
count = 0
node['versions'].each do |a_version|
...
node.override['jboss']['PORT_OFFSET'] = (PORT_OFFSET.to_i + count)
template "#{JBOSS_DIRECTORY}standalone.xml" do
source 'standalone.xml.erb'
end
count += 100
end
...after the run I would like to have each standalone.xml contain a port_offset that is 100 more than the previous version.
so they would look like this..
jboss.socket.binding.port-offset:8000}">
jboss.socket.binding.port-offset:8100}">
jboss.socket.binding.port-offset:8200}">
...etc
but currently they all are the same number.
Any ideas of how to do this?
Upvotes: 1
Views: 881
Reputation: 279
answering my own question:
I did this to get it to work. I passed in the variable to the template where the count was incremented on each iteration.
template "#{JBOSS_DIRECTORY}standalone.xml" do
source 'standalone.xml.erb'
variables(
:port_offset => (node['jboss']['PORT_OFFSET'].to_i + count)
)
end
and in the template (standalone.xml.erb) I added this...
port-offset="${jboss.socket.binding.port-offset:<%= @port_offset %>}">
Upvotes: 3