On Oct 3, 5:44 pm, Bruno Leon <[email protected]> wrote:
> Hi,
>
> is there a way to get the value of a parameter passed to a parameterized
> class ?
> I've searched quite a lot and did not came out with a solution.
Did you mean within your manifests? You can do it easily as long as
the class in question provides for it, otherwise not at all. For
example:
module1::class1($param1, $param2='foo') {
$my_param1 = $param1
$my_param2 = $param2
}
module2::class2 {
notify { "module1::class1::param1":
message => "module1::class1::param1 = $
{module1::class1::my_param1}"
}
notify { "module1::class1::param2":
message => "module1::class1::param2 = $
{module1::class1::my_param2}"
}
}
There, the class makes the parameters externally available by
assigning their values to class variables. If you need parameter
values from a class that does not expose them that way and that you
cannot modify to do so, then you are out of luck. You can get
something close, however: you can record the values that are
*supposed* to be assigned in global variables or some other class's
variables. For example,
module3::class3($param1, $param2='foo') {
}
module4::class4 {
$class3_param1 = 42
$class3_param2 = 'bar'
class { "module3::class3":
param1 => $class3_param1
param2 => $class3_param2
}
}
module5::class5 {
notify { "module3::class3::param1":
message => "module3::class3::param1 = $
{module4::class4::class3_param1}"
}
notify { "module3::class3::param2":
message => "module3::class3::param2 = $
{module4::class4::class3_param2}"
}
}
Good luck,
John
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.