Closed
Description
SUMMARY
Please implement a new filter that returns either the first or last X bits of an IP address.
Example:
I have an IP address like 1234:4321:abcd:dcba::17
. Now I would like to just get the last 80 bits of the address for my firewall rule.
1234:4321:abcd:dcba::17
> expanded: 1234:4321:abcd:dcba:0000:0000:0000:17
-> filtered: dcba:0:0:0:17
ISSUE TYPE
- Feature Request
COMPONENT NAME
ansible.utils.ipaddr
ADDITIONAL INFORMATION
In my case I need to derive a portion of an IP address to make a firewall rule from it.
I don't want to use the IP address itself, as it wouldn't match (Complicated IPv6 story).
So I just want to have the network portion and the interface identifier.
1234:4321:abcd:dcba::17 | ansible.utils.ipcut(last, 80)
dcba:0:0:0:17
1234:4321:abcd:dcba::17 | ansible.utils.ipcut(first, 64)
1234:4321:abcd:dcba
Edit:
As I need that for nftables, the result needs to be in expanded format.