https://github.com/znerol/ansible-role-ipaddr-hash
Provides a Jinja2 filter plugin to compute an IP address given a prefix and a seed, e.g., the `inventory_hostname`.
https://github.com/znerol/ansible-role-ipaddr-hash
Last synced: 11 months ago
JSON representation
Provides a Jinja2 filter plugin to compute an IP address given a prefix and a seed, e.g., the `inventory_hostname`.
- Host: GitHub
- URL: https://github.com/znerol/ansible-role-ipaddr-hash
- Owner: znerol
- License: gpl-3.0
- Created: 2020-05-25T12:25:15.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-06-15T10:57:19.000Z (almost 3 years ago)
- Last Synced: 2025-04-07T23:41:34.557Z (about 1 year ago)
- Language: Python
- Size: 18.6 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
Ansible Role: ipaddr\_hash
==========================
[](https://travis-ci.org/znerol/ansible-role-ipaddr-hash)
Provides a Jinja2 filter plugin to compute an IP address given a prefix and a
seed, e.g., the `inventory_hostname`.
This plugin is useful for people seeking a predictable addressing scheme for
statically assigned IPv6 addresses based on hostnames.
The algorithm used to derive an ip is simple:
ip = prefix + (sha256(seed) & hostmask)
Requirements
------------
None
Role Variables
--------------
None
Dependencies
------------
* Python module [netaddr](https://pypi.org/project/netaddr/) on controller.
Example Playbook
----------------
Usage of `ipaddr_hash` filter:
- hosts: localhost
tasks:
- import_role:
name: znerol.ipaddr_hash
- debug:
msg: "Generated IPv6 address for example.com with prefix '2001:db8::/64' is {{ '2001:db8::/64' | ipaddr_hash('example.com') }}"
This should generate the address: `2001:db8::13d2:1255:86ce:1947`.
See [test/test.yml](tests/test.yml) for sample input/output.
License
-------
GPLv3