Suppose I want hostB
to have a distinct file for each puppet node, but with owner that is only known to the hostB
.
Theoretically it can be done, if we allow hostB
to write a custom fact (my_special_owner
), and then read that fact via query_facts
function in the my_resource
definition by hostA
. But that seems too dirty: it pollutes the facts namespace with meaningless stuff, possibly causing name clashes. It is also a lot of coding for such a simple thing.
Here is a mockup of what I have in mind:
define my_resource() {
$owner=${my_collector::owner} #This attempt fails
file{$name: ensure=>exists, owner=>$owner}
}
node hostA {
@@my_resource{"/tmp/file1.tmp"}
}
class my_collector($owner) {
# How to pass $owner to the collector below?
My_resource <<| |>>
}
node hostB {
class {'my_collector': owner=>bob}
}
See this section for Puppet documentation about customizing collector attributes. Example: