The three pillars
Infrahub’s architecture rests on three fundamental pillars that enable its unique approach to infrastructure management:Flexible schema
- Fully customizable: Define any node type, attribute, or relationship your infrastructure needs
- Version controlled: Schema changes are tracked in branches and can be tested before merging
- YAML-based: Easy to read, write, and manage in Git alongside your code
- Self-documenting: Schema definitions include labels, descriptions, and validation rules
Schema components
A schema consists of:- Nodes: The primary objects in your infrastructure (e.g., Device, Site, VLAN)
- Attributes: Properties of nodes (e.g., name, IP address, status)
- Types: Text, Number, Boolean, Dropdown, JSON, DateTime, URL, etc.
- Validation: Unique, optional, regex patterns, min/max values
- Relationships: Connections between nodes
- Attribute relationships: Simple foreign keys (many-to-one)
- Component relationships: Parent-child with cascading deletion
- Generic relationships: Many-to-many associations
- Hierarchy relationships: For modeling organizational structures
Example schema
- GraphQL mutations for creating/updating devices
- UI forms for data entry
- Validation rules
- Database indexes
Create a Schema
Step-by-step guide to defining your own schema.
Schema Topic
Deep dive into schema design and capabilities.
Version control
Branching and merging
Create isolated branches to:- Test schema changes without affecting production
- Stage infrastructure updates for review
- Experiment with network designs
- Prepare changes for maintenance windows
- Web UI: Click “Create Branch” from any page
- GraphQL API:
BranchCreatemutation - CLI:
infrahubctl branch create
Proposed changes
A proposed change is similar to a pull request in Git. It provides:- Diff view: See exactly what will change when merging
- Comments and threads: Collaborate on changes with your team
- Reviews and approvals: Require sign-off before merging
- CI checks: Run automated validation and artifact generation
- Conflict detection: Identify conflicts before merging
Immutable history
Infrahub’s storage engine is immutable: every change creates a new version, preserving the complete history. You can:- Query the state of your infrastructure at any point in time
- Track who made what changes and when
- Audit compliance and troubleshoot issues
- Restore previous states if needed
Version Control Topic
Learn about branching, merging, and proposed changes.
Branching Topic
Understand how branches work in Infrahub.
Unified storage
Infrahub combines graph database (for data) with Git (for code) to provide unified storage for everything needed to manage infrastructure.Graph database foundation
Infrahub uses Neo4j, a production-grade graph database, to store infrastructure data. The graph model enables:- Rich relationships: Model complex dependencies between infrastructure components
- Fast traversals: Query relationships efficiently (e.g., “find all devices in site X with status Y”)
- Natural modeling: Infrastructure is inherently a graph (devices connect to interfaces, which connect to VLANs, etc.)
- Temporal branching: Version control is implemented directly in the graph structure
Git integration
Infrahub syncs with Git repositories to store:- Schema definitions: Your data model in YAML
- Transformations: Jinja2 templates and Python code to generate configurations
- Generators: Python code to automate object creation
- GraphQL queries: Reusable queries for data retrieval
- Python scripts: Custom automation and integrations
- Version control for code and data: Both evolve together in branches
- GitOps workflows: Treat infrastructure as code
- Collaboration: Use Git workflows for code review and collaboration
Architecture Topic
Deep dive into Infrahub’s technical architecture.
Repository Guide
Connect a Git repository to Infrahub.
Key capabilities
Transformations
- Device configurations: Generate vendor-specific configs from unified data
- Documentation: Create network diagrams, cable plans, runbooks
- API payloads: Transform data for external systems (CloudFormation, Terraform, etc.)
- Reports: Generate compliance or inventory reports
How Transformations work
A Transformation consists of:- GraphQL query: Defines what data to retrieve
- Transformation logic: Jinja2 template or Python class that processes the data
Transformation Topic
Learn about Jinja2 and Python transformations.
Jinja2 Transform Guide
Create your first Jinja2 transformation.
Artifacts
Artifacts are the output of Transformations, stored in Infrahub’s object storage. Artifacts provide:- Version tracking: Each artifact has a version tied to a branch and commit
- Storage: Stored in local filesystem or S3-compatible object storage
- Access control: Artifacts can be retrieved via REST API or webhooks
- Change detection: Compare artifacts across branches or over time
- Store generated device configurations
- Trigger deployments via webhooks
- Archive compliance snapshots
- Provide audit trails
Generators
Generators automate the creation of infrastructure objects based on templates and business logic. They enable design-driven automation:- Define a high-level design (e.g., “Deploy a new site”)
- Generator creates all necessary objects (devices, interfaces, IP addresses, BGP peers)
- Transformations generate configurations
- Review and merge in a proposed change
- Create complex object hierarchies
- Implement business logic and policies
- Allocate resources from pools (IP addresses, VLANs, ASNs)
- Link generated objects back to the design for lifecycle management
- Provision a new data center site
- Deploy a new service instance
- Onboard a new customer
- Roll out a new device type
Generator Topic
Understand how Generators work.
Generator Guide
Create your first Generator.
Resource pools
Resource Manager provides pools for allocating finite resources:- IP Prefixes and Addresses: RFC 1918 and public IP space
- VLANs: 802.1Q VLAN IDs
- ASNs: BGP autonomous system numbers
- Number pools: Generic integer allocation
- Namespaces: Isolate allocations by region, tenant, or environment
- Hierarchical allocation: Allocate subnets from parent prefixes
- Automatic allocation: Request next available resource
- Conflict detection: Prevent overlapping allocations
Interfaces and APIs
Web UI
The web interface provides:- Object management: Create, read, update, delete objects
- Schema explorer: Browse loaded schema and relationships
- Branch management: Create branches, view diffs, merge changes
- GraphQL sandbox: Test queries and mutations interactively
- Global search: Find objects, documentation, and schema elements
- Proposed change workflows: Review, comment, approve changes
GraphQL API
The GraphQL API is the primary programmatic interface. It provides:- Schema-driven: Automatically generated from your schema
- Strongly typed: Type-safe queries and mutations
- Flexible querying: Request exactly the data you need
- Relationship traversal: Query across relationships efficiently
- Metadata access: Query created_by, updated_by, timestamps
Python SDK
The Infrahub Python SDK simplifies programmatic access:- Object-oriented interface for creating and querying data
- Schema introspection and validation
- Batch operations for performance
- Async support for concurrent operations
REST API
The REST API provides endpoints for:- Schema loading and retrieval
- Artifact access and download
- Object storage operations
- Saved GraphQL query execution
http://localhost:8000/api/docs
Integrations
Infrahub integrates with popular automation tools:- Ansible: Use Infrahub as a dynamic inventory source
- Nornir: Python-based network automation with Infrahub inventory
- Webhooks: Trigger external systems on events (branch merge, artifact generation)
- Git: Sync schemas and code bidirectionally
Ansible Integration
Use Infrahub with Ansible playbooks.
Nornir Integration
Integrate with Nornir automation framework.
Webhooks
Configure event-driven automation.
Putting it all together
These concepts work together to enable powerful workflows:Design-driven automation example
- Define a service in the schema: Model a “VPN Service” node
- Create a Generator: Automate creation of routers, interfaces, BGP peers, etc.
- Create Transformations: Generate device configs from the service data
- Work in a branch:
- Create a branch for the new service deployment
- Run the Generator to create all objects
- Review generated artifacts
- Run CI checks
- Propose the change: Create a proposed change for review
- Collaborate: Team reviews diffs, comments, requests changes
- Merge: Approved changes merge to main
- Deploy: Webhook triggers Ansible playbook to deploy configs
Agility in infrastructure management example
- Plan a major upgrade (e.g., OS version across 100 routers)
- Create a branch to stage the changes
- Update the schema (add new OS version attribute)
- Update Transformations to use new OS version in configs
- Update data in the branch (set OS version for devices)
- Generate artifacts for all devices
- Run tests in the branch (syntax checks, lab deployments)
- Review in proposed change (diff shows config changes)
- Merge during maintenance window
- Deploy configs to production
Next steps
Quickstart
Get hands-on with Infrahub in minutes.
Installation
Install Infrahub for development or production.
Create a Schema
Design your infrastructure data model.
GraphQL API
Query and mutate data programmatically.