I'm not sure I follow the use case, but you could probably get away with using inline_epp
or inline_template
to make it look like this feature exists.
For example:
# In real usage this would be the result of a hiera lookup
$simple_lookup_result = '9 % 7'
$simple_evaluated = inline_template("<%= ${simple_lookup_result} %>")
exec { 'simple':
command => "/bin/echo $simple_evaluated",
logoutput => true,
}
# Again, hiera...
$complex_lookup_result = 'sprintf("The value is %i", 9 % 7)'
$complex_evaluated = inline_template("<%= ${complex_lookup_result} %>")
exec { 'complex':
command => "/bin/echo $complex_evaluated",
logoutput => true,
}
And the results:
$ puppet apply eval.pp
Notice: Compiled catalog for box in environment production in 0.06 seconds
Notice: /Stage[main]/Main/Exec[simple]/returns: 2
Notice: /Stage[main]/Main/Exec[simple]/returns: executed successfully
Notice: /Stage[main]/Main/Exec[complex]/returns: The value is 2
Notice: /Stage[main]/Main/Exec[complex]/returns: executed successfully
Notice: Applied catalog in 0.05 seconds
Keep in mind that Hiera can interpolate variables or Hiera lookups, and lookups can also be done within the code that inline_epp
or inline_template
will ultimately evaluate.
N.B. that this is an example, and you shouldn't pass Hiera input into a shell command unless you trust your users and really like headaches.