dalen / puppet-puppetdbquery

Query functions for PuppetDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to return hash rather than array from hiera

claflico opened this issue · comments

Am trying to make use of this hosts module via hiera: https://forge.puppetlabs.com/ghoneycutt/hosts

Specifically the following method:
hosts::host_entries:
'servicename.example.com':
ip: '10.0.0.5'
host_aliases:
- 'servicename'

Here is my attempt using puppetdbquery:
hosts::host_entries::_nodequery:
query: 'location=corp and tier=dev'
fact: 'ipaddress'

And this is the output I'm getting on a node:
"Could not retrieve catalog from remote server: Error 400 on SERVER: ["10.0.0.28"] is not a Hash. It looks to be a Array at...."

Any suggestions? I'd prefer to set the query via hiera as my role/profile manifests are very generic and hiera dependent.

the nodequery can only give an array of either certnames or the specified fact.
If you need to do anything more special like that you likely have to do a wrapper class and use the query_nodes function. Possibly combined with the map and reduce functions from future parser/puppet 4.x to transform it to the desired format.