在模板中引用一个variables,从Puppet Ruby DSL的每个循环加载

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 

有了用Ruby DSL编写的这个类,我该如何正确引用模板中的variables? 我尝试了<%= item %><%= @item %><%= scope.lookupvar('item')%>但它们都不起作用 – 它们都返回nil。

UPD

我发现它的工作原理如果在循环中定义$item_name = item ,然后在模板中将其引用为$item_name

我发现它的工作原理如果在循环中定义$ item_name = item,然后在模板中将其引用为$ item_name。