1

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}
}
Adam Ryczkowski
  • 720
  • 1
  • 9
  • 29
  • 1
    https://docs.puppetlabs.com/puppet/latest/reference/lang_resources.html#amending-attributes-with-a-collector not working? – thankyour Mar 06 '15 at 22:05
  • I didn't find it. I wrongly assumed that all information about resource collectors will be on their dedicated https://docs.puppetlabs.com/puppet/latest/reference/lang_collectors.html page... If you make this an answer I'll accept it. – Adam Ryczkowski Mar 07 '15 at 08:18

1 Answers1

1

See this section for Puppet documentation about customizing collector attributes. Example:

File <| |> {
  owner => 'foo',
}
thankyour
  • 126
  • 3