I have following manifest:
define foo($var) {
file { $var: }
$barclass::store += $var
}
class barclass {
$store = []
foo {
"test1": var => "test1",
"test2": var => "test2",
}
file { "myfile": content => template("puppet:///files/myfile.erb"); }
}
And following erb template:
<% store.each { |i| -%>
<%= i + " " -%>
<% } -%>
My intention here is to collect all $var variables used as parameter of type foo. And provide them in myfile.erb template. In my example $store variable was used.
This example does not work. What have I wrong?
Is there better way to achieve same thing? I basically need to collect parameters used in some type and then provide them in some template.
You can’t access variables set in puppet manifests directly (only facter facts) – what you need is scope.lookupvar
or just
if it’s not a module
SO