Jira (PUP-10660) $module_name is not available up in epp()

10 views
Skip to first unread message

Magnus Jonsson (Jira)

unread,
Sep 7, 2020, 5:12:03 AM9/7/20
to puppe...@googlegroups.com
Magnus Jonsson created an issue
 
Puppet / Bug PUP-10660
$module_name is not available up in epp()
Issue Type: Bug Bug
Affects Versions: PUP 6.17.0
Assignee: Unassigned
Created: 2020/09/07 2:11 AM
Priority: Normal Normal
Reporter: Magnus Jonsson

Puppet Version: 6.17.0
Puppet Server Version: N/A
OS Name/Version: Ubuntu 16.04

Accessing the global (compiler) variabel $module_name in epp() does return an empty string. It does not generate an error/warning that is does not exist.

It is working in inline_epp().

The documentations indicates that this should work. See last paragraph of https://puppet.com/docs/puppet/6.18/lang_template_epp.html#epp_variables

Example module to repoduce:

the file: 'epp-modulename-file.txt' has the same content as $inl

 

class eppmnbug

Unknown macro: { $mn = $module_name $inl = @(INL) modulename}

Desired Behavior:

modulename: eppmnbug
noop: true
mn: eppmnbug

Actual Behavior:

modulename:
noop: true
mn: eppmnbug

 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Henrik Lindberg (Jira)

unread,
Sep 7, 2020, 3:17:03 PM9/7/20
to puppe...@googlegroups.com
Henrik Lindberg commented on Bug PUP-10660
 
Re: $module_name is not available up in epp()

It is actually that way by design. The epp()} function does not have access to the calling scope as it is evaluated in the top scope, and all variables must be given to it. In contrast {{inline_epp has access to the variables in the calling scope.

The $modulename is a special variable that is not really a top scope var - it cannot be since it since it has a different value depending on scope.

Magnus Jonsson (Jira)

unread,
Sep 10, 2020, 8:48:03 AM9/10/20
to puppe...@googlegroups.com

If it's not in the scope then I think that the epp() should complain that is not available at all and not just return an empty string.

Henrik Lindberg (Jira)

unread,
Sep 11, 2020, 9:54:04 AM9/11/20
to puppe...@googlegroups.com

That is also by design (ancient design decision that all variables that does not exist resolve to undef which renders as empty string). You can turn on "strict variables" as that would make it error instead. It is not on by default due to backwards compatibility reasons and if you turn it on you may find that the code you are running needs to be modified.

Magnus Jonsson (Jira)

unread,
Sep 11, 2020, 10:07:03 AM9/11/20
to puppe...@googlegroups.com

For other unknown variables in the epp-file a get a warning that it does not exist but $module_name is just "" without any notifiation.

Henrik Lindberg (Jira)

unread,
Sep 11, 2020, 2:57:03 PM9/11/20
to puppe...@googlegroups.com

Ah, yes... the global scope is actually named "" (nothing). Also an ancient design decision.

Reply all
Reply to author
Forward
0 new messages