Jira (PUP-10966) Allow full-relative path references in file(), template(), related functions

19 views
Skip to first unread message

Reid Vandewiele (Jira)

unread,
Mar 16, 2021, 12:50:02 PM3/16/21
to puppe...@googlegroups.com
Reid Vandewiele created an issue
 
Puppet / Improvement PUP-10966
Allow full-relative path references in file(), template(), related functions
Issue Type: Improvement Improvement
Assignee: Unassigned
Created: 2021/03/16 9:49 AM
Priority: Normal Normal
Reporter: Reid Vandewiele

One of Puppet's most confusing long-standing idioms is its use of pseudo-relative module file references. Most notably, in file(), template(), and related functions.

# This retrieves content from <moduledir>/modname/files/filename
file('modname/filename')
 
# This retrieves content from <moduledir>/modname/templates/filename
template('modname/filename') 

This is difficult for new users to understand, and when ported to the command-line it breaks normal Unix behavior in that forward-slash does not reliably indicate a real file path, even relatively.

Feature Request

Anywhere these confusing references are used, permit instead full-relative path references, following this convention:

<modulename>/full/relative/path

So, the examples above could be used instead as:

 # This retrieves content from <moduledir>/modname/files/filename
file('modname/files/filename')
 
# This retrieves content from <moduledir>/modname/templates/filename
template('modname/templates/filename') 

The same way that it has become best practice to always use a DSL option that includes the literal string "facts" when referencing facts for clarity*, this capability would improve intuitiveness, readability, and discoverability for new users.

This will also make using a full-relative module path more tenable in CLI applications.

* e.g., don't use $::osfamily. Use getvar('facts.osfamily) or $facts['osfamily'] instead.

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

Reid Vandewiele (Jira)

unread,
Mar 16, 2021, 12:53:02 PM3/16/21
to puppe...@googlegroups.com
Reid Vandewiele updated an issue
Change By: Reid Vandewiele
One of Puppet's most confusing long-standing idioms is its use of pseudo-relative module file references. Most notably, in {{file()}}, {{template()}}, and related functions.
{code:java}# This retrieves content from <moduledir>/modname/files/filename

file('modname/filename')

# This retrieves content from <moduledir>/modname/templates/filename
template('modname/filename') {code}

This is difficult for new users to understand, and when ported to the command-line it breaks normal Unix behavior in that forward-slash does not reliably indicate a real file path, even relatively.
h2. Feature Request


Anywhere these confusing references are used, permit instead full-relative path references, following this convention:

{{<modulename>/full/relative/path}}

So, the examples above could be used instead as:
{code:java} # This retrieves content from <moduledir>/modname/files/filename

file('modname/files/filename')

# This retrieves content from <moduledir>/modname/templates/filename
template('modname/templates/filename') {code}

The same way that it has become best practice to always use a DSL option that includes the literal string "facts" when referencing facts for clarity*, this capability would improve intuitiveness, readability, and discoverability for new users.

This will also make using a an ecosystem consistent full-relative module path more tenable in CLI applications.

* e.g., don't use {{$::osfamily}}. Use {{getvar('facts.osfamily)}} or {{$facts['osfamily']}} instead.

Josh Cooper (Jira)

unread,
Mar 16, 2021, 3:50:05 PM3/16/21
to puppe...@googlegroups.com
Josh Cooper commented on Improvement PUP-10966
 
Re: Allow full-relative path references in file(), template(), related functions

Yeah the pseudo-relative thing is super confusing. I think my only concern is about not breaking existing modules. Someone might be currently using file('modname/files/a') and have a file in $codedir/environments/<env>/modname/files/files/a. With this change, puppet would look for $codedir/environments/<env>/modname/files/a which could be different than the old one. So we'd need to handle precedence and fallbacks...

Henrik Lindberg (Jira)

unread,
Mar 17, 2021, 5:35:03 AM3/17/21
to puppe...@googlegroups.com

I always wondered why the reference isn't a proper URL/URI including scheme. That would also open up for reading files and templates via http. For example module scheme could address any file in a module (i.e. what Reid proposed) - it would then not clash with the current "path only" based argument. You have to type a bit more though

# This retrieves content from <moduledir>/modname/templates/filename
template('module://modname/templates/filename')

Reid Vandewiele (Jira)

unread,
Mar 23, 2021, 12:14:03 PM3/23/21
to puppe...@googlegroups.com

Josh Cooper the Bolt team have sketched out a pretty solid adoption and deprecation plan for Bolt, with regards to the use of pseudo-relative paths pertaining to Bolt scripts—e.g. run_script()—which used to borrow the idiom.

What would it take for Puppet to align with their deprecation plan, albeit with a MUCH longer (probably indefinite) deprecation period for the old pathing?

Ciprian Badescu (Jira)

unread,
Jun 15, 2021, 10:40:01 AM6/15/21
to puppe...@googlegroups.com
Ciprian Badescu assigned an issue to Beth Glenfield
 
Change By: Ciprian Badescu
Assignee: Beth Glenfield
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Beth Glenfield (Jira)

unread,
Jun 16, 2021, 8:59:03 AM6/16/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Sep 14, 2021, 12:58:03 AM9/14/21
to puppe...@googlegroups.com

albeit with a MUCH longer (probably indefinite) deprecation period for the old pathing

That's kind of the rub. It's been that way for so long, we pretty much can't drop it without massive effort and tooling changes to help autoupdate manifests. At which point, I'd say that's just not going to happen.

Josh Cooper (Jira)

unread,
Jul 26, 2022, 5:00:03 PM7/26/22
to puppe...@googlegroups.com
Josh Cooper commented on Improvement PUP-10966

I don't see this happening since modules paths have worked this way forever

This message was sent by Atlassian Jira (v8.20.11#820011-sha1:0629dd8)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages