[Satellite 6] Access SAT6 global parameter in file template

asked 2018-03-26 12:56:47 -0500


Global parameter 'webserver' set to true in SAT6

I have params.pp manifest that sets default values and pulls the values from SAT6:

class hardeningrhel::params (
  $webserver = 'false'
) {}


class hardeningrhel::init (
  $webserver = hardeningrhel::params::webserver
) {
  contains webserver.pp


class hardeningrhel::webserver {
  file { "/etc/test.txt":
    content => template('hardeningrhel/limits.conf.erb


#example text
<% if @webserver == 'true' -%>
I am a webserver
<% end %->

/etc/test.txt is not populated with "I am a webserver" when ran. How can I access SAT6 global params in puppet templates?

edit retag flag offensive close merge delete


You don't access 'global' params in a template, you need to pull in your value to be in scope of the puppet code calling your template, with `.erb` templates. That is one thing I like about `.epp` templates, you can explicitly list/pass parameters, which makes it obvious how to 'load' them in.

DarylW gravatar imageDarylW ( 2018-03-27 08:45:08 -0500 )edit

for example, you could do something like `$local_webserver = $webserver` and use $local_webserver in your template, provided that is actually within scope, unless you have to do something like `$local_webserver = $hardeningrhel::params::webserver`

DarylW gravatar imageDarylW ( 2018-03-27 08:46:25 -0500 )edit