Ask Your Question

Revision history [back]

This is the normal approach to resolving your problem:

class myproject::params {
  $path       = '/'
  $path_js    = '/js'
}

class myproject (
    $path       = $::myproject::params::path,
    $path_js    = undef,
) inherits ::myproject::params {

  if $::myproject::path_js {
    $path_js_real = $::myproject::path_js
  } else {
    $path_js_real = $::myproject::params::path_js
  }

  # Code goes here

}

You cannot use one parameter as an interpolation token in another parameter in the same class. E.g. this doesn't work:

class test (
  $foo = $bar,
  $bar = 'zapp',
  $baz = $bar,

) {
  alert($foo)
  alert($baz)
}

include test

This output is produced:

$ puppet apply ./test.pp
Alert: Scope(Class[Test]):
Alert: Scope(Class[Test]):
Notice: Compiled catalog for localhost in environment production in 0.02 seconds
Notice: Finished catalog run in 0.01 seconds