Hello all,
I have a config file which looks like this:
[cache:a]
MAX_CACHE_SIZE = 2000
MAX_UPDATES_PER_SECOND = 500
MAX_CREATES_PER_MINUTE = 100
LOG_UPDATES = False
[cache:b]
MAX_CACHE_SIZE = 2000
MAX_UPDATES_PER_SECOND = 500
MAX_CREATES_PER_MINUTE = 100
LOG_UPDATES = True
[cache:c]
MAX_CACHE_SIZE = 5000
MAX_UPDATES_PER_SECOND = 300
MAX_CREATES_PER_MINUTE = 200
LOG_UPDATES = False
I’ve created the following attributes:
default['app']['cache_instance_name'] = ['a','b','c']
default['app']['max_cache_size'] = [2000, 2000, 5000]
default['app']['max_updates_per_second'] = [500, 500, 300]
default['app']['max_creates_per_minutes'] = [100, 100, 200]
default['app']['log_updates'] = ['False', 'True', 'False']
What I need and it seems to be complicated is to have a template file which with help from mighty ERuby, will generate a config file that looks like the original above
What I was thinking of is something like:
[cache:<%= node['app']['cache_instance_name'].each do |max_cache_size, max_updates_per_second, max_creates_per_minutes, log_updates| %>]
MAX_CACHE_SIZE =<%="{max_cache_size}%>
MAX_UPDATES_PER_SECOND =<%="{max_updates_per_second}%>
MAX_CREATES_PER_MINUTE =<%="{max_creates_per_minutes}%>
LOG_UPDATES =<%="{log_updates}%>
<% end %>
Is this a good approach? Is the best? Is there any better one?
Thank you,
Gabriel