Skip to content

Commit

Permalink
[interface] Support slaac ipv6_type
Browse files Browse the repository at this point in the history
  • Loading branch information
opoplawski committed Mar 23, 2024
1 parent 613d01c commit 5cb4043
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions plugins/module_utils/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
ipv6_gateway=dict(required=False, type='str'),
blockpriv=dict(required=False, type='bool'),
blockbogons=dict(required=False, type='bool'),
slaacusev4iface=dict(required=False, type='bool'),
)

INTERFACE_REQUIRED_IF = [
Expand Down Expand Up @@ -132,6 +133,10 @@ def _params_to_obj(self):
self._get_ansible_param(obj, 'ipv6_prefixlen', fname='subnetv6')
self._get_ansible_param(obj, 'ipv6_gateway', fname='gatewayv6')

if params['ipv6_type'] == 'slaac':
obj['ipaddrv6'] = 'slaac'
self._get_ansible_param_bool(obj, 'slaacusev4iface', value='')

# get target interface
self.target_elt = self._find_matching_interface()
self._check_overlaps('ipaddrv6', 'subnetv6')
Expand Down
5 changes: 5 additions & 0 deletions plugins/modules/pfsense_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@
description: Blocks traffic from reserved IP addresses (but not RFC 1918) or not yet assigned by IANA.
required: false
type: bool
slaacusev4iface:
description: IPv6 will use the IPv4 connectivity link (PPPoE). Only used when dhcp6_type is slaac.
required: false
type: bool
version_added: 0.6.2
"""

EXAMPLES = """
Expand Down
6 changes: 5 additions & 1 deletion tests/unit/plugins/modules/test_pfsense_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,14 @@ def check_target_elt(self, obj, target_elt):
self.assert_xml_elt_equal(target_elt, 'gateway', obj['ipv4_gateway'])

# ipv6 type related
if obj.get('ipv6_type') is None or obj.get('ipv6_type') in ['none', 'slaac']:
if obj.get('ipv6_type') is None or obj.get('ipv6_type') in ['none']:
self.assert_not_find_xml_elt(target_elt, 'ipaddrv6')
self.assert_not_find_xml_elt(target_elt, 'subnetv6')
self.assert_not_find_xml_elt(target_elt, 'gatewayv6')
elif obj.get('ipv6_type') == 'slaac':
self.assert_xml_elt_equal(target_elt, 'ipaddrv6', 'slaac')
self.assert_not_find_xml_elt(target_elt, 'subnetv6')
self.assert_not_find_xml_elt(target_elt, 'gatewayv6')
elif obj.get('ipv6_type') == 'static':
if obj.get('ipv6_address'):
self.assert_xml_elt_equal(target_elt, 'ipaddrv6', obj['ipv6_address'])
Expand Down

0 comments on commit 5cb4043

Please sign in to comment.