Home
Softono
terraform-provider-opnsense

terraform-provider-opnsense

Open source MPL-2.0 Go
176
Stars
46
Forks
9
Issues
9
Watchers
1 week
Last Commit

About terraform-provider-opnsense

OPNsense Terraform Provider

Platforms

Web Self-hosted

Languages

Go

Terraform Provider for OPNsense

This Terraform provider enables management of various configs and resources within OPNsenseยฎ.

[!WARNING] This provider is under active development and makes no guarantee of stability. Breaking changes to resource and data source schemas will occur as needed until v1.0. It is not recommended to use this provider in production environments.

Example Usage

# 1. Configure Terraform to use the provider
terraform {
  required_providers {
    opnsense = {
      source  = "browningluke/opnsense"
      version = "~> 0.16"
    }
  }
}

# 2. Configure the OPNsense provider with API credentials
provider "opnsense" {
  uri        = "https://opnsense.example.com"

  # Either reference the API credentials literally
  api_key    = "<api key>"
  api_secret = "<api password>"

  # Or specify them with environment variables
  # export OPNSENSE_API_KEY="<api key>"
  # export OPNSENSE_API_SECRET="<api key>"
}

# 3. Create resources - example: firewall rule
resource "opnsense_firewall_filter" "allow_https" {
  enabled     = true
  description = "Allow inbound HTTPS traffic"

  interface = {
    interface = ["wan"]
  }

  filter = {
    action    = "pass"
    direction = "in"
    protocol  = "TCP"

    source = {
      net = "any"
    }

    destination = {
      net  = "192.168.1.100"
      port = "https"
    }

    log = true
  }
}

Long Road to v1

Version 1.0 will be released once the provider achieves feature-parity with the Core OPNsense API and all resources have comprehensive acceptance tests (see Current API Coverage). Plugin resources will be added as requested (at a lower priority than requests for Core resources). There is no Plugin API converage requirement for v1.

v1 represents the first release where resource and data source schemas will be guaranteed to be stable, and breaking changes to these schemas will be forbidden. Any updates to these schemas will following appropriate SemVer conventions. Until v1.0 is reached, schemas are subject to change as needed to improve usability and align with best practices. Users should always check the release notes when upgrading between pre-v1.0 versions to understand any breaking changes that may affect their configurations.

Documentation

Contributing

Interested in contributing? Please see our Contributing Guide for development setup, testing requirements, and guidelines.

Current API Coverage

This provider is actively expanding to cover the OPNsense API. The tables below contain the current status of said coverage.

  • โœ… = Fully implemented
  • ๐Ÿšง = Missing acceptance tests
  • โŒ = Not implemented

Core API

Module/Controller/Resource Resource Data Source
Auth/Group โŒ โŒ
Auth/Priv โŒ โŒ
Auth/User โŒ โŒ
Captiveportal/Settings โŒ โŒ
Captiveportal/Service/Template โŒ โŒ
Captiveportal/Settings/Zone โŒ โŒ
Core/Hasync โŒ โŒ
Core/Snapshots โŒ โŒ
Core/Tunables โŒ โŒ
Cron/Job โŒ โŒ
Dhcrelay/Settings โŒ โŒ
Dhcrelay/Settings/Dest โŒ โŒ
Dhcrelay/Settings/Relay โŒ โŒ
Diagnostics/Interface โŒ ๐Ÿšง
Diagnostics/Lvtemplate โŒ โŒ
Diagnostics/Lvtemplate/Item โŒ โŒ
Dnsmasq/Settings โŒ โŒ
Dnsmasq/Settings/Boot โŒ โŒ
Dnsmasq/Settings/Domain โŒ โŒ
Dnsmasq/Settings/Host โœ… โœ…
Dnsmasq/Settings/Option โŒ โŒ
Dnsmasq/Settings/Range โŒ โŒ
Dnsmasq/Settings/Tag โŒ โŒ
Firewall/Alias โœ… โœ…
Firewall/Category ๐Ÿšง ๐Ÿšง
Firewall/Filter โœ… โœ…
Firewall/Group โŒ โŒ
Firewall/NPTv6 โŒ โŒ
Firewall/Source NAT โœ… โœ…
Firewall/One-to-One NAT โœ… โœ…
Interfaces/Bridge โŒ โŒ
Interfaces/Gif โŒ โŒ
Interfaces/Gre โŒ โŒ
Interfaces/Lagg โŒ โŒ
Interfaces/Loopback โŒ โŒ
Interfaces/Neighbor โŒ โŒ
Interfaces/Overview โœ…
Interfaces/Vip โœ… โœ…
Interfaces/Vlan โœ… โœ…
Interfaces/Vxlan โŒ โŒ
Ipsec/Settings โŒ โŒ
Ipsec/Connections/Local โœ… โŒ
Ipsec/Connections/Remote โœ… โŒ
Ipsec/Connections/Child โœ… โŒ
Ipsec/Connections/Connection โœ… โŒ
Ipsec/KeyPairs โŒ โŒ
Ipsec/ManualSpd โŒ โŒ
Ipsec/Pools โŒ โŒ
Ipsec/Psk โœ… โŒ
Ipsec/Vti โœ… โŒ
Kea/CtrlAgent โŒ โŒ
Kea/Dhcpv4/Peer โœ… โœ…
Kea/Dhcpv4/Reservation โœ… โœ…
Kea/Dhcpv4/Subnet โœ… โœ…
Kea/Dhcpv6/PD Pool โœ… โœ…
Kea/Dhcpv6/Peer โœ… โœ…
Kea/Dhcpv6/Reservation โœ… โœ…
Kea/Dhcpv6/Subnet โœ… โœ…
Monit/Settings โŒ โŒ
Monit/Settings/Alert โŒ โŒ
Monit/Settings/Service โŒ โŒ
Monit/Settings/Test โŒ โŒ
Openvpn/Client Overwrites โœ… โœ…
Openvpn/Instances โœ… โœ…
Openvpn/Instances/Static Key โœ… โœ…
Openvpn/Instances/Generate Key โœ… (ephemeral)
Routes/Route ๐Ÿšง ๐Ÿšง
Routing/Gateway โŒ โŒ
Syslog/Settings โŒ โŒ
Syslog/Settings/Destination โŒ โŒ
Trafficshaper/Pipe โŒ โŒ
Trafficshaper/Queue โŒ โŒ
Trafficshaper/Rule โŒ โŒ
Trust/Settings โŒ โŒ
Trust/CA โŒ โŒ
Trust/Cert โŒ โŒ
Unbound/Settings โœ… โœ…
Unbound/Settings/Domain Override โœ… โœ…
Unbound/Settings/Forward โœ… โœ…
Unbound/Settings/Host Alias โœ… โœ…
Unbound/Settings/Host Override โœ… โœ…
Unbound/Settings/ACL โŒ โŒ
Wireguard/Settings โŒ โŒ
Wireguard/Client ๐Ÿšง ๐Ÿšง
Wireguard/Server ๐Ÿšง ๐Ÿšง
Wireguard/Generate Key Pair โŒ โŒ
Wireguard/Generate PSK โŒ โŒ

