Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IP address filter to get the last or first X bits of an IP address #251

Closed
imp1sh opened this issue Apr 18, 2023 · 1 comment · Fixed by #291
Closed

IP address filter to get the last or first X bits of an IP address #251

imp1sh opened this issue Apr 18, 2023 · 1 comment · Fixed by #291
Assignees
Labels
enhancement New feature or request

Comments

@imp1sh
Copy link

imp1sh commented Apr 18, 2023

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.

@Qalthos Qalthos added the enhancement New feature or request label Apr 19, 2023
@ashwini-mhatre ashwini-mhatre self-assigned this Jul 4, 2023
@imp1sh
Copy link
Author

imp1sh commented Aug 7, 2023

Wow, that's great. Can't wait to test this.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Sep 18, 2023
v8.4.0

Major Changes
-------------

fortinet.fortios

- Improve the document for adding notes and examples in Q&A for modules using Integer number as the mkey.

Minor Changes
-------------

amazon.aws

- cloudformation - Add support for ``disable_rollback`` to update stack operation (ansible-collections/amazon.aws#1681).
- ec2_key - add support for new parameter ``file_name`` to save private key in when new key is created by AWS. When this option is provided the generated private key will be removed from the module return (ansible-collections/amazon.aws#1704).

ansible.netcommon

- Add a new cliconf plugin ``default`` that can be used when no cliconf plugin is found for a given network_os. This plugin only supports ``get()``. (ansible-collections/ansible.netcommon#569)
- httpapi - Add additional option ``ca_path``, ``client_cert``, ``client_key``, and ``http_agent`` that are available in open_url but not to httpapi. (ansible-collections/ansible.netcommon#528)
- telnet - add crlf option to send CRLF instead of just LF (ansible-collections/ansible.netcommon#440).

ansible.utils

- Add ipcut filter plugin.(ansible-collections/ansible.utils#251)
- Add ipv6form filter plugin.(ansible-collections/ansible.utils#230)

arista.eos

- Add support for overridden operation in bgp_global resource module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants