lynxman / hiera-consul

Hiera backend plugin for Consul
Apache License 2.0
96 stars 36 forks source link

How to support multiple Consul Data Centres #15

Open fatmcgav opened 8 years ago

fatmcgav commented 8 years ago

I'm currently implementing a platform whereby we're levering Consul for SD and Puppet for automation, and have a challenge whereby the PuppetMaster sits in one Consul DC (e.g CoreSVCs), and I'm trying to query for Consul registered services in another DC (e.g StgSVCs).

Currently, hiera-consul queries the 'agents' DC, in this case that of the PuppetMaster...

The HTTP API supports querying other DC's by passing a ?dc= query param...

Before I dive in and try and implement something in hiera-consul, I wanted to find out whether other people would have a use for this functionality, how best to support it etc...

Thoughts?

Cheers Gavin

fatmcgav commented 8 years ago

OK, after a bit of testing, it looks like appending the query param to the lookup works...

e.g.

$mongo_nodes = hiera('mongodb?dc=StgSVCs', [])

So the question then becomes, is this sufficient support?

lynxman commented 8 years ago

Hi, It's a way to do it, another way would be to add a helper function to iterate through the results :) Would that be useful for you?

fatmcgav commented 8 years ago

@lynxman The above is sufficient for my needs.

However a helper function that allows a wider range of options, such as filtering for multiple DC's, might make sense...

lynxman commented 8 years ago

Cool, will add it to my todo