Ask Your Question

Revision history [back]

Based on domcleal comment Foreman can not expand puppet variables directly. I will answer my own question here for documentation reasons:

As a workaround ERB templates can be used in class parameters. If global variables are defind in foreman, like in my case, one can to use the @host.params macro. Finally, setting this parameter in Foreman to my class myclass works as expected:

<%= @host.params['global_variable'] %>

Now resulting in a puppet output:

Notice: his is a foreman global variable
Notice: /Stage[main]/Myclass/Notify[parameter is:]/message: defined 'message' as 'this is a foreman global variable'

Based on Thanks to domcleal comment it is clear now Foreman can not expand puppet variables directly. I will answer my own question here for documentation reasons:

As a workaround ERB templates can be used in class parameters. If global variables are defind in foreman, like in my case, one can to use the @host.params macro. Finally, setting this parameter in Foreman to my class myclass works as expected:

<%= @host.params['global_variable'] %>

Now resulting in a puppet output:

Notice: his is a foreman global variable
Notice: /Stage[main]/Myclass/Notify[parameter is:]/message: defined 'message' as 'this is a foreman global variable'