Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

What is a good way of retrieving/caching external facts from a database using facter?

All of our servers have attributes that we store in a database and I'd like to make these attributes available locally on each server for use by Puppet (particularly in Hiera). I don't want facter to query the database each time facter is run, though, so using a facter executable script is probably not what I'm looking for.

I'm wondering if I should create a Puppet exec resource in my base module (that is used by all systems) that will query the database and store the values in /etc/puppetlabs/facter/facts.d/vars.yaml or something.

Does this sound like a reasonable approach?

Trying to convert our shop into using Puppet so any help would be greatly appreciated!

What is a good way of retrieving/caching external facts from a database using facter?

All We currently store all of our servers have attributes that we store systems in a database and I'd table, along with some user-defined attributes, such as the system's location. I would like to make use these attributes available locally on each server variables in our Hiera hiearchy so that we can use, for use by Puppet (particularly in Hiera). example, location specific variables within the hierarchy.

:hierarchy:
- "/node/%{::nodename}"
- "/location/%{::location}"
- "common"

So, it appears I don't want facter need to query retrieve these variables from the database each time and put them into facter is run, though, so using a facter executable script is probably somehow. I'm just not quite sure what I'm looking for.the "best" way to do this would be.

I'm wondering if If I use custom facts, I could run a CLI command to query the database, get the values, and put them into facter variables. Would this be a good approach? Is there some other "best practice" I should create a Puppet exec resource in my base module (that is used by all systems) that will query the database and store the values in /etc/puppetlabs/facter/facts.d/vars.yaml or something.

Does this sound like a reasonable approach?

Trying to convert our shop into using Puppet so any help would be greatly appreciated!use?