Plugin API

The following is a non-exhaustive list of the plugin APIs OPNsense supports. The table shows those which are 'highest priority'. Please open a feature request to indicate interest for any plugin not listed here.

Plugin/Controller/Resource Resource Data Source
Acmeclient/Settings โŒ โŒ
Acmeclient/Account โŒ โŒ
Acmeclient/Validation โŒ โŒ
Acmeclient/Certificates โŒ โŒ
Acmeclient/Action โŒ โŒ
Haproxy/Maintenance โŒ โŒ
Haproxy/Settings โŒ โŒ
Haproxy/Settings/Acl โŒ โŒ
Haproxy/Settings/Action โŒ โŒ
Haproxy/Settings/Backend โŒ โŒ
Haproxy/Settings/Cpu โŒ โŒ
Haproxy/Settings/Errorfile โŒ โŒ
Haproxy/Settings/Fcgi โŒ โŒ
Haproxy/Settings/Frontend โŒ โŒ
Haproxy/Settings/Group โŒ โŒ
Haproxy/Settings/Healthcheck โŒ โŒ
Haproxy/Settings/Lua โŒ โŒ
Haproxy/Settings/Mapfile โŒ โŒ
Haproxy/Settings/Server โŒ โŒ
Haproxy/Settings/User โŒ โŒ
Quagga/General โŒ โŒ
Quagga/Bfd โŒ โŒ
Quagga/Bfd/Neighbor โŒ โŒ
Quagga/Bgp โŒ โŒ
Quagga/Bgp/AS Path ๐Ÿšง ๐Ÿšง
Quagga/Bgp/Community List ๐Ÿšง ๐Ÿšง
Quagga/Bgp/Neighbor ๐Ÿšง ๐Ÿšง
Quagga/Bgp/Peer Group โŒ โŒ
Quagga/Bgp/Prefix List ๐Ÿšง ๐Ÿšง
Quagga/Bgp/Route Map ๐Ÿšง ๐Ÿšง
Quagga/Ospf โŒ โŒ
Quagga/Ospf/Interface โŒ โŒ
Quagga/Ospf/Neighbor โŒ โŒ
Quagga/Ospf/Network โŒ โŒ
Quagga/Ospf/Prefix List โŒ โŒ
Quagga/Ospf/Redistribution โŒ โŒ
Quagga/Ospf/Route Map โŒ โŒ
Quagga/Ospf6 โŒ โŒ
Quagga/Ospf6/Interface โŒ โŒ
Quagga/Ospf6/Neighbor โŒ โŒ
Quagga/Ospf6/Network โŒ โŒ
Quagga/Ospf6/Prefix List โŒ โŒ
Quagga/Ospf6/Redistribution โŒ โŒ
Quagga/Rip โŒ โŒ
Quagga/Static โŒ โŒ
Quagga/Static/Route โŒ โŒ

The complete OPNsense API documentation can be found at: docs.opnsense.org

License

This project is licensed under the Mozilla Public License v2.0 - see the LICENSE file for details.