crayfishx/hiera-mysql — pull request #7 by alexjfisher (2013-06-11 15:40:36+00:00)
Title: Provide a way to filter hiera-mysql lookups.

Hi
I've modified hiera-mysql to include the capability of filtering which queries get executed based on a regular expression that must match the key to be looked up.

Why did I do this?

I was thinking of using the hiera-mysql backend to lookup some data directly from my zabbix backend database.

As such, I use a query like

:query: select host from hosts where hostid = (SELECT proxy_hostid from hosts where host='%{hostname}') and 'zabbix::agent::server'='%{key}'

This works, but the database gets all lookups including queries it will never return values for. (ie where key != zabbix::agent::server)

I've not written/touched any ruby before, so sorry for the code quality of my patch! :(

Kind Regards,
Alex