libguestfs / guestfs-tools

Tools for accessing and modifying guest disk images
https://libguestfs.org
GNU General Public License v2.0
15 stars 7 forks source link

Ensure the machine-id operation is the last one #6

Open cjeanner opened 2 years ago

cjeanner commented 2 years ago

We must ensure the modified image doesn't have any content in /etc/machine-id file. This will then trigger the usual systemd-machine-id-setup during the first boot of the image, ensuring we'll get an as unique as possible ID.

This is mandatory, since the tools are generating a machine-id at different stages, for instance in order to ensure packages are installing without any issue[1]

Of course, if the operator wants to get an actual machine-id, they can just disable the "machine-id" operation. Note that it's enabled by default, so the issue is more about ordering than anything.

[1] For instance here: https://github.com/rwmjones/guestfs-tools/blob/3a498512f58bc431db490e96cdb712b19389bda4/customize/customize_run.ml#L170-L188

rwmjones commented 2 years ago

Patch sort of looks reasonable, although running it after the --customize operations [edit: which have order 99] might be wrong since those operations might be needed to fix any earlier built-in operation. However I asked on the bug for a reproducer so I can understand the exact sequence of steps that is being done and what goes wrong, because without that I cannot really tell if the bug has been fixed or not.