-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add
routeros_zerotier_controller
resource to manage ZeroTier …
…controller
- Loading branch information
Showing
4 changed files
with
134 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#The ID can be found via API or the terminal | ||
#The command for the terminal is -> :put [/zerotier/controller get [print show-ids]] | ||
terraform import routeros_zerotier_controller.test '*1' |
15 changes: 15 additions & 0 deletions
15
examples/resources/routeros_zerotier_controller/resource.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
resource "zerotier_identity" "identity" {} | ||
|
||
resource "routeros_zerotier" "zt1" { | ||
comment = "ZeroTier Central" | ||
identity = zerotier_identity.identity.private_key | ||
interfaces = ["all"] | ||
name = "zt1" | ||
} | ||
|
||
resource "routeros_zerotier_controller" "test" { | ||
instance = routeros_zerotier.zt1.name | ||
name = "test" | ||
network = "1234567812345678" | ||
private = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package routeros | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
/* | ||
{ | ||
".id": "*1", | ||
"broadcast": "false", | ||
"comment": "Something", | ||
"disabled": "false", | ||
"inactive": "true", | ||
"instance": "zt1", | ||
"ip-range": "192.168.88.200-192.168.88.220", | ||
"ip6-6plane": "false", | ||
"ip6-range": "fd00:feed:feed:beef::-fd00:feed:feed:beef:ffff:ffff:ffff:ffff", | ||
"ip6-rfc4193": "false", | ||
"mtu": "1598", | ||
"multicast-limit": "32", | ||
"name": "test", | ||
"network": "1234567812345678", | ||
"private": "true", | ||
"routes": "192.168.88.0/24@192.168.88.1,0.0.0.0/0@192.168.88.1" | ||
} | ||
*/ | ||
|
||
// https://help.mikrotik.com/docs/display/ROS/ZeroTier#ZeroTier-Parameters.1 | ||
func ResourceZerotierController() *schema.Resource { | ||
resSchema := map[string]*schema.Schema{ | ||
MetaResourcePath: PropResourcePath("/zerotier/controller"), | ||
MetaId: PropId(Id), | ||
|
||
"broadcast": { | ||
Type: schema.TypeBool, | ||
Optional: true, | ||
Default: true, | ||
Description: "An option to allow receiving broadcast packets.", | ||
}, | ||
KeyComment: PropCommentRw, | ||
KeyDisabled: PropDisabledRw, | ||
"inactive": { | ||
Type: schema.TypeBool, | ||
Computed: true, | ||
Description: "A flag whether the ZeroTier network is inactive.", | ||
}, | ||
"instance": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The ZeroTier instance name.", | ||
}, | ||
"ip_range": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "The IP range of the ZeroTier network.", | ||
}, | ||
"ip6_6plane": { | ||
Type: schema.TypeBool, | ||
Optional: true, | ||
Default: false, | ||
Description: "An option to assign every member a `/80` address within a `/40` network with using NDP emulation.", | ||
}, | ||
"ip6_range": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "The IPv6 range of the ZeroTier network.", | ||
}, | ||
"ip6_rfc4193": { | ||
Type: schema.TypeBool, | ||
Optional: true, | ||
Default: false, | ||
Description: "An option to assign every member a `/128` address within a `/88` network.", | ||
}, | ||
KeyMtu: PropL2MtuRw, | ||
"multicast_limit": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
Default: 32, | ||
Description: "An option to limit the maximum recipients of a multicast packet.", | ||
}, | ||
KeyName: PropName("Name of the ZeroTier controller."), | ||
"network": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The ZeroTier network identifier.", | ||
}, | ||
"private": { | ||
Type: schema.TypeBool, | ||
Optional: true, | ||
Default: true, | ||
Description: "The ZeroTier network access control.", | ||
}, | ||
"routes": { | ||
Type: schema.TypeSet, | ||
Optional: true, | ||
Elem: &schema.Schema{Type: schema.TypeString}, | ||
Description: "The routes list that will be pushed to the client.", | ||
}, | ||
} | ||
|
||
return &schema.Resource{ | ||
CreateContext: DefaultCreate(resSchema), | ||
ReadContext: DefaultRead(resSchema), | ||
UpdateContext: DefaultUpdate(resSchema), | ||
DeleteContext: DefaultDelete(resSchema), | ||
|
||
Importer: &schema.ResourceImporter{ | ||
StateContext: schema.ImportStatePassthroughContext, | ||
}, | ||
|
||
Schema: resSchema, | ||
} | ||
} |