A Terraform provider for managing local Open vSwitch bridges and ports.
✅ Compatible with both Terraform and OpenTofu
- Manage OVS bridges with OpenFlow protocol configuration
- Create and configure ports on bridges
- Support for tap devices and port actions
- Input validation for OpenFlow versions and port actions
- Works with Terraform 1.6+ and OpenTofu 1.6+
- Go 1.22 or later
- Open vSwitch installed and running
- Root/sudo access (required for
ovs-vsctl,ovs-ofctl, andipcommands)
provider "openvswitch" {}
resource "openvswitch_bridge" "br0" {
name = "testbr0"
ofversion = "OpenFlow13" # Optional: OpenFlow10-15
}
resource "openvswitch_port" "port" {
name = "port0"
bridge_id = openvswitch_bridge.br0.name
ofversion = "OpenFlow13"
action = "up" # Optional: up, down, flood, etc.
}Creates and manages an Open vSwitch bridge.
Arguments:
name(Required) - Bridge nameofversion(Optional) - OpenFlow version:OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13(default),OpenFlow14, orOpenFlow15
Creates and manages a port on an OVS bridge.
Arguments:
name(Required) - Port namebridge_id(Required) - Name of the bridge to attach toofversion(Optional) - OpenFlow version (default:OpenFlow13)action(Optional) - Port action:up(default),down,stp,no-stp,receive,no-receive,no-receive-stp,forward,no-forward,flood,no-flood,packet-in, orno-packet-in
git clone https://github.com/trvon/terraform-provider-openvswitch.git
cd terraform-provider-openvswitch
make buildBinary will be created at bin/terraform-provider-openvswitch.
For local development and testing, see DEVELOPMENT.md.
go test ./...Requires Open vSwitch and root access:
sudo -E TF_ACC=1 go test ./openvswitch -vOr using Make:
sudo -E make testacc# Install golangci-lint
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# Run linters
golangci-lint run ./...GitHub Actions runs on every push and PR:
- ✅ Lint - golangci-lint with 20+ linters, go vet, gofmt
- ✅ Security - govulncheck, race detector
- ✅ Unit Tests - with coverage reporting
- ✅ Acceptance Tests - in OVS container
- ✅ Integration Tests - matrix testing with Terraform 1.6/1.10 and OpenTofu 1.6/1.8
This provider works seamlessly with both Terraform and OpenTofu using the same binary. The plugin protocol is identical, so no special configuration is needed.
Tested versions:
- Terraform: 1.6.0, 1.10.5
- OpenTofu: 1.6.0, 1.8.10
sudo commands.
See the examples directory for complete working examples:
- sample-bridge - Terraform example
- opentofu-sample - OpenTofu example
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Ensure tests pass:
make build && go test ./... - Ensure linting passes:
golangci-lint run ./... - Submit a pull request
Apache License 2.0 - see LICENSE for details.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Active Development - The provider is functional and tested. Current focus:
- ✅ Code quality improvements (completed)
- ✅ Comprehensive linting and testing (completed)
- ✅ OpenTofu compatibility verification (completed)
- 🔄 SDK migration to terraform-plugin-sdk/v2 (planned)
- 🔄 Expanded test coverage (in progress)