Puppet templates, defined types, and variable scope [closed]

asked 2018-10-22 05:42:40 -0500

updated 2018-11-04 02:49:00 -0500

hhlp gravatar image

I'm trying to get my head wrapped around why this happening. The following code will not write the variable $group, but it will write the array $users in the template.

define bar::foo(
  String $group = $title,
  Array $users
) {

  file {'/tmp/my.file':
    ensure  => file,
    content => epp('bar/test.epp'),
  }
}
using an epp template that looks like this:

group: <%= $group %>
users: [<%= $users.map |$x|{ "'${x}'"}.join(', ') %>]
If I pass though the variable to the template, then $group gets written to 'my.file'.

define bar::foo(
  String $group = $title,
  Array $users
) {

  file {'/tmp/my.file':
    ensure  => file,
    content => epp('bar/test.epp', { group => $group }),


  }
}

How can the variable $users be present in the template's scope, while $group is not in the first example?

Thanks in Advance

Katherine

edit retag flag offensive reopen merge delete

Closed for the following reason spam or advertising by genodeftest
close date 2018-11-04 08:02:18.796599

Comments

Ad, not Fedora-related,...

florian gravatar imageflorian ( 2018-10-22 11:36:07 -0500 )edit
1

This looks like spam to me.

genodeftest gravatar imagegenodeftest ( 2018-11-04 08:02:04 -0500 )edit