This provider manages local Open vSwitch bridges and ports. Compatible with both Terraform and OpenTofu.
From examples/sample-bridge:
provider "openvswitch" {}
resource "openvswitch_bridge" "sample_bridge" {
name = "testbr0"
# Optional Parameters
# OpenFlow10, OpenFlow11, OpenFlow12, OpenFlow14, OpenFlow15
ofversion = "OpenFlow13"
}
resource "openvswitch_port" "sample_port" {
count = 2
name = "p${count.index}"
ofversion = "OpenFlow13"
bridge_id = openvswitch_bridge.sample_bridge.name
# Optional Field
action = "up"
}
- The ip, ovs-vsctl, ovs-ofctl commands all require sudo or root access
- Error handling is currently broken
Requirements:
- Go 1.18.x or later
- GNU Make
- Terraform v0.12 or later
- OpenTofu v1.6.0 or later
Clone this repo, and then do the following:
$ make build
See the Development Guide for detailed instructions on how to set up your development environment and use the provider locally before it's published to the Terraform Registry.
This includes:
- Using development overrides
- Setting up CLI configuration
- Linking the provider for local testing
To run the unit tests:
$ go test ./...
The acceptance tests require:
- OpenVSwitch installed
- Root privileges or sudo
To run the acceptance tests:
$ sudo -E TF_ACC=1 go test ./openvswitch -v
Or use the Makefile target:
$ sudo -E make testacc
This project uses GitHub Actions for CI/CD:
-
Tests Workflow (
tests.yml
): Runs on every push and pull request to master- Unit tests in standard environment
- Acceptance tests in OpenVSwitch container
- Integration tests with both Terraform and OpenTofu
-
Release Workflow (
release.yml
): Triggered manually with a version parameter- First runs all tests from the tests workflow
- Creates GitHub release and publishes provider to Terraform Registry
The test workflow uses a custom container with OpenVSwitch installed to ensure tests have the necessary environment.