-
Notifications
You must be signed in to change notification settings - Fork 43
Guide for development setup #8328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+522
−435
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0c04b55
First draft guide for development setup
BaptisteGi 51b4abe
Merge branch 'stable' into bgi-infrahub-dev-tuto
BaptisteGi 56a83c1
replace getting started by overview
BaptisteGi fbdc0ce
spelling exception
BaptisteGi 7d13516
Round 1 of review
BaptisteGi 52d2661
Refine getting schema library and loading part
BaptisteGi 31bb5aa
Fix typos
BaptisteGi 467d3f3
Merge branch 'stable' into bgi-infrahub-dev-tuto
BaptisteGi 189eedd
Fix broken link
BaptisteGi 230c915
Fix broken link
BaptisteGi 2980f77
Merge branch 'stable' into bgi-infrahub-dev-tuto
BaptisteGi dfd6562
Apply suggestion from @BaptisteGi
BaptisteGi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| --- | ||
| title: Set up a development environment | ||
| --- | ||
|
|
||
| Set up a local development environment to build automation solutions with Infrahub. By the end of this guide, you will have a working Infrahub instance with a schema loaded and ready for customization. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| Before you begin, ensure you have the following installed: | ||
|
|
||
| - [Docker](https://docs.docker.com/get-docker/) (Docker Desktop or OrbStack) | ||
| - [uv](https://docs.astral.sh/uv/getting-started/installation/) (Python package manager) | ||
| - [Python 3.10+](https://www.python.org/downloads/) | ||
| - A text editor (VS Code recommended) | ||
|
|
||
| ## Create a project from template | ||
|
|
||
| Use the Infrahub project template to scaffold a new project with the recommended structure. | ||
|
|
||
| 1. Run the following command to create a new project: | ||
|
|
||
| ```bash | ||
| uv tool run --from 'copier' copier copy -r bgi-invoke-schema-library https://github.com/opsmill/infrahub-template <project-name> | ||
BaptisteGi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| Replace `<project-name>` with your desired project directory name. | ||
|
|
||
| 2. Answer the prompts to configure your project settings. | ||
|
|
||
| 3. Navigate to your new project directory: | ||
|
|
||
| ```bash | ||
| cd <project-name> | ||
| ``` | ||
|
|
||
| 4. Open the project in your text editor: | ||
|
|
||
| ```bash | ||
| code . | ||
| ``` | ||
|
|
||
| :::success Verification | ||
| Your project directory should contain files like `pyproject.toml`, `invoke.yaml`, and a `schemas/` folder. | ||
| ::: | ||
BaptisteGi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Start Infrahub | ||
|
|
||
| Launch a local Infrahub instance using the project's built-in tasks. | ||
|
|
||
| 1. Start all services: | ||
|
|
||
| ```bash | ||
| uv run invoke start | ||
| ``` | ||
|
|
||
| 2. Open your browser and navigate to [http://localhost:8000](http://localhost:8000). | ||
|
|
||
| 3. Log in with the default credentials: | ||
BaptisteGi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - Username: `admin` | ||
| - Password: `infrahub` | ||
|
|
||
| :::success Verification | ||
| You should see the Infrahub web interface with a menu on the left side. | ||
| ::: | ||
|
|
||
| ## Get the schema library | ||
|
|
||
| The schema library provides reusable schema definitions as a starting point. You can customize these later to match your organization's needs. | ||
|
|
||
| 1. Download the schema library: | ||
|
|
||
| ```bash | ||
| uv run invoke schema-library.get | ||
BaptisteGi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| 2. Verify the schema files are available in your text editor under the `schema-library/` folder. | ||
|
|
||
| :::info | ||
| The schema defines the structure of your data in Infrahub. Start with the schema library and customize it as you learn more about your requirements. | ||
| ::: | ||
|
|
||
| ## Load a schema | ||
|
|
||
| Load schema definitions into your Infrahub instance to define the data model. | ||
|
|
||
| 1. Copy the base schema from the schema library to your schemas folder: | ||
|
|
||
| ```bash | ||
| cp -r schema-library/base schemas/ | ||
| ``` | ||
|
|
||
| 2. Load the base schema: | ||
|
|
||
| ```bash | ||
| uv run infrahubctl schema load schemas/base | ||
| ``` | ||
|
|
||
| 3. Copy the location extension schema: | ||
|
|
||
| ```bash | ||
| cp -r schema-library/extensions/location_minimal schemas/ | ||
| ``` | ||
|
|
||
| 4. Load the location schema: | ||
|
|
||
| ```bash | ||
| uv run infrahubctl schema load schemas/location_minimal | ||
| ``` | ||
|
|
||
| :::success Verification | ||
| Return to [http://localhost:8000](http://localhost:8000) and refresh the page. The left-hand menu should now display additional options for the loaded schema types. | ||
| ::: | ||
|
|
||
| ## Use infrahubctl | ||
|
|
||
| The `infrahubctl` command-line tool helps you interact with Infrahub during development. Use it to manage branches, load schemas, run Generators, and render Transformations. | ||
|
|
||
| Create a test branch to experiment with changes: | ||
|
|
||
| ```bash | ||
| uv run infrahubctl branch create test-branch | ||
| ``` | ||
|
|
||
| :::info | ||
| Branches in Infrahub work similarly to Git branches. Use them to isolate changes and test modifications before merging to the main branch. | ||
| ::: | ||
|
|
||
| ## Development best practices | ||
|
|
||
| Keep these principles in mind as you build with Infrahub: | ||
|
|
||
| - **Treat your development instance as disposable**: Rebuild it frequently to test fresh installations. | ||
| - **Experiment freely**: Use branches to try new ideas without affecting your main data. | ||
| - **Start minimal**: Add complexity only when needed. | ||
|
|
||
| ## Next steps | ||
|
|
||
| With your development environment ready, explore these guides to build your automation solution: | ||
|
|
||
| - [Create a schema](./create-schema.mdx): Extend the existing schema to fit your organization's needs. | ||
| - [Generate artifacts](./artifact.mdx): Use Transformations to create configuration files, documentation, and other outputs from your data. | ||
| - [Build Generators](./generator.mdx): Automate the creation of infrastructure objects based on templates and inputs. | ||
|
|
||
| When you're ready to share your work with your organization, see the [installation guide](./installation.mdx) for production deployment options. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.