Skip to content
This repository has been archived by the owner on Jun 30, 2024. It is now read-only.

ffddorf/terraform-provider-netbox

 
 

Repository files navigation

terraform-provider-netbox

Lisence Conventional Commits Build Status Go Report Card

Terraform provider for Netbox.

Requirements

  • A libc library like libc6-compat or libc-utils
  • General developer tools like make, bash, ... (to build the provider)
  • Go 1.15 minimum (to build the provider)
  • Terraform (to use the provider)

Compatibility with Netbox

Version 0.x.y => Netbox 2.8
Version 1.x.y => Netbox 2.9

Building the provider

Clone repository to: $GOPATH/src/github.com/smutel/terraform-provider-netbox

$ mkdir -p $GOPATH/src/github.com/smutel
$ cd $GOPATH/src/github.com/smutel
$ git clone git@github.com:smutel/terraform-provider-netbox.git

Enter the provider directory and build the provider

$ cd $GOPATH/src/github.com/smutel/terraform-provider-netbox
$ make build

Installing the provider


NOTE

Before changing the version of the provider, please remove the temporary folder .terraform and ~/.terraform.d.


Automatic installation from Terraform 0.13

terraform {
  required_providers {
    netbox = {
      source = "smutel/netbox"
      version = "0.2.1"
    }
  }
}

Manual installation

You can install the provider manually in your global terraform provider folder.

$ export NETBOX_PROVIDER_VERSION=1.0.0
$ mkdir -p ~/.terraform.d/plugins/registry.terraform.io/smutel/netbox/${NETBOX_PROVIDER_VERSION}/linux_amd64
$ cp terraform-provider-netbox_v${NETBOX_PROVIDER_VERSION} ~/.terraform.d/plugins/registry.terraform.io/smutel/netbox/${NETBOX_PROVIDER_VERSION}/linux_amd64/terraform-provider-netbox_v${NETBOX_PROVIDER_VERSION}

Manual installation (to test the compiled version = version 0.0.1)

$ make localinstall
==> Creating folder ~/.terraform.d/plugins/registry.terraform.io/smutel/netbox/0.0.1/linux_amd64
==> Installing provider in this folder

Using the provider

The definition of the provider is optional.
All the parameters could be setup by environment variables.

provider netbox {
  # Environment variable NETBOX_URL
  url = "127.0.0.1:8000"
  
  # Environment variable NETBOX_TOKEN
  token = "c07a2db4adb8b1e7f75e7c4369964e92f7680512"
  
  # Environment variable NETBOX_SCHEME
  scheme = "http"
}

For further information, check this documentation

Contributing to this project

To contribute to this project, please follow the conventional commits rules.

Examples

You can find some examples in the examples folder.
Each example can be executed directly with command terraform init & terraform apply.
You can set different environment variables for your test:

  • NETBOX_URL to define the URL and the port (127.0.0.1:8000 by default)
  • NETBOX_TOKEN to define the TOKEN to access the application (empty by default)
  • NETBOX_SCHEME to define the SCHEME of the URL (https by default)
$ export NETBOX_URL="127.0.0.1:8000"
$ export NETBOX_TOKEN="c07a2db4adb8b1e7f75e7c4369964e92f7680512"
$ export NETBOX_SCHEME="http"
$ cd examples
$ terraform init & terraform apply

Known bugs in external project which can impact this provider

About

Terraform provider for Netbox

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 97.8%
  • Shell 1.3%
  • Makefile 0.9%