Ask Your Question
0

Instantiating Exported Resources Repeatedly

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

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
  validate_absolute_path($path)

  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
0

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

DarylW gravatar image

I have two possible suggestions:

Query puppetDB for the information you need. If on older puppet, use https://github.com/dalen/puppet-puppe... , newer puppet use the pql - https://docs.puppet.com/puppetdb/4.3/... - https://puppet.com/blog/introducing-p...

Use the datacat module, https://forge.puppet.com/richardc/dat... , you may be able to use that as your exported resource and collect it different times.

edit flag offensive delete link more

Comments

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 -0500 )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

Stats

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

Seen: 25 times

Last updated: Feb 10