Skip to content

Commit 37885ab

Browse files
committed
feat!: add SDN support for zones, vnets, subnets with validation and tests
Signed-off-by: MacherelR <[email protected]>
1 parent 1b86a41 commit 37885ab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3105
-6
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
layout: page
3+
title: proxmox_virtual_environment_sdn_subnet
4+
parent: Data Sources
5+
subcategory: Virtual Environment
6+
description: |-
7+
Retrieve details about a specific SDN Subnet in Proxmox VE.
8+
---
9+
10+
# Data Source: proxmox_virtual_environment_sdn_subnet
11+
12+
Retrieve details about a specific SDN Subnet in Proxmox VE.
13+
14+
15+
16+
<!-- schema generated by tfplugindocs -->
17+
## Schema
18+
19+
### Required
20+
21+
- `subnet` (String)
22+
- `vnet` (String) The VNet this subnet belongs to.
23+
24+
### Read-Only
25+
26+
- `canonical_name` (String)
27+
- `dhcp_dns_server` (String) The DNS server used for DHCP.
28+
- `dhcp_range` (Attributes List) List of DHCP ranges (start and end IPs). (see [below for nested schema](#nestedatt--dhcp_range))
29+
- `dnszoneprefix` (String) Prefix used for DNS zone delegation.
30+
- `gateway` (String) The gateway address for the subnet.
31+
- `id` (String) The full ID in the format 'vnet-id/subnet-id'.
32+
- `snat` (Boolean) Whether SNAT is enabled for the subnet.
33+
- `type` (String)
34+
35+
<a id="nestedatt--dhcp_range"></a>
36+
### Nested Schema for `dhcp_range`
37+
38+
Read-Only:
39+
40+
- `end_address` (String) End of the DHCP range.
41+
- `start_address` (String) Start of the DHCP range.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
layout: page
3+
title: proxmox_virtual_environment_sdn_vnet
4+
parent: Data Sources
5+
subcategory: Virtual Environment
6+
description: |-
7+
Retrieves information about an existing SDN Vnet in Proxmox VE.
8+
---
9+
10+
# Data Source: proxmox_virtual_environment_sdn_vnet
11+
12+
Retrieves information about an existing SDN Vnet in Proxmox VE.
13+
14+
15+
16+
<!-- schema generated by tfplugindocs -->
17+
## Schema
18+
19+
### Required
20+
21+
- `name` (String) The name of the vnet.
22+
23+
### Read-Only
24+
25+
- `alias` (String) - An alias for this vnet.
26+
- `id` (String) - The ID of the vnet (usually the name).
27+
- `isolate_ports` (Boolean) - Whether ports are isolated.
28+
- `tag` (Number) - VLAN/VXLAN tag.
29+
- `type` (String) - Type of the vnet.
30+
- `vlanaware` (Boolean) - Whether this vnet is VLAN aware.
31+
- `zone` (String) - The zone associated with the vnet.
32+
- `zonetype` (String) - The type of the zone associated with this vnet.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
layout: page
3+
title: proxmox_virtual_environment_sdn_zone
4+
parent: Data Sources
5+
subcategory: Virtual Environment
6+
description: |-
7+
Fetch a Proxmox SDN Zone by name.
8+
---
9+
10+
# Data Source: proxmox_virtual_environment_sdn_zone
11+
12+
13+
This data source allows you to fetch information about an existing SDN zone in a Proxmox Virtual Environment (PVE) cluster by its name.
14+
15+
16+
17+
<!-- schema generated by tfplugindocs -->
18+
## Schema
19+
20+
### Required
21+
22+
- `name` (String) Name (ID) of the SDN zone.
23+
24+
### Read-Only
25+
26+
- `advertise_subnets` (Boolean) - Whether to advertise subnets to the zone.
27+
- `bridge` (String) – Linux bridge device used (if applicable).
28+
- `controller` (String) – Controller for EVPN zones.
29+
- `disable_arp_nd_suppression` (Boolean) – Whether ARP/ND suppression is disabled.
30+
- `dns` (String) – DNS server configured for the zone.
31+
- `dns_zone` (String) – The DNS zone name used by this SDN zone.
32+
- `exit_nodes` (String) – Nodes designated as exit points.
33+
- `exit_nodes_local_routing` (Boolean) – Whether local routing is enabled for exit nodes.
34+
- `id` (String) - The ID of the SDN zone.
35+
- `ipam` (String) – The IP Address Management (IPAM) method used in the zone.
36+
- `mtu` (Number) – Maximum Transmission Unit for this zone.
37+
- `nodes` (String) – Comma-separated list of node names associated with the zone.
38+
- `peers` (String) – Peers used for some zone types only.
39+
- `primary_exit_node` (String) – The main exit node.
40+
- `reversedns` (String) – Reverse DNS server for the zone.
41+
- `rt_import` (String) – Route targets to import.
42+
- `tag` (Number) – VLAN tag or other numeric identifier.
43+
- `type` (String) – The SDN zone type (e.g., `simple`, `vlan`, `vxlan`, `evpn`).
44+
- `vlan_protocol` (String) – VLAN protocol used.
45+
- `vrf_vxlan` (Number) – VXLAN ID associated with VRF zones.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
layout: page
3+
title: proxmox_virtual_environment_sdn_subnet
4+
parent: Resources
5+
subcategory: Virtual Environment
6+
description: |-
7+
Manages SDN Subnets in Proxmox VE.
8+
---
9+
10+
# Resource: proxmox_virtual_environment_sdn_subnet
11+
12+
Manages SDN Subnets in Proxmox VE.
13+
14+
15+
16+
<!-- schema generated by tfplugindocs -->
17+
## Schema
18+
19+
### Required
20+
21+
- `subnet` (String) The name/ID of the subnet.
22+
- `vnet` (String) The VNet to which this subnet belongs.
23+
24+
### Optional
25+
26+
- `dhcp_dns_server` (String) The DNS server used for DHCP.
27+
- `dhcp_range` (Attributes List) List of DHCP ranges (start and end IPs). (see [below for nested schema](#nestedatt--dhcp_range))
28+
- `dnszoneprefix` (String) Prefix used for DNS zone delegation.
29+
- `gateway` (String) The gateway address for the subnet.
30+
- `snat` (Boolean) Whether SNAT is enabled for the subnet.
31+
32+
### Read-Only
33+
34+
- `canonical_name` (String) Canonical name of the subnet (e.g. zoneM-10.10.0.0-24).
35+
- `id` (String) The unique identifier of this resource.
36+
- `type` (String) Subnet type (set default at 'subnet')
37+
38+
<a id="nestedatt--dhcp_range"></a>
39+
### Nested Schema for `dhcp_range`
40+
41+
Required:
42+
43+
- `end_address` (String) End of the DHCP range.
44+
- `start_address` (String) Start of the DHCP range.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
layout: page
3+
title: proxmox_virtual_environment_sdn_vnet
4+
parent: Resources
5+
subcategory: Virtual Environment
6+
description: |-
7+
Manages Proxmox VE SDN vnet.
8+
---
9+
10+
# Resource: proxmox_virtual_environment_sdn_vnet
11+
12+
Manages Proxmox VE SDN vnet.
13+
14+
15+
16+
<!-- schema generated by tfplugindocs -->
17+
## Schema
18+
19+
### Required
20+
21+
- `name` (String) Unique identifier for the vnet.
22+
- `zone` (String) The zone to which this vnet belongs.
23+
- `zonetype` (String) Parent's zone type. MUST be specified.
24+
25+
### Optional
26+
27+
- `alias` (String) An optional alias for this vnet.
28+
- `isolate_ports` (Boolean) Whether to isolate ports within this vnet.
29+
- `tag` (Number) Tag value for VLAN/VXLAN (depends on zone type).
30+
- `vlanaware` (Boolean) Whether this vnet is VLAN aware.
31+
32+
### Read-Only
33+
34+
- `id` (String) The unique identifier of this resource.
35+
- `type` (String) Type of vnet (e.g. 'vnet').
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
layout: page
3+
title: proxmox_virtual_environment_sdn_zone
4+
parent: Resources
5+
subcategory: Virtual Environment
6+
description: |-
7+
Manages SDN Zones in Proxmox VE.
8+
---
9+
10+
# Resource: proxmox_virtual_environment_sdn_zone
11+
12+
Manages SDN Zones in Proxmox VE.
13+
Some attributes in the `proxmox_virtual_environment_sdn_zone` resource or data source are only applicable to certain zone types. For example:
14+
15+
`bridge` is relevant only for `vlan` zones.
16+
17+
`peers`, `controller`, `vrf_vxlan`, and related attributes are specific to `vxlan` and `evpn` zone types.
18+
19+
`service_vlan` and `vlan_protocol` apply to `qinq` zones.
20+
21+
While the Proxmox API does not explicitly document these constraints, they are enforced by the Proxmox backend and have been validated manually through API experimentation.
22+
23+
The Terraform provider implements field-level validation to ensure that only compatible attributes are used with each zone type. If incompatible attributes are set, Terraform will raise a configuration error during plan or apply to prevent invalid requests to the Proxmox API.
24+
25+
This design helps ensure correctness and avoids unexpected API failures when managing SDN zones across different zone types.
26+
27+
28+
29+
<!-- schema generated by tfplugindocs -->
30+
## Schema
31+
32+
### Required
33+
34+
- `name` (String) The unique ID of the SDN zone.
35+
- `type` (String) Zone type (e.g. simple, vlan, qinq, vxlan, evpn).
36+
37+
### Optional
38+
39+
- `advertise_subnets` (Boolean) Enable subnet advertisement for EVPN.
40+
- `bridge` (String) Bridge interface for VLAN/QinQ.
41+
- `controller` (String) EVPN controller address.
42+
- `disable_arp_nd_suppression` (Boolean) Disable ARP/ND suppression for EVPN.
43+
- `dns` (String) DNS server address.
44+
- `dns_zone` (String) DNS zone name.
45+
- `exit_nodes` (String) Comma-separated list of exit nodes for EVPN.
46+
- `exit_nodes_local_routing` (Boolean) Enable local routing for EVPN exit nodes.
47+
- `ipam` (String) IP Address Management system.
48+
- `mtu` (Number) MTU value for the zone.
49+
- `nodes` (String) Comma-separated list of Proxmox node names.
50+
- `peers` (String) Peers list for VXLAN.
51+
- `primary_exit_node` (String) Primary exit node for EVPN.
52+
- `reversedns` (String) Reverse DNS settings.
53+
- `rt_import` (String) Route target import for EVPN.
54+
- `tag` (Number) Service VLAN tag for QinQ.
55+
- `vlan_protocol` (String) Service VLAN protocol for QinQ.
56+
- `vrf_vxlan` (Number) EVPN VRF VXLAN ID.
57+
58+
### Read-Only
59+
60+
- `id` (String) The unique identifier of this resource.

example/resource_virtual_environment_container.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ resource "proxmox_virtual_environment_container" "example_template" {
44
start_on_boot = "true"
55

66
disk {
7-
datastore_id = "local-lvm"
7+
datastore_id = var.virtual_environment_storage
88
size = 4
99
}
1010

1111
mount_point {
1212
// volume mount
13-
volume = "local-lvm"
13+
volume = var.virtual_environment_storage
1414
size = "4G"
1515
path = "mnt/local"
1616
}
@@ -66,7 +66,7 @@ resource "proxmox_virtual_environment_container" "example_template" {
6666

6767
resource "proxmox_virtual_environment_container" "example" {
6868
disk {
69-
datastore_id = "local-lvm"
69+
datastore_id = var.virtual_environment_storage
7070
}
7171

7272
clone {

example/resource_virtual_environment_download_file.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
resource "proxmox_virtual_environment_download_file" "release_20240725_ubuntu_24_noble_lxc_img" {
44
content_type = "vztmpl"
55
datastore_id = "local"
6-
node_name = "pve"
6+
node_name = var.virtual_environment_node_name
77
url = var.release_20240725_ubuntu_24_noble_lxc_img_url
88
checksum = var.release_20240725_ubuntu_24_noble_lxc_img_checksum
99
checksum_algorithm = "sha256"
@@ -15,7 +15,7 @@ resource "proxmox_virtual_environment_download_file" "latest_debian_12_bookworm_
1515
content_type = "iso"
1616
datastore_id = "local"
1717
file_name = "debian-12-generic-amd64.img"
18-
node_name = "pve"
18+
node_name = var.virtual_environment_node_name
1919
url = var.latest_debian_12_bookworm_qcow2_img_url
2020
overwrite = true
2121
overwrite_unmanaged = true

0 commit comments

Comments
 (0)