Ask Your Question

Instantiating Exported Resources Repeatedly

asked 2017-02-09 17:33:11 -0600

Rob Ogilvie gravatar image

Context: I'm trying to build a file that lists the names and locations all the databases I've defined across Puppet (a tnsnames.ora file).

I have defined a tnsname type that includes a concat::fragment, which is exported each time a database is defined (@@tnsname).

I then have a tnsnames type that collects all the tnsname exported resources and instantiates them:

define tnsnames ($path = $title,
          String $devprod = 'dev', ) {

  # Build the master tnsnames.ora file

  if $devprod == 'all' {
    Profile::Tnsnames::Tnsname <<| |>> {
      path => $path,
  } else {
    Profile::Tnsnames::Tnsname <<| tag == $devprod |>> {
      path => $path,

However, if I try and instantiate it more than once (with different paths), I'm seeing some incredibly odd behavior. It only creates the last one tnsnames defined type lists.

What is the best way to handle a problem like this? I want to iterate over all the exported database resources and pull information from them into the proper format for the tnsnames.ora file, instantiating the file differently in different places; with different tags. I believe I am approaching this incorrectly and wish to know how others solve similar problems. Ideally, I need a "tnsnames" type that I can instantiate anywhere with different parameters to build the file in different locations.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-02-10 03:55:53 -0600

DarylW gravatar image

I have two possible suggestions:

Query puppetDB for the information you need. If on older puppet, use , newer puppet use the pql - -

Use the datacat module, , you may be able to use that as your exported resource and collect it different times.

edit flag offensive delete link more


I tried puppetdbquery, but it appears to only support query_facts and query_nodes, neither of which seems to support external resources or anything that isn't defined as a fact (and the databases are defined in hiera, not as facts)

Rob Ogilvie gravatar imageRob Ogilvie ( 2017-02-10 15:22:17 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-02-09 17:33:11 -0600

Seen: 47 times

Last updated: Feb 10 '17