Search code examples
chef-infraconsul

Use consul key value store instead of chef databags?


I've tried googling for this but I can't seem to find anything on using consul's kv store instead of chef's databags. Does anyone have any suggestion on how this can be done? Is it a bad idea? I've found 'consul_kv' cookbook but it's for setting and deleting kv pairs in consul from chef. I'm looking for a way to read kv pairs from consul instead of using chef attributes and databag items.


Solution

  • I mean you just do it. Use any of the Ruby Consul client libraries that exist (install via either a gem line in the metadata.rb or a chef_gem resource). Because Chef is just plain old Ruby under the hood, you don't need to do anything special. Make sure you are careful about Chef's two-pass loading model so you don't try to connect to Consul before it is installed/available, but otherwise just like any other Ruby code.