Skip to main content

hegemony-inventory-git

Git-backed YAML inventory provider for Hegemony. Reads devices and sites from plain YAML files in a Git repository you already manage, and feeds them into the core inventory.

It is an out-of-tree plugin: it depends only on hegemony-inventory-sdk and is discovered at runtime via the hegemony.inventory_plugins entry-point group (git = "hegemony_inventory_git:register").

Install

Provider wheels are opt-in — they are not bundled in the default images. The package is on PyPI (uv pip install hegemony-inventory-git==X.Y.Z or pip install hegemony-inventory-git==X.Y.Z); each GitHub Release also carries the same wheel, the sdist, SHA256SUMS and the SLSA provenance bundle. See the root Install From A Release guide for Docker commands, checksum and attestation verification, and local-wheel development installs.

How it works

The Git provider reads inventory files from a Git checkout. You first register a Git repository under Settings → Git Repositories (URL + branch + credentials), and the Git inventory provider then points at a directory inside that repository. The repository fetch, credentials, caching, and SSRF protection are all handled by the platform's existing Git machinery — the plugin only parses the YAML it is handed.

Configure

Create a git inventory provider (Settings → Inventory Providers, or POST /inventory/providers). The form is schema-driven; git_repo_id renders as a dropdown of the Git repositories you have added.

Field Required Default Notes
git_repo_id yes — The configured Git repository to read from (Settings → Git Repositories)
branch no main Branch to read
path yes — Repo-relative path to the inventory directory (the one containing sites/ and devices/)
default_access_config no {} Access-config defaults applied to every device
refresh_strategy no cache_ttl Cache strategy (currently the only value)

Example config:

{
  "git_repo_id": "<uuid of a configured Git repository>",
  "branch": "main",
  "path": "inventory"
}

Inventory file structure

path points at a directory. Inside it, sites and devices live in their own subdirectories, one record per file:

<path>/
  sites/
    emea/
      emea.yaml             # parent/root site "emea"
      nl/
        nl.yaml             # nested parent site "emea/nl"
        ams01.yaml          # leaf site "emea/nl/ams01"
  devices/
    <external_id>.yaml      # one device per file; file stem MUST equal external_id
    ...

Rules enforced by the loader (fail-closed — any error rejects the whole sync):

  • Files use .yaml or .yml; each is a single YAML document (no multi-doc).
  • The loader scans sites/ recursively. A site file's stem must equal its local external_id; a device file's stem must equal its external_id. Duplicate full site paths, duplicate device external_ids, and duplicate YAML keys are rejected.
  • Symlinked files/directories are not allowed, and path may not escape the repository.
  • A site with children is represented as <external_id>/<external_id>.yaml; a leaf site may stay as <external_id>.yaml directly under its parent directory.
  • The site's full external_id is derived from its path. Examples:
    • sites/emea/emea.yaml → emea
    • sites/emea/nl/nl.yaml → emea/nl
    • sites/emea/nl/ams01.yaml → emea/nl/ams01
  • Devices reference sites by that full derived path (for example emea/nl/ams01); unknown site references and missing parent sites are rejected.
  • Duplicate local site ids or names are allowed in different branches because the full path is the unique identity.

A ready-to-copy example lives in examples/ (two devices + three nested sites). Copy its contents into your repository and set path to wherever you put it.

Site fields (sites/.../<external_id>.yaml)

Field Required Default Notes
schema_version yes — must be 1
kind yes — must be site
external_id yes — stable id for the current path segment; must equal the file stem
name yes — site name
description no — human-readable description
location no — address or location summary
tags no {} key/value tags stored on the site
custom_fields no {} free-form metadata exposed as safe descriptive data

The provider derives the site's full external_id and parent_external_id from the nested path, so those values are not written into the YAML.

Device fields (devices/<external_id>.yaml)

