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
--
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...@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.
For more options, visit https://groups.google.com/d/optout.
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::paramsfile { '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::p2and 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.
Note 1: Although declaring another class does not make its variables local, inheriting from another class does effectively do so. But use class inheritance for that purpose.
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?
By the way, if you are using Puppet 3.0.0 or newer you shouldn't need the hiera() function at all.
--To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/caf5ac4a-23c2-4ad1-9b94-17d9bb30c0e4%40googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "Puppet Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/puppet-users/jZGsQ97oljs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to puppet-users...@googlegroups.com.