Chapter 6. Hiera Data
Hiera is a multilayered, hierarchical key/value lookup system for Puppet that provides data used to inform the code. In this chapter, we look at best practices for configuring Hiera backends, designing your hierarchy, and integrating Hiera into your Puppet code. We briefly review the features and functionality of Hiera before covering best practices.
Separating Code and Data
Hiera’s most important capability and its greatest value come from its ability to separate your code and data. Separation of code and data is a fairly old idea as far as programming goes. You generally cannot use code that contains data without modification, whereas code that acts based on input data can be utilized repeatedly for different purposes. This abstraction makes it possible to assemble functionality from many reusable components rather than building a large monolithic codebase with a single purpose.
Conversely, the structure and storage of data is a well-studied and understood subject. There are frameworks and skill sets devoted to data management. Separating the code from the data allows the developer to focus on the code and data specialists to focus on data management.
There are many different guidelines and rules, but we’ve use the following three simple and easy baselines for clarity. When considering where some information belongs, compare it to these guidelines:
-
Information that differs for each resource (user name, UID, etc.) is data.
-
Code describes how to do something, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access