How to use node-specific information with exported resource collectors?

asked 2016-07-15 16:52:34 -0600

Rob Ogilvie gravatar image

How can I use node-specific information (ie; hiera data) with exported resource collectors?

I have a defined type:

define oradatabase::tnsname (String $sid = $title, String $host, String $port = '1521') {
  if ! defined(Concat["/tmp/tnsnames.ora"]) {
    concat { "/tmp/tnsnames.ora":
      ensure => present,
      ensure_newline => true,

  concat::fragment { "$title":
    target => "/tmp/tnsnames.ora",
    content => template('oradatabase/tnsname.erb'),

and have elsewhere exported resources of that type:

  @@oradatabase::tnsname { "$sid":
    host => $fqdn,

and have finally collected and realized the collection:

  Oradatabase::Tnsname <<| |>>

This all works great! However, my use case is such that I need to have one or more instances of tnsnames.ora located at various places on my systems. It'll vary depending on each system. I need to take that /tmp/tnsnames.ora and make it available as a defined type I can realize multiple locations - with those locations not known at export time, but at realization time.

How best should I accomplish this?

edit retag flag offensive close merge delete