Field Required Default Notes
schema_version yes — must be 1
kind yes — must be device
external_id yes — stable id; must equal the file stem
name yes — device name
mgmt_host yes — management IP or hostname
mgmt_port no (core default) omit to let the core inventory service fill its default (22); range 1–65535
platform no (core default) omit to let the core inventory service fill its default
attributes no {} Inventory facts, e.g. vendor, model, and current_version
site no — full derived site path, for example emea/nl/ams01
role no —
tags no [] list of strings
access_config no {} ssh / enable secret references (see below)
custom_fields no {} free-form metadata

access_config carries secret references, never raw credentials:

access_config:
  ssh:
    username_ref: "{{ secret('vault://devices/ssh-username') }}"
    password_ref: "{{ secret('vault://devices/ssh-password') }}"
    private_key_ref: "{{ secret('vault://devices/ssh-key') }}"
  enable:
    password_ref: "{{ secret('vault://devices/enable-password') }}"

An old device that supports only weak SSH algorithms or small keys can say so itself, so no step has to:

access_config:
  ssh:
    allow_legacy_ssh: true

The flag covers connections to that device only. A jump host has its own (access_config.jump_host.allow_legacy_ssh), so an old device does not weaken its jump host. It must be true or false, not text. Hegemony still checks the host key, offers every secure algorithm first, and warns in the run when the device did not need the flag. Use it only while the device is being upgraded.

Walkthrough

  1. Add your inventory repository under Settings → Git Repositories (URL, branch, credentials).
  2. Put the examples/ tree (or your own) into that repo, e.g. under inventory/.
  3. Create a git inventory provider: pick the repository, set branch, and set path to inventory.
  4. Run a sync. Devices and sites appear in the inventory; missing platforms get the core default.

Supported object types

device, site.

Adding an object type

Object types are extended in code (edit + release the wheel). The Git provider reads YAML, so a new type means parsing additional files/fields from the repo and mapping them with the SDK helper:

from hegemony_inventory_sdk import ObjectFieldMapping, map_records

_VLAN = ObjectFieldMapping(
    object_type="vlan",
    identity="external_id",
    name_field="name",
    field_map={"vid": "vid", "description": "description"},
)
# In list_objects("vlan", ...): load the records (e.g. from a vlans/ directory),
# then `return map_records(records, _VLAN, provider_id=self.id)`.

Register the type with register_object_type(ObjectTypeSpec(...)) and add its id to supported_resources. After installing the new wheel version and restarting, it appears in the inventory submenu with schema-driven list/detail pages — no core change, no migration.

Generic object types

See Generic Git inventory objects for declarative type definitions, attributes, relationships, discovery, synchronization, and cascading flow inputs.

Metadata

Release files for hegemony-inventory-git 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hegemony-inventory-git 0.6.1
File Size Uploaded Provenance Actions
hegemony_inventory_git-0.6.1.tar.gz 32.8 kB With provenance Details for hegemony_inventory_git-0.6.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hegemony-inventory-git 0.6.1
File Interpreter ABI Platform Actions
hegemony_inventory_git-0.6.1-py3-none-any.whl Python 3 none any Details for hegemony_inventory_git-0.6.1-py3-none-any.whl

Total release size: 67.9 kB

Release files / hegemony_inventory_git-0.6.1.tar.gz

Download URL hegemony_inventory_git-0.6.1.tar.gz
Size 32.8 kB
Tags Source
SHA-256 checksum
How to use checksums
68417fb6e07d9c22f9ad2aeb9743026c697d3a18845933073b8b20f72f8a7e9a
BLAKE2b-256 checksum
How to use checksums
ac0df021068273bfbc6fd1a217f50c72ce781ae048ac246390b19c4b2ea2e00a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / hegemony_inventory_git-0.6.1-py3-none-any.whl

Download URL hegemony_inventory_git-0.6.1-py3-none-any.whl
Size 35.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7353d49c4a8decaffa73e34975ca9b0e87a469c6f8e3dab7a84eb4a4c07348c9
BLAKE2b-256 checksum
How to use checksums
adf1aae479ee0638f056ffcd5e9715ab405c662b77f59fa639471043ee6cb039
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for hegemony-inventory-git 0.6.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for hegemony_inventory_git-0.6.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page