diff --git a/lib/ansible/module_utils/network/f5/ipaddress.py b/lib/ansible/module_utils/network/f5/ipaddress.py index 495b0b90e65..5871530b67e 100644 --- a/lib/ansible/module_utils/network/f5/ipaddress.py +++ b/lib/ansible/module_utils/network/f5/ipaddress.py @@ -94,12 +94,12 @@ def is_valid_ip_interface(address): def get_netmask(address): - addr = ip_network(address) + addr = ip_network(u'{0}'.format(address)) netmask = addr.netmask.compressed return netmask def compress_address(address): - addr = ip_network(address) + addr = ip_network(u'{0}'.format(address)) result = addr.compressed.split('/')[0] return result diff --git a/lib/ansible/modules/network/f5/bigip_virtual_address.py b/lib/ansible/modules/network/f5/bigip_virtual_address.py index ea4528f821f..c9060dd5881 100644 --- a/lib/ansible/modules/network/f5/bigip_virtual_address.py +++ b/lib/ansible/modules/network/f5/bigip_virtual_address.py @@ -36,7 +36,9 @@ options: description: - Netmask of the provided virtual address. This value cannot be modified after it is set. - default: 255.255.255.255 + - When creating a new virtual address, if this parameter is not specified, the + default value is C(255.255.255.255) for IPv4 addresses and + C(ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff) for IPv6 addresses. connection_limit: description: - Specifies the number of concurrent connections that the system @@ -279,6 +281,7 @@ try: from library.module_utils.network.f5.common import fq_name from library.module_utils.network.f5.common import f5_argument_spec from library.module_utils.network.f5.ipaddress import is_valid_ip + from library.module_utils.network.f5.ipaddress import compress_address from library.module_utils.network.f5.icontrol import tmos_version except ImportError: from ansible.module_utils.network.f5.bigip import F5RestClient @@ -291,6 +294,7 @@ except ImportError: from ansible.module_utils.network.f5.common import fq_name from ansible.module_utils.network.f5.common import f5_argument_spec from ansible.module_utils.network.f5.ipaddress import is_valid_ip + from ansible.module_utils.network.f5.ipaddress import compress_address from ansible.module_utils.network.f5.icontrol import tmos_version @@ -487,7 +491,7 @@ class ModuleParameters(Parameters): if self._values['address'] is None: return None if is_valid_ip(self._values['address']): - return self._values['address'] + return compress_address(self._values['address']) else: raise F5ModuleError( "The provided 'address' is not a valid IP address" @@ -713,6 +717,7 @@ class ModuleManager(object): def create(self): self._set_changed_options() + if self.want.traffic_group is None: self.want.update({'traffic_group': '/Common/traffic-group-1'}) if self.want.arp is None: @@ -720,6 +725,12 @@ class ModuleManager(object): if self.want.spanning is None: self.want.update({'spanning': False}) + if self.want.netmask is None: + if is_valid_ip(self.want.address, type='ipv4'): + self.want.update({'netmask': '255.255.255.255'}) + else: + self.want.update({'netmask': 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'}) + if self.want.arp and self.want.spanning: raise F5ModuleError( "'arp' and 'spanning' cannot both be enabled on virtual address." @@ -866,10 +877,7 @@ class ArgumentSpec(object): ), name=dict(), address=dict(), - netmask=dict( - type='str', - default='255.255.255.255', - ), + netmask=dict(), connection_limit=dict( type='int' ),