mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-16 22:01:15 +00:00
ipaddr: Handle network address in ipmath (#57149)
* Updated testcase, documentation Fixes: #54457 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
committed by
Nilashish Chakraborty
parent
e620e27609
commit
ee8a607cca
@@ -673,8 +673,11 @@ def ipaddr(value, query='', version=False, alias='ipaddr'):
|
||||
|
||||
def ipmath(value, amount):
|
||||
try:
|
||||
ip = netaddr.IPAddress(value)
|
||||
except netaddr.AddrFormatError:
|
||||
if '/' in value:
|
||||
ip = netaddr.IPNetwork(value).ip
|
||||
else:
|
||||
ip = netaddr.IPAddress(value)
|
||||
except (netaddr.AddrFormatError, ValueError):
|
||||
msg = 'You must pass a valid IP address; {0} is invalid'.format(value)
|
||||
raise errors.AnsibleFilterError(msg)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user