- From: Jesse Nelson <
>
- To:
- Subject: [chef] Re: Re: Iterating over an array for a set of resources
- Date: Tue, 16 Oct 2012 18:09:40 -0700
You can pass any ruby data to your template via the variables option.
Erb templates support loops:
template "/tmp/foo" do
source "foo.erb"
variables( :org => org )
end
~~~ foo.erb
<% @org.each do |org| -%>
org is: <%= org %>
<% end %>
This is untested code i just wrote in the email, but the concept
should be communicated.
On Tue, Oct 16, 2012 at 5:52 PM, Maven User
<
>
wrote:
>
A better way would be - how can I user a property in a recipe to expand
>
tokens inside an erb file - or is that not possible?
>
>
>
>
>
On Tue, Oct 16, 2012 at 7:46 PM, Maven User
>
<
>
>
wrote:
>
>
>
> Hi list -
>
>
>
> I'm struggling a little bit with something - I'm trying to provision a
>
> "demo" environment and we need to set up several "fake" users.
>
>
>
> Part of this process is to fill in some data in a template then run a
>
> script, but I feel like the loop just selects the last thing in the array:
>
>
>
> orgs = ["Ermergerd", "FOO"]
>
>
>
>
>
> orgs.each do |org|
>
> Chef::Log.info("Org is : " + org)
>
> node.set[:org] = org
>
> Chef::Log.info("Org after node set: " + node[:org])
>
> end
>
>
>
> Is there a way to do this? I'm not even seeing anything come out of that
>
> loop :-/
>
>
Archive powered by MHonArc 2.6.16.