-
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_interface
resource to manage ZeroTier i…
…nterface
- Loading branch information
Showing
4 changed files
with
151 additions
and
1 deletion.
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/interface get [print show-ids]] | ||
terraform import routeros_zerotier_interface.zerotier1 '*1' |
31 changes: 31 additions & 0 deletions
31
examples/resources/routeros_zerotier_interface/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,31 @@ | ||
resource "zerotier_identity" "identity" {} | ||
|
||
resource "zerotier_network" "network" { | ||
name = "test" | ||
} | ||
|
||
resource "zerotier_member" "member" { | ||
authorized = true | ||
member_id = zerotier_identity.identity.id | ||
name = "test" | ||
network_id = zerotier_network.network.id | ||
hidden = false | ||
allow_ethernet_bridging = true | ||
no_auto_assign_ips = true | ||
} | ||
|
||
resource "routeros_zerotier" "zt1" { | ||
comment = "ZeroTier Central" | ||
identity = zerotier_identity.identity.private_key | ||
interfaces = ["all"] | ||
name = "zt1" | ||
} | ||
|
||
resource "routeros_zerotier_interface" "zerotier1" { | ||
allow_default = false | ||
allow_global = false | ||
allow_managed = false | ||
instance = routeros_zerotier.zt1.name | ||
name = "zerotier1" | ||
network = zerotier_network.network.id | ||
} |
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,115 @@ | ||
package routeros | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
/* | ||
{ | ||
".id": "*1", | ||
"allow-default": "false", | ||
"allow-global": "false", | ||
"allow-managed": "false", | ||
"arp-timeout": "auto", | ||
"bridge": "true", | ||
"dhcp": "false", | ||
"disabled": "false", | ||
"instance": "zt1", | ||
"mac-address": "00:00:00:00:00:00", | ||
"mtu": "2800", | ||
"name": "zerotier1", | ||
"network": "a00000000aa00a00", | ||
"network-name": "something", | ||
"running": "true", | ||
"status": "OK", | ||
"type": "PRIVATE" | ||
} | ||
*/ | ||
|
||
// https://help.mikrotik.com/docs/display/ROS/ZeroTier#ZeroTier-Parameters | ||
func ResourceZerotierInterface() *schema.Resource { | ||
resSchema := map[string]*schema.Schema{ | ||
MetaResourcePath: PropResourcePath("/zerotier/interface"), | ||
MetaId: PropId(Id), | ||
|
||
"allow_default": { | ||
Type: schema.TypeBool, | ||
Optional: true, | ||
Default: false, | ||
Description: "An option to override the default route.", | ||
}, | ||
"allow_global": { | ||
Type: schema.TypeBool, | ||
Optional: true, | ||
Default: false, | ||
Description: "An option to allow overlapping public IP space by the ZeroTier routes. .", | ||
}, | ||
"allow_managed": { | ||
Type: schema.TypeBool, | ||
Optional: true, | ||
Default: false, | ||
Description: "An option to allow assignment of managed IPs.", | ||
}, | ||
KeyArpTimeout: PropArpTimeoutRw, | ||
"bridge": { | ||
Type: schema.TypeBool, | ||
Computed: true, | ||
Description: "A flag whether the ZeroTier interface is bridged.", | ||
}, | ||
KeyComment: PropCommentRw, | ||
KeyDisabled: PropDisabledRw, | ||
"disable_running_check": { | ||
Type: schema.TypeBool, | ||
Optional: true, | ||
Description: "An option to force the `running` property to true.", | ||
DiffSuppressFunc: AlwaysPresentNotUserProvided, | ||
}, | ||
"dhcp": { | ||
Type: schema.TypeBool, | ||
Computed: true, | ||
Description: "A flag whether the ZeroTier interface obtained an IP address.", | ||
}, | ||
"instance": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The ZeroTier instance name.", | ||
}, | ||
KeyMacAddress: PropMacAddressRo, | ||
KeyMtu: PropL2MtuRo, | ||
KeyName: PropName("Name of the ZeroTier interface."), | ||
"network": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The ZeroTier network identifier.", | ||
}, | ||
"network_name": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The ZeroTier network name.", | ||
}, | ||
KeyRunning: PropRunningRo, | ||
"status": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The status of the ZeroTier connection.", | ||
}, | ||
"type": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The ZeroTier network type.", | ||
}, | ||
} | ||
|
||
return &schema.Resource{ | ||
CreateContext: DefaultCreate(resSchema), | ||
ReadContext: DefaultRead(resSchema), | ||
UpdateContext: DefaultUpdate(resSchema), | ||
DeleteContext: DefaultDelete(resSchema), | ||
|
||
Importer: &schema.ResourceImporter{ | ||
StateContext: schema.ImportStatePassthroughContext, | ||
}, | ||
|
||
Schema: resSchema, | ||
} | ||
} |