You cannot specify the same parameter name twice in one class's declaration. It simply doesn't make sense -- they conflict.
You also cannot interpolate a class parameter's value into
its own default value. This stands to reason because the default is relevant only when no value is specified for the parameter. Moreover, you cannot modify a class parameter's (or any other Puppet variable's) value once it is assigned. You can, however, create a separate class variable that contains the transformed value you want.
As a separate matter, you cannot reliably interpolate the value of one class parameter into the default value of a different one, though there is
an outstanding feature request for that. In practice, doing so works for some combinations of parameters but not for others, and it is difficult to predict which will and won't work. You have a few options here, among them:
(1) Similar to the case of transforming a parameter value, you can create a separate class variable (not parameter) in which to assemble the wanted value. Example:
class webapps_dt($envir = "${which_envir}", $agent_name = undef) {
$envir_upcase = upcase($envir)
if $agent_name {
$agent_name_real = $agent_name
} else {
$agent_name_real = "WEBAPP_EC2EAST_${envir_upcase}_SERVICE"
}
# ... use $agent_name_real
}
(Note the braces around the variable name in the interpolation, by the way. Since you are proficient with bash scripting, I don't need to explain.)
(2) You can create a wrapper class that performs the data munging you want, and declares the true target class with the right parameters. The easiest way to do this is just a special case of (1), though, so it's usefulness is limited. It mainly serves cases where
other classes, not themselves declared by the target class, rely on the values of the target class's parameters:
class webapps_dt_wrapper($envir = "${which_envir}", $agent_name = undef) {
$envir_upcase = upcase($envir)
if $agent_name {
$agent_name_real = $agent_name
} else {
$agent_name_real = "WEBAPP_EC2EAST_${envir_upcase}_SERVICE"
}
class { 'webapps_dt':
envir => $envir,
agent_name => $agent_name_real
}
}
John