network_in_network test fails for /31 IPv4 and /127 IPv6 networks
sebastianw opened this issue · 0 comments
sebastianw commented
SUMMARY
When using /31 IPv4 and /127 IPv6 networks for point-2-point connections the network_in_network
filter fails when trying to validate the second IP address in the network.
Trying the same with network_in_usable
works because this function seems to have special handling for a network size of two addresses. As network_in_usable
is by definition a subset of network_in_network
the latter should also succeed when using this kind of networks.
ISSUE TYPE
- Bug Report
COMPONENT NAME
ipaddr
ANSIBLE VERSION
ansible 2.10.16
config file = /Users/CENSORED/test/ansible.cfg
configured module search path = ['/Users/CENSORED/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /Users/CENSORED/test/venv/lib/python3.9/site-packages/ansible
executable location = /Users/CENSORED/test/venv/bin/ansible
python version = 3.9.9 (main, Nov 21 2021, 03:16:13) [Clang 13.0.0 (clang-1300.0.29.3)]
COLLECTION VERSION
# /Users/CENSORED/test/collections/ansible_collections
Collection Version
----------------- -------
ansible.netcommon 2.5.0
CONFIGURATION
Not dependent on config
OS / ENVIRONMENT
MacOS 12.1
STEPS TO REPRODUCE
- hosts: localhost
tasks:
- name: Test filter
debug:
msg:
- "network_in_network IPv4: {{ '192.168.1.0/31'|ansible.netcommon.network_in_network('192.168.1.1') }}"
- "network_in_network IPv6: {{ '2001:db8::/127'|ansible.netcommon.network_in_network('2001:db8::1') }}"
EXPECTED RESULTS
This should return True both times because the last IP address in a /31 is valid.
ACTUAL RESULTS
The result is False
PLAY [localhost] *************************************************************************************************************
TASK [Test ipaddr filters] ***************************************************************************************************
ok: [localhost] => {}
MSG:
['network_in_network IPv4: False', 'network_in_network IPv6: False']
PLAY RECAP *******************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0