Skip to content

Nike-Inc/phiera

Repository files navigation

Phiera

codecov Test PyPi Release License Python Versions Python Wheel

Phiera is a fork of Piera, a lightweight, pure-Python Hiera parser. Piera was originally built to provide Python tooling access to Puppet/Hiera configurations. The original Piera is currently not feature complete; lacking some less-used interpolation and loading features.

Table of content

Why?:

Piera/Phiera generalizes Puppet Hiera's hierarchical storage system; making a simple, very flexible, abstracted, and DRY mechanism for managing complex configuration data available to a broad set of tooling and applicable to a broad set of problems.

Phiera builds on the original Piera work, adding:

  • Python3 compatibility
  • Support for deep merging
  • Support for configuration as a dict

Installation:

From PyPi:

pip install phiera

From GitHub:

pip install git+https://github.com/Nike-Inc/phiera#egg=phiera

Manually

git clone [email protected]/Nike-Inc/phiera.git
cd phiera
poetry install

Usage:

import phiera

h = phiera.Hiera("my_hiera.yaml")

# You can use phiera to simply interact with your structured Hiera data

# key: 'value'
assert h.get("key") == "value"

# key_alias: '%{alias('key')}'
assert h.get("key_alias") == "value"

# key_hiera: 'OHAI %{hiera('key_alias')}'
assert h.get("key_hiera") == "OHAI value"

# Give phiera context
assert h.get("my_context_based_key", name='test01', environment='qa') == "context is great!"

Unit Tests:

poetry run pytest --cov-report=html --cov=phiera --cov-fail-under=80 tests/