Initial Schema
To start the lab, we'll load an initial schema into Infrahub and later on we'll explore how we extend it to explore some advanced features
Explore the initial schema
The provided schema is meant to be a good starting point. It includes a handful of node types:
- City
- Device
- InterfaceL3
- IP address
- Prefix
Most of these nodes are leveraging some generics to make it easier to extend the schema. We'll explore that concept in a moment.
Create a branch and load the schema into the branch
When working on building a new schema or extending an existing schema, it's often part of the process to experiment with different solutions and to even occasionally revert back to a known good starting point in the process.
When dealing with an application managing data (such as a relational database), it's usually not possible to try a change in isolation and start from scratch if needed.
In Infrahub, it's possible to use a branch as an isolated environment to try new things and we can easily delete the branch if the changes aren't ready to be integrated into main.
Since we are using infrahubctl
to load the schema, it's logical to also use it to manage branches.
Manage branches using infrahubctl
infrahubctl branch list
infrahubctl branch create <branch_name>
infrahubctl branch delete <branch_name>
The account student
doesn't have the permissions to make changes to the default branch (main
) so the creation a branch is mandatory for this account.
Create a new branch and load the schema
Create a branch using infrahubctl
infrahubctl branch create schema01
Load the initial schema
infrahubctl schema load workshop_b2/lab3/schemas --branch schema01
Load some data to go with the schema
To go along with the schemas some data have been prepared in the directory workshop_b2/lab3/data
We'll use the command infrahubctl object load
to load the data into infrahub directly
infrahubctl object load workshop_b2/lab3/data/site.yml --branch schema01
infrahubctl object load workshop_b2/lab3/data/device.yml --branch schema01
infrahubctl object load workshop_b2/lab3/data/interface_l3.yml --branch schema01
infrahubctl object load workshop_b2/lab3/data/prefix.yml --branch schema01
infrahubctl object load workshop_b2/lab3/data/ipaddress.yml --branch schema01
Please note that the order of these commands is important!
The command infrahubctl object load
is still under active development and that's why it's hidden by default.