Skip to main content

Creating a new sync instance

This guide will walk you through the steps to create a new sync instance for infrahub-sync, allowing you to synchronize data between your source and destination systems efficiently.

Step 1: Define your configuration

Start by defining your synchronization requirements in a YAML configuration file.

Here's an example configuration for syncing data from Nautobot to Infrahub: In this example, consider that device_type and manufacturer are Attribute of InfraDevice. If you are using another object with a Relationship, you would need to first import those objects and then referenced them (like InfraDevice in InfraInterface)

---
name: example-sync-task

source:
name: nautobot
settings:
url: "https://nautobot.example.com"
token: "NAUTOBOT_TOKEN" # This can also be loaded from environment variables

destination:
name: infrahub
settings:
url: "https://infrahub.example.com"
token: "INFRAHUB_API_TOKEN" # This can also be loaded from environment variables


order:
- "InfraDevice"
- "InfraInterface"

schema_mapping:
- name: InfraDevice
mapping: "dcim.devices"
identifiers: ["name"]
fields:
- name: "name"
mapping: "name"
- name: "device_type"
mapping: "device_type.display_name"
- name: "manufacturer"
mapping: "device_type.manufacturer.name"

- name: InfraInterface
mapping: "dcim.interfaces"
identifiers: ["device", "name"]
fields:
- name: "name"
mapping: "name"
- name: "interface_type"
static: "10gbe"
- name: "description"
mapping: "description"
- name: "device"
reference: "InfraDevice"

For more information on customizing your sync configuration and troubleshooting, see the Sync Instance configuration reference