puppetlabs / puppet

Server automation framework and application
https://puppet.com/open-source/#osp
Apache License 2.0
7.46k stars 2.19k forks source link

find_template breaks the implied functionality of deferrable_epp #9518

Open tedgarb opened 1 week ago

tedgarb commented 1 week ago

Describe the Bug

I am trying to use stdlib::deferrable_epp, from functions/deferrable_epp.pp . In the case a Deferred value appears, find_template from lib/puppet/functions/find_template.rb is used to find the template. However, find_template requires the .epp extension to be defined, while stdlib::deferrable_epp does not provide it, so the template cannot be found when leaving off the .epp in both the case where there is a Deferred, and when there is not.

Expected Behavior

Regardless of the presence or lack of a Deferred, stdlib::deferrable_epp should render the epp template without the .epp extension.

Steps to Reproduce

I will borrow the example from https://www.puppet.com/docs/puppet/8/template_with_deferred_values.html

  1. Define this collection of resources:

    $variables = {
      'password' => 'foo',
    }
    
    # compile the template source into the catalog
    file { '/etc/secrets.conf':
      ensure  => file,
      content => epp('mymodule/secrets.conf', $variables)
    }
    
    $variables = {
      'password' => Deferred('vault_lookup::lookup',
                      ["secret/test", 'https://vault.docker:8200']),
    }
    
    # compile the template source into the catalog
    file { '/etc/secrets.conf':
      ensure  => file,
      content => stdlib::deferrable_epp('mymodule/secrets.conf', $variables)
    }
  2. The first declaration works, but the second cannot find the template

Environment

Additional Context

This can be worked around if you always include the .epp extension, but since it isn't required in the epp function, it would be nice if it was not required in thedeferrable_epp function