znerol.ipaddr_hash
Ansible Role: ipaddr_hash
This is a simple tool that helps create IPv6 addresses based on a prefix and a "seed" value, like a hostname.
It’s great for anyone wanting a consistent way to assign IPv6 addresses to devices using their hostnames.
How It Works
The process to create an IP address is straightforward:
ip = prefix + (sha256(seed) & hostmask)
Requirements
None needed.
Role Variables
None to set.
Dependencies
- You need the Python module netaddr on your controller.
Example Playbook
Here’s how to use the 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 will produce the address: 2001:db8::13d2:1255:86ce:1947
.
For more examples, see test/test.yml.
License
GPLv3