Skip to content

Commit

Permalink
github action to sync docs
Browse files Browse the repository at this point in the history
  • Loading branch information
petercrocker committed Jan 9, 2025
1 parent b067434 commit 4df7269
Show file tree
Hide file tree
Showing 3 changed files with 170 additions and 147 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/sync-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Sync Folders

on:
push:
paths:
- 'docs/docs/**'

jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout source repository
uses: actions/checkout@v4
with:
path: source-repo

- name: Checkout target repository
uses: actions/checkout@v4
with:
repository: opsmill/infrahub-docs
token: ${{ secrets.PAT_TOKEN }}
path: target-repo

- name: Sync folders
run: |
cp -r source-repo/docs/docs/* target-repo/docs/docs-infrahub/
cd target-repo
git config user.name github-actions
git config user.email [email protected]
git add .
git diff --quiet && git diff --staged --quiet || (git commit -m "Sync folder from source repository" && git push)
147 changes: 139 additions & 8 deletions docs/docs/readme.mdx
Original file line number Diff line number Diff line change
@@ -1,19 +1,150 @@
---
title: infrahub-demo-dc-fabric
title: Demo-dc-fabric
---

import CodeBlock from '@theme/CodeBlock';
import block1 from '!!raw-loader!./code_snippets/0001_graphql_add_repo.gql';
import block2 from '!!raw-loader!./code_snippets/0002_shell_run_generator.sh';

This repository demos key Infrahub features using an example data center running VxLAN / EVPN and firewalls. It demonstrates the capabilities to use Infrahub with Arista AVD and Containerlab. Infrahub generates configurations that AVD deploys to a Containerlab topology.

![infrahub-demo-dc-fabric drawing](./infrahub-demo-dc-fabric.excalidraw.svg)

## Infrahub introduction
## Running the demo

### Clone the repository

Clone the GitHub repository to the server you will run this demo on:

```shell
git clone https://github.com/opsmill/infrahub-demo-dc-fabric.git
```

### Requirements

Please ensure you have installed the [Infrahub docker-compose requirements](https://docs.infrahub.app/guides/installation#docker-compose).

### Set environmental variables

```shell
export INFRAHUB_ADDRESS="http://localhost:8000"
export INFRAHUB_API_TOKEN="06438eb2-8019-4776-878c-0941b1f1d1ec"
export CEOS_DOCKER_IMAGE="registry.opsmill.io/external/ceos-image:4.29.0.2F"
export LINUX_HOST_DOCKER_IMAGE="registry.opsmill.io/external/alpine-host:v3.1.1"
```

### Install the Infrahub SDK

```shell
poetry install --no-interaction --no-ansi --no-root
```

### Start Infrahub

```shell
poetry run invoke start
```

### Load schema and data into Infrahub

The `invoke` command will create:

- Basic data (Account, organization, ASN, Device Type, and Tags)
- Location data (Locations, VLANs, and Prefixes)
- Topology data (Topology, Topology Elements)
- Security data (Policies, rules, objects)

```shell
poetry run invoke load-schema load-data
```

## Demo flow

### 1. Add the repository into Infrahub via GraphQL

> [!NOTE]
> Reference the [Infrahub documentation](https://docs.infrahub.app/guides/repository) for the multiple ways this can be done.
<!-- markdownlint-disable -->
<CodeBlock language="graphql">{block1}</CodeBlock>
<!-- markdownlint-restore -->

### 2. Generate a topology (devices, interfaces, cabling, BGP sessions, ...)

> [!NOTE]
> The example below creates the topology fra05-pod1
<!-- markdownlint-disable -->
<CodeBlock language="bash">{block2}</CodeBlock>
<!-- markdownlint-restore -->

### 3. Generate a network service in a Topology

> [!NOTE]
> The example below creates the Layer2 network service and a another Layer3 on topology fra05-pod1
```shell
poetry run infrahubctl run generators/generate_network-services.py topology=fra05-pod1 type=layer2
poetry run infrahubctl run generators/generate_network-services.py topology=fra05-pod1 type=layer3 vrf=production
```

### 4. Render artifacts

Artifact Generation is not currently present in the UI but it's possible to try it out locally :

> [!NOTE]
> This command will render the artifact define with `device_arista` Transformation, for `fra05-pod1-leaf1` device
```shell
poetry run infrahubctl render device_arista device=fra05-pod1-leaf1
```

### 5. Try out our pytest plugin

> [!NOTE]
> The command will use our Infrahub pytest plugin. It will run the different test in the `tests` folder. Those tests included :
>
> - Syntax checks for all the GraphQL Queries
> - Syntax checks for the Checks
> - Syntax checks for all the jinja files used in `templates`
> - will use the input/output file to try out the rendering and confirm there is no unexpected missing piece
```shell
pytest -v ./tests
```

### 6. Create a new Branch

Create directly a new branch `test` in the UI, or if you prefer to use our SDK in CLI :

```shell
poetry run infrahubctl branch create test
```

### 7. Create new network services and regenerate artifacts in your branch

> [!NOTE]
> You will be able to see the Diff in the Branch not only about the Data but about the Artifact as well
> You can go back in time to see the Diff on the branch before you create the new services (you can do it `main` after merging the proposed changes too)
### 8. Create a proposed change

Using your new branch `test` you will be able to see the Diff in the Proposed Change and you will see the checks / tests in the CI pipeline

### 9. Try out the topology check

- Modify an Elements in a Topology (example: increase or decrease the quantity of leaf switches in fra05-pod1)

- The checks will run in the `Proposed Changes` -> `check_device_topology` will fail.

Infrahub from [OpsMill](https://opsmill.com) is taking a new approach to Infrastructure Management by providing a new generation of datastore to organize and control all the data that defines how an infrastructure should run. Infrahub offers a central hub to manage the data, templates and playbooks that power your infrastructure by combining the version control and branch management capabilities of Git with the flexible data model and UI of a graph database.
### 10. Deploy your environment to Containerlab

## Infrahub documentation
The Containerlab generator automatically generates a Containerlab topology artifact for every topology. Every device has its startup configuration as an artifact.

If you'd like to learn more about Infrahub, please refer to the following resources:
```shell
# Download all artifacts automatically to ./generated-configs/
poetry run python3 scripts/get_configs.py

- [Infrahub Overview](https://docs.infrahub.app/overview/)
- [Infrahub Documentation](https://docs.infrahub.app/)
- [FAQ](https://docs.infrahub.app/faq/)
# Start Containerlab
sudo -E containerlab deploy -t ./generated-configs/clab/fra05-pod1.yml --reconfigure
```
139 changes: 0 additions & 139 deletions docs/docs/step_by_step.mdx

This file was deleted.

0 comments on commit 4df7269

Please sign in to comment.