Skip to content

t0m3kz/infrahub-demo

Repository files navigation

Infrahub demo

Ruff Python Actions status Coverage Status GitHub Discussion


Requirements

  • Python 3.10, 3.11, or 3.12
  • uv for dependency management
  • Docker (for containerlab and some integration tests)

Features

  • Design-driven network automation demo using InfraHub
  • Example data, schemas, and menu for rapid onboarding
  • Scripts for bootstrapping, demo use cases, and CI integration
  • Modular structure for easy extension and experimentation

Project Structure

  • checks/ – Custom validation logic
  • data/ – Example data for bootstrapping
  • generators/ – Topology and config generators
  • menu/ – Example menu definition
  • queries/ – GraphQL queries for InfraHub
  • schemas/ – Base and extension schemas
  • scripts/ – Helper scripts for automation
  • templates/ – Jinja2 templates for device configs
  • tests/ – Unit, integration, and smoke tests
  • transforms/ – Python transforms for InfraHub

Quickstart

Use GitHub Codespaces

Deploy demo using Codespaces: Launch in GitHub Codespaces

Install the Infrahub SDK

uv sync

Start Infrahub

uv run invoke start

Setup environment variables

export INFRAHUB_ADDRESS="http://localhost:8000"
export INFRAHUB_API_TOKEN="06438eb2-8019-4776-878c-0941b1f1d1ec"

Load initial setup

Load schemas

uv run infrahubctl schema load schemas

Load menu

uv run infrahubctl menu load menu

Load demo data

uv run infrahubctl object load data/bootstrap

Load sample security data

uv run infrahubctl object load data/security/

Add demo repository

uv run infrahubctl repository add DEMO https://github.com/t0m3kz/infrahub-demo.git --read-only

Add event actions (optional)

uv run infrahubctl object load data/events/

You can also use the script to execute all previous steps:

./scripts/bootstrap.sh

Demo 1 - Data Center

In this demo, configuration is generated for a composable data center.

./scripts/demo.sh design dc-2

If you would like to process all steps manually, follow these steps:

  1. Create branch
    uv run infrahubctl branch create my-branch
  2. Load example design data stored in data/dc-2 file:
    uv run infrahubctl object load data/ --branch my-branch
    You can review designs in Design Patterns and in Design Elements. New deployment should be added into Services -> Topology Deployments -> Data center
  3. Change branch to design
  4. Go to Actions -> Generator Definitions -> create_dc
  5. Select Run -> Selected Targets, select DC-3 and click Run Generator
  6. Wait until task is completed
  7. Go to the devices and see the generated hosts
  8. Go to Propose Changes -> New Proposed change
  9. Select design as source branch, add name and Create proposed change
  10. Wait until all tasks are completed and check the artifacts/data

If you added event actions steps 4, 5 will be executed automatically.

CI/CD

This project uses GitHub Actions for continuous integration. All pushes and pull requests are tested for lint, type checks, and unit tests.

Security & Secrets

  • Do not commit real API tokens. Use .env or GitHub secrets for sensitive data in production.
  • Example tokens in this README are for demo purposes only.

Troubleshooting

  • If you encounter port conflicts, ensure no other service is running on port 8000.
  • For dependency issues, run uv sync again.
  • For Docker/infrahub issues, ensure Docker is running and you have the correct permissions.

Testing

Run all tests using:

uv run pytest

Or run specific test scripts in the tests/ directory.

Contributing

Contributions, questions, and feedback are welcome! Please use GitHub Discussions.

References

License

This project is licensed under the MIT License. See LICENSE for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •