Categorygithub.com/bl4ko/netbox-ssot
repository
1.7.8
Repository: https://github.com/bl4ko/netbox-ssot.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author

# README

Netbox-SSOT

Go GitHub last commit GitHub Tag codecov GitHub License

Netbox-ssot is a small but powerful microservice designed to keep your Netbox instance in sync with external data sources.

It is designed to be run as a cronjob, and will periodically update Netbox with the latest data from the external sources. It syncs each source in parallel to speed up the process of syncing.

Currently, the supported external data sources types are:

[!WARNING] This project is still under heavy development, use with caution.

  • v1.x.x works with netbox>=4.0.0

  • v0.x.x works with netbox>=3.7.0

Configuration

Netbox-ssot is configured via a single yaml file. The configuration file is divided into three sections:

  • logger: Logger configuration
  • netbox: Netbox configuration
  • source: Array of configuration for each data source

Example configuration can be found here.

Logger

ParameterDescriptionTypePossible valuesDefaultRequired
logger.levelLog levelint/string[0-3] or [debug,info,warn,error]1,infoNo
logger.destLog output filename. Default "" representing stdout.strAny valid path""No

Netbox

ParameterDescriptionTypePossible valuesDefaultRequired
netbox.apiTokenNetbox API token.strAny valid token""Yes
netbox.hostnameHostname of your netbox instance (e.g netbox.example.com).strValid hostname""Yes
netbox.portPort of your netbox instance.int0-65536443No
netbox.httpSchemeHTTP scheme of your netbox instance.str[http, https]httpsNo
netbox.validateCertValidate the TLS certificate of your netbox instance.bool[true, false]falseNo
netbox.timeoutMax timeout for api call of your netbox instance.int>=030No
netbox.removeOrphansIf set to true all objects, marked with netbox-ssot tag that were not found during this iteration are automatically deleted. If set to false, objects that were not found are marked with an Orphan tag. We can then use netbox.removeOrphansAfterDays to remove the orphans after n days that they were not seen on the sources.bool[true, false]trueNo
netbox.removeOrphansAfterDaysSpecifies the number of days to wait before automatically deleting objects marked as Orphan. This setting is only applicable if netbox.removeOrphans is set to false. A value of 5 means objects are deleted in five days after being marked as Orphan and not found since.int>0MaxIntNo
netbox.tagTag to be applied to all objects managed by netbox-ssot.stringany"netbox-ssot"No
netbox.tagColorTagColor for the netbox-ssot tag.stringany"07426b"No
netbox.sourcePriorityArray of source names in order of priority. If an object (e.g. Vlan) is found in multiple sources, the first source in the list will be used.[]stringany[]No
netbox.caFilePath to a self signed certificate for netbox.stringValid path""No

Source

ParameterDescriptionSource TypeTypePossible valuesDefaultRequired
source.nameName of the data source.allstrany""Yes
source.typeType of the data source.allstr[ovirt, vmware, dnac, proxmox, paloalto]""Yes
source.httpSchemeHttp scheme for the sourceallstr[ http,https]httpsNo
source.hostnameHostname of the data source.allstrany""Yes
source.portPort of the data source.allint0-65536443No
source.usernameUsername of the data source account.allstrany""Yes
source.passwordPassword of the data source account.allstrany""Yes
source.apiTokenAPI token of the data source account.[fortigate]strany""Yes
source.validateCertEnforce TLS certificate validation.allbool[true, false]falseNo
source.tagColorTagColor for the source tag.allstringanyPredefinedNo
source.ignoredSubnetsList of subnets, which will be ignored (e.g. IPs won't be synced).all[]stringany[]No
source.permittedSubnetsList of subnets, which will be permitted (e.g. only IPs in these subnets will be synced).all[]stringany[]No
source.interfaceFilterRegex representation of interface names to be ignored (e.g. (cali|vxlan|flannel|[a-f0-9]{15}))allstringany[]No
source.collectArpDataCollect data from the arp table of the device.[paloalto, ios-xe]bool[true, false]falseNo
source.datacenterClusterGroupRelationsRegex relations in format regex = clusterGroupName, that map each datacenter that satisfies regex to clusterGroupname (see #130).[vmware, ovirt][]stringany[]No
source.hostSiteRelationsRegex relations in format regex = siteName, that map each host that satisfies regex to site.all[]stringany[]No
source.clusterSiteRelationsRegex relations in format regex = siteName, that map each cluster that satisfies regex to site.all[]stringany[]No
source.clusterTenantRelationsRegex relations in format regex = tenantName, that map each cluster that satisfies regex to tenant.all[]stringany[]No
source.hostTenantRelationsRegex relations in format regex = tenantName, that map each host that satisfies regex to tenant.all[]stringany[]No
source.hostRoleRelationsRegex relations in format regex = roleName, that map each host that satisfies regex to device role.all[]stringany[]No
source.hostTenantRelationsRegex relations in format regex = tenantName, that map each host that satisfies regex to tenant.all[]stringany[]No
source.vmTenantRelationsRegex relations in format regex = tenantName, that map each vm that satisfies regex to tenant.all[]stringany[]No
source.vmTenantRelationsRegex relations in format regex = tenantName, that map each vm that satisfies regex to tenant.all[]stringany[]No
source.vmRoleRelationsRegex relations in format regex = roleName, that map each vm that satisfies regex to device role.all[]stringany[]No
source.vlanGroupRelationsRegex relations in format regex = vlanGroup, that map each vlan that satisfies regex to vlanGroup.all[]stringany[]No
source.vlanTenantRelationsRegex relations in format regex = tenantName, that map each vlan that satisfies regex to tenant.all[]stringany[]No
source.wlanTenantRelationsRegex relations in format regex = tenantName, that map each wlan that satisfies regex to tenant.[dnac][]stringany[]No
source.customFieldMappingsMappings of format customFieldName = option. Currently, supported options are contact, owner, description.[vmware][]stringany[]No
source.caFilePath to a self signed certificate for the source.anystringValid path""No

Example config

logger:
  level: 1
  dest: ""

netbox:
  apiToken: "el1aof2azu6n50ks5zcenp3..."
  hostname: "netbox.example.com"
  httpScheme: http
  port: 443
  timeout: 30
  sourcePriority: ["olvm", "prodvmware", "prodprox", "dnacenter", "testvmware", "pa-uk", "fmc-lab"] # Not required, but recommended

source:
  - name: olvm
    type: ovirt
    hostname: ovirt.example.com
    port: 443
    username: "admin"
    password: "topsecret"
    interfaceFilter: (cali|vxlan|flannel|docker|[a-f0-9]{15})

  - name: prodvmware
    type: vmware
    hostname: vcenter.example.com
    username: user
    password: "top_secret"
    clusterSiteRelations:
      - .* = ExampleSite
    hostSiteRelations:
      - .*_NYC = New York
      - nyc.* = New York
    customFieldMappings: # Here we define map of our custom field names, to 3 option [email, owner, description]
      - Mail = email
      - Creator = owner
      - Description = description

  - name: prodprox
    type: proxmox
    username: svc@pve
    password: changeme
    hostname: 192.168.1.254
    port: 8006
    validateCert: false
    clusterSiteRelations:
     - .* = Site

  - name: forti
    type: fortigate
    hostname: forti.example.com
    apiToken: "apitokenhere"
    validateCert: False
    hostTenantRelations:
      - .* = MyTenant
    hostSiteRelations:
      - .* = MyTenant
    vlanTenantRelations:
      - .* = MyTenant

  - name: pa-uk
    type: paloalto
    hostname: 192.168.1.52
    username: user
    password: passw0rd
    hostTenantRelations:
      - .* = MyTenant
    hostSiteRelations:
      - .* = MySite
    vlanTenantRelations:
      - .* = MyTenant
    collectArpData: true

  - name: dnacenter
    type: dnac
    hostname: dnac.example.com
    username: user
    password: "pa$$w0rd"
    vlanTenantRelations:
      - .* = MyTenant

  - name: fmc-lab
    type: fmc
    hostname: 172.16.1.30
    username: user
    password: password
    validateCert: False
    hostTenantRelations:
      - .* = MyTenant
    hostSiteRelations:
      - .* = MySite
    vlanTenantRelations:
      - .* = MyTenant

  - name: cs1
    type: ios-xe
    hostname: 10.10.1.1
    username: user
    password: password
    port: 830
    validateCert: False
    hostTenantRelations:
      - .* = MyTenant
    hostSiteRelations:
      - .* = MySite
    vlanTenantRelations:
      - .* = MyTenant
    collectArpData:
      true

Deployment

Via docker

docker run -v /path/to/config.yaml:/app/config.yaml ghcr.io/bl4ko/netbox-ssot

Via k8s

Create k8s secret from self defined config.yaml:

kubectl create secret generic netbox-ssot-secret --from-file=config.yaml

Apply cronjob with custom settings:

kubectl apply -f cronjob.yaml

Using self signed certificate

Create self signed certificate e.g.:

kubectl create secret generic netbox-ssot-cert --from-file=sub.pem=./sub.pem

Use cronjob with cert mounted:

kubectl apply -f cronjob_with_cert.yaml