The file data source performs hierarchical searches across YAML or JSON formatted files and searches for the lookup key
:formatThe file format, one of :yaml and :json (other formats are pluggable)
:docrootThe root of the documents
:searchpathAn array specifying the order of hierarchical lookups. Entries starting with an alphanumerical character will be relative from
docroot, paths starting with
/will be absolute.
:extensionOverrides the default extension (eg: yml) for the file format chosen
:enable_cachingtrue or false, whether to cache the contents of files
Jerakia requests consist of a lookup key and an array representing the namespace. By default the file data source will look for the lookup key in a filename based upon the
namespace. For example if we use the above lookup directive with the following request:
Assuming the scope has
certname => foo.acme.com and
environment => development then Jerakia will search for the key
port in the following order
More than one element used in the namespace will just expand the filesystem hierarchy, for example
:namespace => [ "profile", "web" ] will result in something like
Hiera maps lookups to file paths slightly differently by default. If you are performing a lookup for
apache::port from Puppet, Hiera will normally search for the key
apache::port in a file corresponding to the hierarchy. Jerakia searches for the lookup key
port, in the namespace
apache and therefore will look for the key in
This is illustrated here;
Users migrating from Hiera to Jerakia or just looking to test Jerakia on their existing Hiera filesystem layout can use the hiera plugin to make the lookup rewrite the request so it gets searched in a hiera-style way.
A useful feature of Jerakia is the ability to break down your document into multiple files, especially where a file is becomming excessivly large. The fragments feature was introduced in 0.4.0 and searches for a .d directory matching the full pathname (minus extension) to your data file. If found, Jerakia will concatenate the contents of all files below the .d directory into one document before sending it to the format handler.
So in this example;
Jerakia will first scan the
apache.yaml file, then traverse into the directory and concatenate (in alphabetical order) all the files encountered into one YAML document. That means you can use YAML anchors across multiple files within the scope of the fragments as the YAML parser will only get one document. Note that the
apache.yaml file will always be parsed and included first.