Generate IPv6 ULA /64 subnet

Hello all,
Is there a way to generate an IPv6 ULA /64 subnet subnet?
I’ve been looking in the docs but nowhere can I find how to do this.

Some Google-fu gave me this command, which works locally, but not when ran through ansible using ansible.builtin.shell:
printf “fd%x:%x:%x:%x::/64” “$(( $RANDOM/256 ))” “$RANDOM” “$RANDOM” “$RANDOM”

Anybody who has a solution or workaround for this?

Considering that $RANDOM

is an internal Bash function (not a constant) that returns a pseudorandom integer in the range 0 - 32767

the almost exact equivalent to the given command

printf "fd%x:%x:%x:%x::/64\n" "$(( $RANDOM/256 ))" "$RANDOM" "$RANDOM" "$RANDOM"

resulting into a random output like

fd1:4dd9:8f1:6ea7::/64

would be in Ansible

---
- hosts: localhost
  become: false
  gather_facts: false

  tasks:

    - name: Generate an IPv6 Unique Local Address (ULA) /64 subnet
      debug:
        msg: "fd{{ '%02x' % ((127 | random) | int) }}:{{ '%x' % ((32767 | random) | int) }}:{{ '%x' % ((32767 | random) | int) }}:{{ '%x' % ((32767 | random) | int) }}::/64"

resulting into a random output of

TASK [Generate an IPv6 Unique Local Address (ULA) /64 subnet] ***
ok: [localhost] =>
  msg: fd01:4dd9:8f1:6ea7::/64

by using Python Format with % within Jinja2 Template.

Great, that seems to work!
Don’t think I would have ever found this myself.