- From: FX <
>
- To:
- Subject: [chef] Using arrays in templates
- Date: Wed, 28 Jul 2010 14:50:55 +0300
Hi,
I have a question about templates and the correct syntax.
I have an array which contains the following data:
"name1","description of name1"
"name2","description of name2"
...
"nameN","description of nameN"
This array needs to be stored as an attribute of a role or node (so
that it can be overridden)
I assume it could look something like this:
"host":[["name1","description of name1"],["name2","description of name2"]]
Now the problem (at least for me) is how do I specify this in the template?
I have tried this (I assume it does not work because it needs to have
a object and not array):
<% @host.each do |h| %>
<%= host[0] %> <%= host[1]%>
<% end %>
if I write something like this
<% for h in @hosts %>
<%= h[0] %> <%= h[1]%>
<% end %>
the I get `render_template': undefined method `keys' for
#<Array:0x2b099b406648> (Chef::Mixin::Template::TemplateError)
So my question is, how can I use arrays in templates and store their
values in a role or node attribute?
Can you show me an example of this?
Thanks a lot!
Regards,
chef user
- [chef] Using arrays in templates, FX, 07/28/2010
Archive powered by MHonArc 2.6.16.