Skip to content

Commit

Permalink
Create local networks
Browse files Browse the repository at this point in the history
  • Loading branch information
mraerino committed Mar 23, 2024
1 parent 50ec9dd commit bf723fd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
29 changes: 29 additions & 0 deletions modules/device/networks.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
resource "netbox_vrf" "local" {
name = var.name
}

resource "netbox_prefix" "local_v4" {
vrf_id = netbox_vrf.local.id
prefix = var.client_prefix_v4
status = "active"
}

resource "netbox_prefix" "networks_v4" {
for_each = netbox_vlan.networks

vrf_id = netbox_vrf.local.id
prefix = cidrsubnet(var.client_prefix_v4, 8, each.value.vid)

status = "active"
description = "'${each.value.name}' network for ${var.name}"
}

resource "netbox_prefix" "networks_v6" {
for_each = netbox_vlan.networks

vrf_id = netbox_vrf.local.id
prefix = cidrsubnet(netbox_available_prefix.site_v6.prefix, 8, each.value.vid)

status = "active"
description = "'${each.value.name}' network for ${var.name}"
}
6 changes: 6 additions & 0 deletions modules/device/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ variable "site_id" {
type = number
description = "Netbox ID of the site"
}

variable "client_prefix_v4" {
type = string
description = "private network to assign client subnets from"
default = "10.0.0.0/8"
}

0 comments on commit bf723fd

Please sign in to comment.