Closed velis74 closed 4 years ago
Are you thinking that the hostname should be set via DHCP? I would have
thought /etc/machine-id
would have been generated with a unique id:
systemd-machine-id-setup may be used by system installer tools to initialize the machine ID stored in /etc/machine-id at install time, with a provisioned or randomly generated ID. See machine-id(5) for more information about this file.
If the tool is invoked without the --commit switch, /etc/machine-id is initialized with a valid, new machined ID if it is missing or empty. The new machine ID will be acquired in the following fashion:
If a valid D-Bus machine ID is already configured for the system, the D-Bus machine ID is copied and used to initialize the machine ID in /etc/machine-id.
If run inside a KVM virtual machine and a UUID is configured (via the -uuid option), this UUID is used to initialize the machine ID. The caller must ensure that the UUID passed is sufficiently unique and is different for every booted instance of the VM.
https://www.freedesktop.org/software/systemd/man/systemd-machine-id-setup.html
Is this not the case?
Each vm in the libvirt_vms
list has a name
field.
@markgoddard yes, it does, but that's not how ansible finds it: it will find it by its host name. And the hostname is copied from the template disk file
@jovial see above, I think you both are assuming I'm providing a clean image file and then running a setup. I'm sorry, but I failed to mention the fact that I'd like to copy a prepared image in the OP
I think this issue is outside the scope of this role. We will give the VM a name, but we do not access the VM in any way after it has been created.
OK, that's confirmed then. Is there a recommended method of doing that, then?
I usually use a config-drive to give the machine an IP, then access it via IP. Alternatively you could add it to your DNS server or /etc/hosts to get the name to resolve.
We are using virt-edit and virt-customize of libguestfs-tools package, but thanks for the info / suggestions. Closing issue.
I'm in the middle of moving to ansible for all my machine provisioning. After successfully integrating your libvirt-host role, I got to this one.
However, after inspecting the code, I don't see how this role takes care of making the newly provisioned VMs unique in terms of hostname and machine-id. I don't know if that's all I need, but at least these two are all but mandatory in order for a machine to even work.
Should I include another role that takes care of this or does this one do it in a way I can't see?