Module data with YAML data files
You can also manage your module's default data with basic Hiera YAML files,
Set up a hierarchy in your module layer hiera.yaml file:
# ntp/hiera.yaml
---
version: 5
defaults:
datadir: data
data_hash: yaml_data
hierarchy:
- name: "OS family"
path: "os/%{facts.os.family}.yaml"
- name: "common"
path: "common.yaml"
Then, put the necessary data files in the data directory:
# ntp/data/common.yaml --- ntp::autoupdate: false ntp::service_name: ntpd # ntp/data/os/Debian.yaml ntp::service_name: ntp
You can also use any other Hiera backend to provide your module’s data. If you want to use a custom backend that is distributed as a separate module, you can mark that module as a dependency.
For more information, see class inheritance, conditional logic, write functions in the Puppet language, hash merge operator.
Related information