Adopting Hiera means that a user can control the specific data that a module uses
Adopting Hiera means that a user can control the specific data that a module uses from a seperate config file. The puppet-common module takes this one step further: you can control which modules a node uses from Hiera.
The module is available on GitHub at the link below:
https://github.com/ghoneycutt/puppet-module-common
By default all of the included modules are turned off since you may not have them. If you do the common include at the site level, you then can use Hiera to turn toggle the modules you need.
The base hiere.yaml file that I am using in this example is below. This file is generally located in /var/lib/hiera
---
:backends:
- yaml
:hierarchy:
- fqdn/%{fqdn}
- %{clientcert}
- %{environment}
- common
:yaml:
# datadir is empty here, so hiera uses its defaults:
# - /var/lib/hiera on *nix
# - %CommonAppData%\PuppetLabs\hiera\var on Windows
# When specifying a datadir, make sure the directory exists.
:datadir:
The line containing fqdn means Hiera will look for a subdirectory in the Hiera configuration directory that contains files in the format of (fully qualified domain name).yaml. The last entry common points to the common.yaml file.
The common.yaml file is listed below.
common::enable_ntp: true
common::enable_hosts: false
common::enable_dnsclient: false
ntp::servers:
- timeserver0.noedu.edu
- timeserver1.noedu.edu
As you can see in it, NTP has been enabled and the NTP servers have been set to timeserver0 and 1.
The machine specialmachine1.noedu.edu needs to use a different set of servers. The file fqdn/specialmachine1.noedu.edu looks like the following:
common::enable_ntp: true
ntp::servers:
- timeserver2.noedu.edu
- timeserver3.noded.edu
Since the fqdn is listed before the common, specialmachine1 will use these settings for NTP instead of the common ones.