diff --git a/examples/resources/routeros_wifi_capsman/import.sh b/examples/resources/routeros_wifi_capsman/import.sh new file mode 100644 index 00000000..8dca701f --- /dev/null +++ b/examples/resources/routeros_wifi_capsman/import.sh @@ -0,0 +1 @@ +terraform import routeros_wifi_capsman.settings . diff --git a/examples/resources/routeros_wifi_capsman/resource.tf b/examples/resources/routeros_wifi_capsman/resource.tf new file mode 100644 index 00000000..38e77599 --- /dev/null +++ b/examples/resources/routeros_wifi_capsman/resource.tf @@ -0,0 +1,5 @@ +resource "routeros_wifi_capsman" "settings" { + enabled = true + interfaces = ["bridge1"] + upgrade_policy = "suggest-same-version" +} diff --git a/routeros/provider.go b/routeros/provider.go index bfcb3f7f..4aa3988f 100644 --- a/routeros/provider.go +++ b/routeros/provider.go @@ -221,6 +221,7 @@ func Provider() *schema.Provider { // WiFi "routeros_wifi_aaa": ResourceWifiAaa(), "routeros_wifi_access_list": ResourceWifiAccessList(), + "routeros_wifi_capsman": ResourceWifiCapsman(), "routeros_wifi_channel": ResourceWifiChannel(), "routeros_wifi_configuration": ResourceWifiConfiguration(), "routeros_wifi_datapath": ResourceWifiDatapath(), diff --git a/routeros/resource_wifi_capsman.go b/routeros/resource_wifi_capsman.go new file mode 100644 index 00000000..8c5815a2 --- /dev/null +++ b/routeros/resource_wifi_capsman.go @@ -0,0 +1,92 @@ +package routeros + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +) + +/* +{ + "ca-certificate": "auto", + "certificate": "auto", + "enabled": "yes", + "generated-ca-certificate": "WiFi-CAPsMAN-CA-000000000000", + "generated-certificate": "WiFi-CAPsMAN-000000000000", + "interfaces": "LAN", + "package-path": "/upgrade", + "require-peer-certificate": "true", + "upgrade-policy": "suggest-same-version" +} +*/ + +// https://help.mikrotik.com/docs/display/ROS/WiFi#WiFi-CAPsMANGlobalConfiguration +func ResourceWifiCapsman() *schema.Resource { + resSchema := map[string]*schema.Schema{ + MetaResourcePath: PropResourcePath("/interface/wifi/capsman"), + MetaId: PropId(Name), + + "ca_certificate": { + Type: schema.TypeString, + Optional: true, + Description: "Device CA certificate.", + }, + "certificate": { + Type: schema.TypeString, + Optional: true, + Description: "Device certificate.", + }, + "enabled": { + Type: schema.TypeBool, + Optional: true, + Description: "Disable or enable CAPsMAN functionality.", + }, + "generated_ca_certificate": { + Type: schema.TypeString, + Computed: true, + Description: "Generated CA certificate.", + }, + "generated_certificate": { + Type: schema.TypeString, + Computed: true, + Description: "Generated CAPsMAN certificate.", + }, + "interfaces": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Description: "List of interfaces on which CAPsMAN will listen for CAP connections.", + }, + "package_path": { + Type: schema.TypeString, + Optional: true, + Description: "Folder location for the RouterOS packages. For example, use '/upgrade' to specify the " + + "upgrade folder from the files section. If empty string is set, CAPsMAN can use built-in RouterOS " + + "packages, note that in this case only CAPs with the same architecture as CAPsMAN will be upgraded.", + }, + "require_peer_certificate": { + Type: schema.TypeBool, + Optional: true, + Description: "Require all connecting CAPs to have a valid certificate.", + }, + "upgrade_policy": { + Type: schema.TypeString, + Optional: true, + Description: "Upgrade policy options.", + ValidateFunc: validation.StringInSlice([]string{"none", "require-same-version", "suggest-same-version"}, false), + }, + } + + return &schema.Resource{ + Description: `*This resource requires a minimum version of RouterOS 7.13.*`, + CreateContext: DefaultSystemCreate(resSchema), + ReadContext: DefaultSystemRead(resSchema), + UpdateContext: DefaultSystemUpdate(resSchema), + DeleteContext: DefaultSystemDelete(resSchema), + + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: resSchema, + } +}