.infrahub.yml
file
To make full use of a remote repository within Infrahub, the remote repository must have a .infrahub.yml
file defined at the root of the repository. Without this file, Infrahub will only load GraphQL queries (.gql
extension) defined within the repository and it will ignore any other Infrahub data types.
An external repository can be used to link the following Infrahub objects to an Infrahub instance:
- GraphQL Query
- Schema
- Jinja2 Transform
- Python Transformation
- Artifact Definition
- Generator Definition
- See this guide for how to add or update an external repository in Infrahub
- See this topic for more information on remote repositories in Infrahub
- See this reference for more information on the
.infrahub.yml
file format
To help with the development process of a repository configuration file, you can leverage schema validation within your editor.
GraphQL query
GraphQL queries could be defined in file(s) with a .gql
extension. Then queries must also be explicitly identified in the .infrahub.yml
file under queries
.
Example
queries:
- name: topology_info # Here goes the query's name
file_path: "topology/topology_info.gql" # Here is the path to query's file
Schema
Schemas to be loaded as part of an external repository can be defined in file(s) as described here. The schemas must also be explicitly identified in the .infrahub.yml
file under schemas
.
Example
schemas:
- schemas/demo_edge_fabric.yml
Infrahub will attempt to import any schemas defined in .infrahub.yml
when pulling from the external repository.
Jinja2 transformation
Jinja2 Transformations can be defined as described here. To load Jinja2 Transformations into Infrahub from an external repository, you must explicitly define them in the .infrahub.yml
file. Each Jinja2 Transformations in the .infrahub.yml
configuration file is defined by the following
name
: name of the transformquery
: the name of an InfrahubGraphQL query
to use with the transformtemplate_path
: the path to the Jinja2 template within this repositorydescription
: (optional) a description of the transform
Example
jinja2_transforms:
- name: device_startup
description: "Template to generate startup configuration for network devices"
query: "device_startup_info"
template_path: "templates/device_startup_config.tpl.j2"
Python transformation
Python Transformations can be defined as described here. To load Python Transformations from an external repository, you must explicitly define them in the .infrahub.yml
configuration file. The definition in .infrahub.yml
includes the following
name
: name of the transformationfile_path
: path to the Python transformation within this repositoryclass_name
: which specific class to use in the Python file designated byfile_path
Example
python_transforms:
- name: OCInterfaces
class_name: OCInterfaces
file_path: "transforms/openconfig.py"
Artifact definition
Artifact Definitions can be created as described here. To load Artifact Definitions from an external repository, you must explicitly define them in the .infrahub.yml
configuration file. Each Artifact Definition in .infrahub.yml
must include the following:
name
: the name of the Artifact Definitionartifact_name
: the name of the Artifact created by this Artifact Definitionparameters
: mapping of the input parameters required to render this Artifactcontent_type
: the content-type of the created Artifacttargets
: the InfrahubGroup
to target when generating the Artifacttransformation
: the name of the Transformation to use when generating the Artifact
Example
artifact_definitions:
- name: "Openconfig Interface for Arista devices"
artifact_name: "openconfig-interfaces"
parameters:
device: "name__value"
content_type: "application/json"
targets: "arista_devices"
transformation: "OCInterfaces
Generator definition
Generator Definitions can be created as described here. To load Generator Definitions from an external repository, you must explicitly define them in the .infrahub.yml
configuration file. Each Generator Definition in .infrahub.yml
must include the following:
name
: the name of the Generator Definitionfile_path
: path to the Generator Python file within this repositoryquery
: the name of an InfrahubGraphQL query
to use with the Generatorclass_name
: the class defining the generator in the Python file designated by file_pathtargets
: the Infrahub Group containing the targets for which we want to run the Generator