hostname: add $ hostname substitution and petnames

This commit adds support to /etc/hostname for substitution
of $ wordlists from {/etc,/run,/usr/lib}/systemd/hostname-wordlist.
The first $ will lookup hostname-wordlist/1, the next
hostname-wordlist/2 and so on.

With that we can do a petname [1] style hostname in systemd, e.g.
below a possible expansion for a hostname template:

    $-$-$-????  ->  wildly-happy-octopus-92a9

The substitution of words is stable (based on machine-id) but
not persisted, it is picked on every boot via a stable file
offset so the operation is cheap. But this means that if the
wordlist changes the hostname would change. The next commit
will add the pattern to the firstboot.hostname credential which
is persistet with the resolved names to avoid this issue.

This also includes a wordlist from the "petname" project
that can be optionally installed.

Thanks to Dustin Kirkland for this wonderful project.

[1] https://github.com/dustinkirkland/petname
This commit is contained in:
Michael Vogt
2026-06-20 14:26:41 +02:00
parent aa0f05173b
commit df12d58f8b
16 changed files with 1551 additions and 53 deletions
+1
View File
@@ -2454,6 +2454,7 @@ subdir('test')
#####################################################################
subdir('docs/var-log')
subdir('hostname-wordlist')
subdir('hwdb.d')
subdir('man')
subdir('modprobe.d')