For the past few days, i was playing with hiera-puppet
. I strongly wanted to use hiera
in my puppet modules. Yesterday i was going through craigdunn’s blog, there i saw his new blog post about thehiera-http
,a Hiera back end to connect to any HTTP RESTful API and return data based on a lookup.hiera-http
is available as a rubygem or from craigdunn’s Github page. In his blog he has clearly explained how he uses hiera-http
to query data from couchdb
. Since i’m a fan of Riak, i wanted to try the same from Riak.
I used the riak-ruby-client to pass my json data to Riak. Below is a simple ruby script which i used,
#! /usr/local/bin/ruby
require 'rubygems'
require 'riak'
client = Riak::Client.new(:host => '192.168.1.120', :http_port => 8098)
bucket = client.bucket("hiera_bucket")
deb = Riak::RObject.new(bucket, "Debian")
deb.content_type = "application/json"
deb.data = { "db_name" => "testdb", "db_pass" => "P@ssw0rd" }
deb.store
where hiera_bucket is the name of the Bucket and Debian is the key.
Now we need to create a hiera.yaml
,
:backends:
– http
:http:
:host: 192.168.1.120
:port: 8098
:output: json
:failure: graceful
:paths: /riak/hiera_bucket/Debian
We can test the working using hiera cli hiera-c hiera.yaml db_name
As per the hiera-http
dcumentation, we can use the facter variables, so the path can be :paths: /riak/hiera_bucket/%{operatingsystem}
. For those who wants a gui for Riak, i prefer rekon. It’s very simple to install and configure, also we can edit our values directly using this.