I have some data whose source-of-truth is in a MySQL database, size is expected to max out at the some-thousands-rows range (in a worst-case scenario) and I'd like to use puppet to configure files on some servers with that data (mostly iterating through those rows in a template).
I'm currently using Puppet 3.0.x, and I cannot change the fact that MySQL will be the authoritative source for that data. Please note, data comes from external sources and not from puppet or from the managed nodes.
What possible approaches are there? Which one would you recommend?
Would External Node Classifiers be useful here?
My "last resort" would be regularly dumping the table to a YAML file and reading that through Hiera to a Puppet template, or to directly dump the table in one or more pre-formatted text file(s) ready to be copied to the nodes.
There is an unanswered question on SF about system users but the fundamental issue is probably similar to mine - he's trying to get data out of MySQL.
I go even further and have a MySQL db that's authoritative for all server data (it's a django app actually). Here's how I integrate them:
Node definitions
There are two possibilities. We currently use a generated manifest, that's included from site.pp containing entries like:
}
But soon-ish we need to switch this to an ENC as puppet doesn't support this anymore. The ENC is already written and uses almost the same template.
Server data
Some recipes, like our DNS master recipe, need extra data about servers. Like you suggest, this is done in templates. Here's an example of one such template: named.conf which needs to know all secondary nameservers. It simply uses the mysql gem to get to the database. The database structure is irrelevant of course, but a complete example is usually nice :)
You could also use hiera-mysql backend. If you see the source for this backend, you can see it is easy to create a new one, or customize this one. Using hiera like this, will make your template/manifest code cleaner, than using the approach suggested by Dennis (which also works finel)