diff --git a/plugins/module_utils/interface.py b/plugins/module_utils/interface.py index b2942acd..3d9936c9 100644 --- a/plugins/module_utils/interface.py +++ b/plugins/module_utils/interface.py @@ -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 = [ @@ -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') @@ -527,7 +532,8 @@ def _log_fields(self, before=None): values += self.format_cli_field(self.obj, 'subnet', fname='ipv4_prefixlen') values += self.format_cli_field(self.obj, 'gateway', fname='ipv4_gateway') values += self.format_cli_field(self.params, 'ipv6_type', default='none') - values += self.format_cli_field(self.obj, 'ipaddrv6', fname='ipv6_address') + if self.obj.get('ipaddrv6') != 'slaac': + values += self.format_cli_field(self.obj, 'ipaddrv6', fname='ipv6_address') values += self.format_cli_field(self.obj, 'subnetv6', fname='ipv6_prefixlen') values += self.format_cli_field(self.obj, 'gatewayv6', fname='ipv6_gateway') values += self.format_cli_field(self.params, 'mac') @@ -545,8 +551,15 @@ def _log_fields(self, before=None): values += self.format_updated_cli_field(self.obj, before, 'ipaddr', add_comma=(values), fname='ipv4_address') values += self.format_updated_cli_field(self.obj, before, 'subnet', add_comma=(values), fname='ipv4_prefixlen') values += self.format_updated_cli_field(self.obj, before, 'gateway', add_comma=(values), fname='ipv4_gateway') - values += self.format_updated_cli_field(self.obj, before, 'ipv6_type', add_comma=(values), log_none='True') - values += self.format_updated_cli_field(self.obj, before, 'ipaddrv6', add_comma=(values), fname='ipv6_address') + if self.obj.get('ipaddrv6') == 'slaac' and before.get('ipaddrv6') != 'slaac': + res = "ipv6_type=slaac" + if values: + values += ", " + res + else: + values += res + else: + values += self.format_updated_cli_field(self.obj, before, 'ipv6_type', add_comma=(values), log_none='True') + values += self.format_updated_cli_field(self.obj, before, 'ipaddrv6', add_comma=(values), fname='ipv6_address') values += self.format_updated_cli_field(self.obj, before, 'subnetv6', add_comma=(values), fname='ipv6_prefixlen') values += self.format_updated_cli_field(self.obj, before, 'gatewayv6', add_comma=(values), fname='ipv6_gateway') values += self.format_updated_cli_field(self.obj, before, 'spoofmac', add_comma=(values), fname='mac') diff --git a/plugins/modules/pfsense_aggregate.py b/plugins/modules/pfsense_aggregate.py index a7fa77b6..7371ddb9 100644 --- a/plugins/modules/pfsense_aggregate.py +++ b/plugins/modules/pfsense_aggregate.py @@ -144,6 +144,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 aggregated_nat_outbounds: description: Dict of nat_outbound rules to apply on the target required: False diff --git a/plugins/modules/pfsense_interface.py b/plugins/modules/pfsense_interface.py index 21b8dbb5..3b70e3ae 100644 --- a/plugins/modules/pfsense_interface.py +++ b/plugins/modules/pfsense_interface.py @@ -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 = """ diff --git a/tests/unit/plugins/modules/test_pfsense_interface.py b/tests/unit/plugins/modules/test_pfsense_interface.py index a922ca17..f2ed9264 100644 --- a/tests/unit/plugins/modules/test_pfsense_interface.py +++ b/tests/unit/plugins/modules/test_pfsense_interface.py @@ -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'])