Andriy Yurchuk
2013-Feb-05 20:04 UTC
[Puppet Users] Referencing a variable in template, loaded from Ruby DSL each loop
hostclass :class do items = scope.lookupvar(''items_list'') items.each do |item| file("/etc/init.d/#{item}", :content => template([''class/item_init.erb''])) end end Having this class written in Ruby DSL, how do I properly reference the itemvariable in the template? I tried <%= item %>, <%= @item %>,<%= scope.lookupvar(''item'')%> but none of them work. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Andriy Yurchuk
2013-Feb-06 09:02 UTC
[Puppet Users] Re: Referencing a variable in template, loaded from Ruby DSL each loop
I''ve found out that it works if inside the loop I define $item_name = itemand then reference it as $item_name in the template. On Tuesday, February 5, 2013 10:04:14 PM UTC+2, Andriy Yurchuk wrote:> > hostclass :class do > items = scope.lookupvar(''items_list'') > items.each do |item| > file("/etc/init.d/#{item}", > :content => template([''class/item_init.erb''])) > end > end > > Having this class written in Ruby DSL, how do I properly reference the > item variable in the template? I tried <%= item %>, <%= @item %>,<%= > scope.lookupvar(''item'')%> but none of them work. >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.