On 11-10-04 09:11 AM, jcbollinger wrote:
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
Very interesting ideas John.
I did not thought about making the parameters available by assigning
them to class variables.
That would indeed work, but I was hoping for some kind of method that
would allow to get the value,
I also thought about passing every single parameter through hiera, so
that they are easily available for any object,
but that kind of end up having all variables/parameters in on place like
it used to be in 0.25.X.
I think I need to make up my mind about the best way to do this.
Thanks a lot
--
Bruno
--
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.