We just ran into this too recently. From my investigation it looks like the syntax you quote above is for referencing Hiera values in Puppet manifests. For erb templates we ended up using scope.function_hiera () although I wonder now whether a scope.lookupvar () call would a) be better and b) be better as it's more generic?
Matt On 30 Apr 2014 19:48, "drs" <david.r.stei...@dartmouth.edu> wrote: > I am new to puppet and am trying to figure out variable scoping. I have a > test module that I am using for this and it looks like this: > > manifiests/init.pp: > > class test { > include test::params > > file { 'testfile' : > path => "/tmp/testfile", > content => template("test/testfile.erb"), > } > } > > manifests/params.pp: > > class test::params { > $p1 = hiera('param1') > $p2 = hiera('param2') > } > > templates/testfile.erb: > > this is the first parameter: <%= @p1 %> > this is the second parameter: <%= @p2 %> > > global.yaml: > > --- > param1: "this is the first one" > param2: "this is the second one" > > Based on what I am seeing in the ProPuppet book (the discussion of the > puppet module in Chap. 2, pp69-70), this should work. However, the values > are not being inserted in the template. In order to get them in, I have to > add something like this to the init.pp manifest: > > $a = $::test::params::p1 > $b = $::test::params::p2 > > and reference @a and @b in the template. > > So the question is: Am I missing something or is there an error in the > ProPuppet example? > > If I need to add the $a = …. and $b=… lines to the init.pp, what, if any > is the advantage to having a params.pp manifest. I could just put the > hiera() calls in init.pp. > > thanks for your patience. > > -- > 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+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/puppet-users/abcf9bb6-b3a2-483d-8655-3b6a6eed8196%40googlegroups.com<https://groups.google.com/d/msgid/puppet-users/abcf9bb6-b3a2-483d-8655-3b6a6eed8196%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CAKUTv3KZS9NQKEhOcM_WYBrX1w%3DiO2j0gChwN7ok%3DX-w4cw0TQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.