infrahubctl command is the main entry point for interacting with Infrahub from the command line. It provides access to database management, server control, development utilities, and system maintenance.
Command Overview
Global Options
| Option | Description |
|---|---|
--help | Show help message and exit |
Top-Level Commands
shell
Start a Python interactive shell within Infrahub context.db- InfrahubDatabase instanceBranch- Branch classNodeManager- NodeManager class for querying nodesregistry- Global registry instanceservice- InfrahubServices instance
upgrade
Upgrade Infrahub to the latest version by running migrations and updating schemas.| Argument | Description | Default |
|---|---|---|
CONFIG_FILE | Path to configuration file | infrahub.toml |
| Option | Description | Default |
|---|---|---|
--check | Check upgrade status without applying | False |
--rebase-branches | Rebase and migrate branches after upgrade | False |
--interactive | Prompt to accept/deny rebase of each branch | False |
INFRAHUB_CONFIG- Configuration file path
- Detects and runs pending graph migrations
- Updates the core schema to the latest version
- Upgrades internal objects (menu, permissions)
- Sets up Prefect task manager components
- Optionally rebases branches that need migration
Command Groups
server
Control the Infrahub API server. See Server Commands for details.db
Manage the graph database. See Database Commands for details.dev
Internal development commands for schema export and database initialization.dev export-graphql-schema
Export the Core GraphQL schema to a file.| Option | Description | Default |
|---|---|---|
--config-file | Configuration file path | infrahub.toml |
--out | Output file path | schema.graphql |
dev export-json-schema
Export the REST API OpenAPI schema to a file.| Option | Description | Default |
|---|---|---|
--out | Output file path | openapi.json |
dev export-node-schema
Export the repository configuration schema to a file.| Option | Description | Default |
|---|---|---|
--config-file | Configuration file path | infrahub.toml |
--out | Output file path | develop.json |
dev db-init
Erase the database and initialize it with the core schema.| Argument | Description | Default |
|---|---|---|
CONFIG_FILE | Path to configuration file | infrahub.toml |
| Option | Description |
|---|---|
--config-file | Configuration file path |
dev load-test-data
Load test data into the database from thetest_data directory.
| Argument | Description | Default |
|---|---|---|
CONFIG_FILE | Path to configuration file | infrahub.toml |
--dataset | Dataset name to load | dataset01 |
| Option | Description |
|---|---|
--config-file | Configuration file path |
events
(Hidden) Interact with the events system.events listen
Listen to events in the message bus and print them.| Argument | Description | Default |
|---|---|---|
TOPIC | Routing key pattern to match | # (all events) |
CONFIG_FILE | Path to configuration file | infrahub.toml |
tasks
(Hidden) Manage Prefect task manager.tasks init
Initialize the Prefect task manager.| Argument | Description | Default |
|---|---|---|
CONFIG_FILE | Path to configuration file | infrahub.toml |
| Option | Description | Default |
|---|---|---|
--debug | Enable debug logging | False |
tasks execute
Execute a test workflow in the task manager.| Argument | Description | Default |
|---|---|---|
CONFIG_FILE | Path to configuration file | infrahub.toml |
| Option | Description | Default |
|---|---|---|
--debug | Enable debug logging | False |
tasks flush flow-runs
Delete old Prefect flow runs.| Argument | Description | Default |
|---|---|---|
CONFIG_FILE | Path to configuration file | infrahub.toml |
| Option | Description | Default |
|---|---|---|
--days-to-keep | Number of days of flow runs to keep | 30 |
--batch-size | Number of runs to delete per batch | 100 |
tasks flush stale-runs
Delete stale (stuck in RUNNING state) Prefect flow runs.| Argument | Description | Default |
|---|---|---|
CONFIG_FILE | Path to configuration file | infrahub.toml |
| Option | Description | Default |
|---|---|---|
--days-to-keep | Age threshold for stale runs | 2 |
--batch-size | Number of runs to process per batch | 100 |
git-agent
(Hidden) Control the Git Agent service.git-agent start
Start the Infrahub Git Agent.| Argument | Description | Default |
|---|---|---|
PORT | Metrics endpoint port | 8000 |
| Option | Description | Default |
|---|---|---|
--debug | Enable debug logging | False |
--config-file | Configuration file path | infrahub.toml |
INFRAHUB_CONFIG- Configuration file pathINFRAHUB_METRICS_PORT- Metrics endpoint port
See Also
- Database Commands - Complete database command reference
- Server Commands - Server control commands
- CLI Overview - Introduction and common usage patterns