
Extending Puppet
By :

The data stored in Hiera can be retrieved by the Puppet Master while compiling the catalog using the Hiera functions. In our manifests, we can have something like the following:
$dns_servers = hiera("dns_servers")
Note that the name of the Puppet variable need not be the same as the Hiera one, so the preceding command can also be something like this:
$my_dns_servers = hiera("dns_servers")
This assigns the top value to the $my_dns_servers
variable (the first one found while crossing the hierarchy of data sources) retrieved by Hiera for the key dns_servers
.
We can also merge arrays and hashes here, so, in order to retrieve an array of all the values in the hierarchy's data sources of a given key and not just the first one, we can use hiera_array()
:
$my_dns_servers = hiera_array("dns_servers")
If we expect a hash value for a given key, we can use the hiera()
function to retrieve the top value found, or hiera_hash()
to merge all the found values...
Change the font size
Change margin width
Change background colour