Comment 8 for bug 1905932

Revision history for this message
forceps (ubuntubugs-web) wrote :

I found a workaround using late-commands.
Note that that "curtin in-target --target=/target -- <cmd>" won't work if <cmd> contains stdout redirection, perhaps requiring some quote encapsulation. I avoid this confusion by just writing straight to /target. I find it easier to understand.

Below is a minimal working user-data file:

#cloud-config
autoinstall:
  version: 1
  identity:
    hostname: localhost
    username: ubuntu
    password: <mkpasswd output>
  late-commands:
    - getent hosts $(ip -o -4 address show scope global | head -n 1 | awk '{print $4}' | awk -F '/' '{print $1}') | awk '{print $2}' | awk -F '.' '{print $1}' > /target/etc/hostname

This command assumes that the first active non-loopback IPv4 address on the system reverse resolves to the desired hostname.

It would be nice to have this as a built-in feature. Currently, autoinstall is a step back compared to the preseed framework in this important domain.