As far as I know, the only reason you would use params.pp is if you have 
sane defaults you want to pass to variables. When you do, you use:

class test inherits test::params {
}

for your init.pp. You don't use an include statement as far as I know.

However, because you aren't defining sane defaults, you don't need the 
params.pp.

Instead just make your test/manifests/init.pp look like:

class test {

  $p1 = hiera('param1')
  $p2 = hiera('param2')

  file { 'testfile' :
    path   => "/tmp/testfile",
    content => template("test/testfile.erb"),
  }

}

Hope that helps.

--Alex

On Wednesday, April 30, 2014 11:31:03 AM UTC-7, drs 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/935d68a3-64cb-4f51-8fe4-a6282f4260dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to