I would like to reference variables inside instances of defined types. For example, what can I do to reference $x
and $y
of foo a
in bar b
?
define foo($x, $y) {
}
define bar($foo) {
notify { "${::$foo::x}": } # <- how to make this reference work?
}
foo { 'a':
x => 'oh bar may you reference me',
y => 'please'
}
bar { 'b':
foo => Foo['a'],
require => Foo['a']
}
The reason why I would like this to work is that a foo instance may contain many values that I wouldn't like to repeat to each and every resource that might need them. Instead of passing those values again and again, thus repeating myself, I'd rather pass a reference to their container.
I've been looking all over and tried a bunch of things, but can't seem to find an answer to this question anywhere. I know it is possible to amend attributes, reference resources and read class attributes, but is it possible to read attributes of a resource/defined type? If it isn't what is then the best possible work around?