is there any way to use cloud-init configs in python libvirt? cloud-init require to create an iso, which seems that ovirt support cloud-config: https://red.ht/2K1gBkn But how can I do that by python libvirt? I know I can mount iso by python libvirt to the VM, but the process of creating iso file is the problem which if it is possible to enter the cloud-config commands by libvirt could be better to me. Regards
On Tue, Apr 14, 2020 at 12:35:02AM +0430, PunkGeek wrote:> is there any way to use cloud-init configs in python libvirt? > cloud-init require to create an iso, which seems that ovirt support > cloud-config: https://red.ht/2K1gBkn > But how can I do that by python libvirt?Cloud-init is out of scope of libvirt, so with libvirt, mounting the ISO is your only option. Outside of libvirt, I'd look at virt-install whether the cloud-init support currently in place is sufficient for your use case. Bear in mind though that cloud-init support in virt-install was added shortly after the 2.2.1 release and we haven't had a new release since then, so you'd have to use virt-install directly from git, maybe Cole can shed a bit more light on when the next virt-install release is planned. -- Erik Skultety
On 4/13/20 4:05 PM, PunkGeek wrote:> is there any way to use cloud-init configs in python libvirt? > cloud-init require to create an iso, which seems that ovirt support > cloud-config: https://red.ht/2K1gBkn > But how can I do that by python libvirt? > > I know I can mount iso by python libvirt to the VM, but the process of > creating iso file is the problem which if it is possible to enter the > cloud-config commands by libvirt could be better to me. > RegardsThe short answer is yes. I have put together an ansible role to build cloud init based qcow images and does the most basic of configs based on the vars passed to the role. you need to create an ISO with 2 files: "meta-data" and "user-data" then run something like the folowing command to create the ISO. genisoimage -output myvmconfig.iso -volid cidata -joliet -r cloudinit_src_dir/ Then you create and start your VM with the ISO attached. On the first reboot of the VM you could remove the ISO so long as cloud-init is not going to run again. My work was done using ansible and the standard virsh commands so your build process will be different -- Alvin Starr || land: (647)478-6285 Netvel Inc. || Cell: (416)806-0133 alvin@netvel.net ||