infrahub-managing-transforms

Creates Infrahub transforms converting GraphQL data into JSON, CSV, or device configs via Python or Jinja2.

9|2|Updated Aug 27, 2025
One-click install
npx skills add https://github.com/opsmill/infrahub-solution-ai-dc --skill infrahub-managing-transforms-opsmill
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: infrahub-managing-transforms
Source: https://github.com/opsmill/infrahub-solution-ai-dc/tree/main/.agents/skills/infrahub-managing-transforms
Command: npx skills add https://github.com/opsmill/infrahub-solution-ai-dc --skill infrahub-managing-transforms-opsmill

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires infrahub-sdk, jinja2, netutils, and includes references (resource) components.

What problem does it solve? Writing Infrahub transforms involves subtle conventions — query binding, registration keys, content-type matching, and artifact wiring — where small mistakes surface late as silent empty artifacts or "transformation not found" errors at render time. ## Core Features & Use Cases - Python and Jinja2 Transform Authoring: Guides creation of InfrahubTransform subclasses, pure Jinja2 templates, and hybrid Python-plus-template patterns with correct .infrahub.yml registration. - Artifact Pipeline Integration: Connects transforms to artifact_definitions with correct content_type, targets, and parameter mapping, including async regeneration polling. - YAML-Driven Testing: Adds smoke, unit, and integration tests using the Resources Testing Framework with fixture-based input/output validation. - Use Case: Generate per-vendor device startup configs (Cisco, Arista, Juniper) from a single GraphQL query by building a hybrid transform that selects platform-specific Jinja2 templates. ## Quick Start Ask the assistant to create an Infrahub transform that renders device configurations from a GraphQL query and register it in .infrahub.yml.

Frequently Asked Questions about infrahub-managing-transforms

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create an Infrahub transform in Python?▼

Subclass InfrahubTransform from infrahub_sdk.transforms, set the query class attribute to a named query in .infrahub.yml, and implement transform() to return a dict or str. Register the class under python_transforms with its file_path and class_name.

When should I use a Jinja2 transform instead of a Python transform?▼

Use Jinja2 when the output is text formatting with minimal logic, such as device configs or topology files. Use Python when you need computation like IP math, data reshaping, or platform-based template selection.

Why does my Infrahub transform return None or empty data?▼

The query class attribute likely does not match any query name registered in .infrahub.yml, so collect_data() skips silently and transform() receives None. For Jinja2 transforms, a missing top-level query field causes the template to render against empty data.

What content_type values does Infrahub support for artifacts?▼

Infrahub enforces a fixed enum of eight values including text/plain, text/csv, application/json, application/yaml, application/xml, application/hcl, text/markdown, and image/svg+xml. Note that text/yaml is rejected; use application/yaml instead.

How do I test Infrahub transforms locally?▼

Run infrahubctl transform for Python transforms or infrahubctl render for Jinja2 templates against a live server. You can also define YAML-driven smoke, unit, and integration tests with JSON fixtures using the Resources Testing Framework.

Why is my Ansible Jinja2 filter not working in Infrahub templates?▼

The Infrahub SDK builds its Jinja2 environment from an explicit AVAILABLE_FILTERS allowlist plus netutils filters, so Ansible filters like regex_replace or to_nice_yaml fail with 'No filter named' errors. Use the hybrid pattern with Python preprocessing instead.