hyera
A small, dependency-light Python implementation of Puppet
Hiera hierarchical data
lookup. It reads a Hiera base config, walks the hierarchy for a given context,
and fully resolves values — including %{...} interpolation and the
hiera/lookup/scope/literal/alias functions — with optional array,
hash, and deep-hash merging. The PyPI distribution, the import package and
the command are all named hyera; Hiera is the class it exports.
Installation
pip install hyera
Extras add optional features:
pip install "hyera[cli]"
| Extra | Adds | Needed for |
|---|---|---|
cli |
duho |
the command-line tool |
hocon |
pyhocon |
hocon_data levels |
eyaml |
cryptography |
eyaml_lookup_key (PKCS7) levels |
30-second tour
# hiera.yaml
---
version: 5
defaults:
datadir: data
data_hash: yaml_data
hierarchy:
- name: "Per-environment"
path: "environments/%{environment}.yaml"
- name: "Common"
path: "common.yaml"
# data/common.yaml
ntp::servers:
- 0.pool.ntp.org
classes:
- base
# data/environments/production.yaml
ntp::servers:
- ntp1.prod.example.com
classes:
- monitoring
# facts.yaml
role: web
>>> from hyera import Hiera, Scope
>>> h = Hiera("hiera.yaml", scope=Scope(environment="production"))
>>> h.lookup("ntp::servers")
['ntp1.prod.example.com']
>>> h.lookup("classes", merge="unique")
['monitoring', 'base']
$ python -m hyera classes --hiera_config hiera.yaml --facts facts.yaml --environment production --merge unique --render-as json
["monitoring","base"]