Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse deferred templates non deferred first #1425

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Apr 15, 2024

  1. Parse deferred templates twice

    Currently it is not possible to have a template file.epp
    
    ```puppet
    <%- |
    Stdlib::Port $port,
    String[1] $password,
    | %>
    port <%= $port %>
    password <%= $password %>
    
    ```
    
    and run
    
    ```puppet
    file{'/tmp/junk':
      content => stdlib::deferrable_epp('module/file.epp', { 'port' => '1234', pass => Deferred('secrets::get',['mysecret'])}),
    }
    ```
    since the deferred template substitution  will fail:
    ```
    Error: Failed to apply catalog: Evaluation Error: Resource type not found: Stdlib::Port (file: inlined-epp-text, line: 2, column: 3)
    ```
    due to Stdlib::Port not being available on the agent node.
    
    This change now parses the EPP twice. The first pass will reduce the
    template to:
    
    ```puppet
    port = 1234
    password <%= $password %>
    ```
    
    and this simpler template will be passed in deferred mode.
    
    Note the original template type for password must accept the
    intermediate generated value of `<%= $password %>` which is typically
    case for a secret password.
    traylenator committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    60fd443 View commit details
    Browse the repository at this point in the history