dalen / puppet-puppetdbquery

Query functions for PuppetDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can I use puppetdbquery to return fqdn of one node as string?

toepi opened this issue · comments

commented

I've a database server (Class[databaseserver]), now I need the fqdn of this node to configure different clients which use a string to configure the host of the database. Best sample is the puppetlabs puppetdb module which do it in this way.

If I try:

puppetdb::master::config::puppetdb_server::_puppetdbquery: 'Class[daabaseserver]'

puppetdb module write to syslog:

can not connect to [fqdn-of-dbhost]:8081

because fqdn is in an array instead of a string.

A workaround replace string with an array but than I must think at modules level 'Can I use puppetdb query to get this value'. And create 'wrapper' to convert array to string.

At the moment you would have to create a small wrapper class to pick the first value from the array. Or do something like this in the node definition:

class { 'puppetdb::master::config':
  puppetdb_server => query_nodes('Class[databaseserver]')[0]
}
commented

Thanks @dalen,

Any future plan to support this kind of usecase in hiera?

Not really, no. The main purpose of hiera was to separate code and data, and if you put too much functionality for data transformations and functions and stuff into hiera it too becomes "code" really. Eventually you would end up needing a hiera-lint.