Creating your default Jerakia policy

All requests for data from Jerakia are processed according to the so-called policy. The filenames for policies should be the same as the actual name of the policy, and are loaded from the directory indicated by the policydir setting in your jerakia.yaml configuration file. If a certain policy name is not indicated by the lookup request, then the name default is used. Let's create the default policy, as follows:

$ mkdir /etc/jerakia/policy.d
$ vim /etc/jerakia/policy.d/default.rb

A Jerakia policy is a container of the so-called lookup, which is performed in the indicated order. A lookup consists of a datasource that should be used for the data lookup, along with any plugin functions.

There follows a simple example, using the file data source to provide data from simple YAML files:

policy :default do

lookup :default do
datasource :file, {
:format => :yaml,
:docroot => "/var/lib/jerakia",
:searchpath => [
"hostname/#{scope[:fqdn]}",
"environment/#{scope[:environment]}",
"common",
],
}
end

end

Let's change the default policy to accommodate settings for another configuration team, based in, let's say, denmark:

policy :default do

lookup :denmark do
datasource :file, {
:format => :yaml,
:docroot => "/var/external/data/ie",
:searchpath => [
"project/#{scope[:project]}",
"common",
]
}

confine scope[:location], "dk"

confine request.namespace[0], [
"apache",
"php",
]
stop

end

lookup :default do
datasource :file, {
:format => :yaml,
:docroot => "/var/lib/jerakia",
:searchpath => [
"hostname/#{scope[:fqdn]}",
"environment/#{scope[:environment]}",
"common",
],
}
end

end

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.89.30