Skip to main content

.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:

info
  • 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
note

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 transform
  • query: the name of an Infrahub GraphQL query to use with the transform
  • template_path: the path to the Jinja2 template within this repository
  • description: (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 transformation
  • file_path: path to the Python transformation within this repository
  • class_name: which specific class to use in the Python file designated by file_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 Definition
  • artifact_name: the name of the Artifact created by this Artifact Definition
  • parameters: mapping of the input parameters required to render this Artifact
  • content_type: the content-type of the created Artifact
  • targets: the Infrahub Group to target when generating the Artifact
  • transformation: 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 Definition
  • file_path: path to the Generator Python file within this repository
  • query: the name of an Infrahub GraphQL query to use with the Generator
  • class_name: the class defining the generator in the Python file designated by file_path
  • targets: the Infrahub Group containing the targets for which we want to run the Generator