Hi
I have an epp template that looks as follows:
<%- |$testabc, $param1, $param2| -%>
Testvar1: <%= $::testclass::testvar1 %>
Testvar2: <%= $::testclass::testvar2 %>
Param1: <%= $::testclass::param1 %>
Param2: <%= $::testclass::param2 %>
Param1: <%= $param1 %>
Param2: <%= $param2 %>
TestABC: <%= $testabc %>

and a defined type that looks as follows:

define testclass::yoyo (
  String $param1 = 'hello',
  String $param2
)
{
  file { '/tmp/defined.type':
    ensure  => file,
    content => epp('testclass/data.epp',
      {
        'param1' => $param1,
        'testabc' => 'abc',
        param2 => $param2
      } )
  }

  file { '/tmp/defined.type.erb':
    ensure  => file,
    content => template('testclass/data2.erb'),
  }

  notify { [ $param1, $param2 ]: }
}

and init.pp:
class testclass {
  $testvar1 = 'one'
  $testvar2 = ['1', 'two']
}

I call this in the following way:
include testclass
testclass::yoyo { 'one':
  param1 => 'param1 value',
  param2 => 'param2 value',
}

I can easily reference the variables from the class and get their values in 
the EPP template however I can't do it for the defined type without passing 
variables as part of the epp function call and declaring the variables at 
the top of the epp template. Why is there a difference in how variables are 
accessed from a epp template, between a defined type and a class. Am I 
missing something or is it by design? I am using puppet 4.3.1

Regards

-- 
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/7c329914-ea5d-4c56-af6f-d050ebca0423%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to