A versatile data lookup system
Using the file
datasource as configured earlier we can add our data to YAML files under the directory specified in :docroot
, which we set to /var/lib/jerakia
It’s recommended that you read Jerakia Lookup Basics to understand the structure and behaviour of a Jerakia lookup
When using the file
datasource, the :searchpath
is evaluated to determine which files to scan and elements of the scope object can be interpolated into the file paths. By default, Jerakia will search for the key in a filename corresponding to the namespace. So, lets review our lookup object from earlier, it has the following settings configured…
:format => :yaml,
:docroot => "/var/lib/jerakia",
:searchpath => [
"hostname/#{scope[:fqdn]}",
"environment/#{scope[:environment]}",
"common"
]
If our scope contains the following
"environment" => "development",
"fqdn" => "host011.example.com"
Then when we search for the key port
in the apache
namespace (eg: apache::port) then Jerakia will scan the following files until it encounters the key port:
/var/lib/jerakia/hostname/host011.example.com/apache.yaml
/var/lib/jerakia/environment/development/apache.yaml
/var/lib/jerakia/common/apache.yaml
The astute among you might have noticed that the search is done in a common
directory rather than common.yaml
as you would expect with hiera. To understand why that is the case read File datasource, to explain the functioning and differences between hiera and jerakia. To get the above debug output yourself read the Debug Guide
Let’s start off by adding the port value to our searchpath
$ mkdir -p /var/lib/jerakia/common
$ vim /var/lib/jerakia/common/apache.yaml
---
port: 8080