/terraform-provider-netbox

Terraform provider to interact with Netbox

Primary LanguageGoMozilla Public License 2.0MPL-2.0

terraform-provider-netbox

The Terraform Netbox provider is a plugin for Terraform that allows for the full lifecycle management of Netbox resources. This provider is maintained by E. Breuninger.

See: Official documentation in the Terraform registry.

Requirements

Supported netbox versions

Netbox often makes breaking API changes even in non-major releases. Check the table below to see which version a provider was tested against. It is generally recommended to use the provider version matching your Netbox version. We aim to always support the latest minor version of Netbox.

Since version 1.6.6, each version of the provider has a built-in list of all Netbox versions it supports at release time. Upon initialization, the provider will probe your Netbox version and include a (non-blocking) warning if the used Netbox version is not supported.

Provider version Netbox version
v2.0.x v3.2.[0-4]
v1.6.x and up v3.1.9
v1.1.x and up v3.1.3
v1.0.x v3.0.9
v0.3.x v2.11.12
v0.2.x v2.10.10
v0.1.x v2.9
v0.0.x v2.9

Building The Provider

  1. Clone the repository
  2. Enter the repository directory
  3. Build the provider using the Go install command:
$ go install

Installation

Starting with Terraform 0.13, you can download the provider via the Terraform registry.

For further information on how to use third party providers, see the Terraform documentation

Releases for all major plattforms are available on the release page.

Using the provider

Here is a short example on how to use this provider:

provider "netbox" {
    server_url           = var.netbox_server
    api_token            = var.netbox_api_token
    allow_insecure_https = false
}

resource "netbox_platform" "testplatform" {
    name = "my-test-platform"
}

resource "netbox_cluster_type" "testclustertype" {
    name = "my-test-cluster-type"
}

For a more complex example, see the example folder.

Developing the Provider

If you wish to work on the provider, you need Go installed on your machine (see Requirements above).

To compile the provider, run go install. This will build the provider and put the provider binary in the $GOPATH/bin directory.

To generate or update documentation, run go generate.

In order to run the suite of unit tests, run make test.

In order to run the full suite of acceptance tests, run make testacc.

Note: Acceptance tests create a docker compose stack on port 8001.

$ make testacc

If you notice a failed test, it might be due to a stale netbox data volume. Before concluding there is a problem, refresh the docker containers by running docker-compose down --volumes in the docker directory. Then run the tests again.

Contribution

We focus on virtual machine management and IPAM. If you want to contribute more resources to this provider, feel free to make a PR.