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

Allow execution of Puppet functions from Hiera #336

Open
tuxmea opened this issue Jan 10, 2023 · 4 comments
Open

Allow execution of Puppet functions from Hiera #336

tuxmea opened this issue Jan 10, 2023 · 4 comments

Comments

@tuxmea
Copy link
Member

tuxmea commented Jan 10, 2023

It should be possible to call puppet functions directly from Hiera.
e.g.

stdlib::manage::create_resources:
  file:
    '/etc/app/db.cfg':
      ensure: 'file'
      content: "%{epp('profile/app/db.cfg.epp')}"

Hiera should then return the epp parsed content.

How are we able to solve this?
Which syntax would be possible or recommended?

@tuxmea
Copy link
Member Author

tuxmea commented Jan 10, 2023

Note: the above is just an example. It should be possible to execute any Puppet function, like upcase, template, keys, profile::get_url, ...
Maybe limit to custom functions only, omitting Puppet DSL functions.

@ekohl
Copy link
Member

ekohl commented Jan 10, 2023

There's a risk of recursion, like calling lookup().

@tuxmea
Copy link
Member Author

tuxmea commented Jan 10, 2023

There's a risk of recursion, like calling lookup().

Risk of recursion is there at the moment, too when using lookup or alias.
I assume I saw some Ruby code which takes care on this.

@hlindberg
Copy link

A recursion guard is indeed implemented in hiera 5. I wrote a puppet language backend (available in my github.com/hlindberg/tahu module that interprets all data as puppet language "snippets". With it is possible to call any function from within hiera data, and it does recursion checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants