Skip to content

Commit

Permalink
vmware_vmkernel: Support IPv6
Browse files Browse the repository at this point in the history
  • Loading branch information
mariolenz committed Jan 26, 2025
1 parent af13893 commit 659ea54
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/1740-vmware_vmkernel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
minor_changes:
- vmware_vmkernel - Support setting an IPv6 address
(https://github.com/ansible-collections/community.vmware/pull/1740).
34 changes: 23 additions & 11 deletions plugins/modules/vmware_vmkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,35 @@
ip_address:
type: str
description:
- Static IP address.
- Static IPv4 address.
- Required if O(network.type=static).
subnet_mask:
type: str
description:
- Static netmask required.
- Static IPv4 netmask.
- Required if O(network.type=static).
default_gateway:
type: str
description: Default gateway (Override default gateway for this adapter).
description: Default IPv4 gateway (Override default gateway for this adapter).
tcpip_stack:
type: str
description:
- The TCP/IP stack for the VMKernel interface.
choices: [ 'default', 'provisioning', 'vmotion', 'vxlan' ]
default: 'default'
ipv6_address:
type: str
description:
- Static IPv6 address.
- Required if O(network.ipv6_subnet_mask) is set.
ipv6_subnet_mask:
type: str
description:
- Static IPv6 netmask.
- Required if O(network.ipv6_address) is set.
ipv6_default_gateway:
type: str
description: Default IPv6 gateway (Override default gateway for this adapter).
type: dict
default: {
type: 'static',
Expand Down Expand Up @@ -324,14 +337,6 @@ def __init__(self, module):
msg="Failed to get details of ESXi server. Please specify esxi_hostname."
)

if self.network_type == 'static':
if self.module.params['state'] == 'absent':
pass
elif not self.ip_address:
module.fail_json(msg="ip_address is a required parameter when network type is set to 'static'")
elif not self.subnet_mask:
module.fail_json(msg="subnet_mask is a required parameter when network type is set to 'static'")

# find Port Group
if self.vswitch_name:
self.port_group_obj = self.get_port_group_by_name(
Expand Down Expand Up @@ -1113,12 +1118,19 @@ def main():
ip_address=dict(type='str'),
subnet_mask=dict(type='str'),
default_gateway=dict(type='str'),
ipv6_address=dict(type='str'),
ipv6_subnet_mask=dict(type='str'),
ipv6_default_gateway=dict(type='str'),
tcpip_stack=dict(type='str', default='default', choices=['default', 'provisioning', 'vmotion', 'vxlan']),
),
default=dict(
type='static',
tcpip_stack='default',
),
required_together=[
['ip_address', 'subnet_mask'],
['ipv6_address', 'ipv6_subnet_mask']
]
),
state=dict(
type='str',
Expand Down

0 comments on commit 659ea54

Please sign in to comment.