How to properly clone a registered host running on VMware

Problem: Any time I clone a VM, it’s still tied to the source that it’s cloned from. What I’ve tried to do to get this to work is to remove the following files:

/var/lib/dbus/machine-id
/etc/machine-id

Some documentation I found online says to also remove /etc/rhsm/facts/katello.facts but that file doesn’t exist (I guess because I’m not using the katello agent due to deprecation).

But every time I do a registration it complains that a host with the ID already exists and that I must use the --force switch which unregisters the source host.

Expected outcome: I would expect that removing these files and regenerating them would allow me to properly register these as new hosts in Foreman without having to touch the source.

Foreman and Proxy versions: 3.5.1

Foreman and Proxy plugin versions: 3.5.1

Distribution and version: Rocky Linux 8.8

So after some trial and error, I’ve managed to get this to work. Here’s my workflow for anyone else that may be running into this issue:

Remove the following files:

rm -f /etc/machine-id
rm -f /var/lib/dbus/machine-id

Run the following:

dbus-uuidgen --ensure
systemd-machine-id-setup
subscription-manager clean

Then reregister using subscription-manager and you should be all set.

Edit: forgot to mention my hosts are all Rocky Linux 8

1 Like