Provisioning VMs with community.libvirt.virt_install

Hi all, I’m trying to provision some VMs with the community.libvirt.virt_install module but apparently I can’t get them working, maybe I’m misunderstanding something in the docs

Unattended install

This is the snippet, basically copied from the docs:

  tasks:
    - name: Ubuntu install
      community.libvirt.virt_install:
        name: ubuntu-server
        memory: 2048
        vcpus: 2
        disks:
          - size: 25
        osinfo:
          name: ubuntu20.04
        location: http://archive.ubuntu.com/ubuntu/dists/focal/main/installer-amd64/
        unattended:
          profile: jeos
          admin_password_file: /tmp/root_password
          user_login: ansible
          user_password_file: /tmp/user_password
        networks:
          - network: default

Where /tmp/user_password and /tmp/root_password just contain the string my-secret-password.

VM is running, using CPU/RAM and answering to pings, but the console (through shell or cockpit) just shows

Connected to domain 'ubuntu-server'
Escape character is ^] (Ctrl + ])

while if it’s installing I should see something (?) and the SSH port is closed

Cloud image

I also tried to provision a VM from a cloud image with cloud-init and got errors:

I downloaded and converted to qcow2 a Kali Linux image using qemu img, as /tmp/base-kali.qcow2 then created a qcow2 img referencing it qemu-img create -b /tmp/base-kali.qcow2 -f qcow2 -F qcow2 /tmp/overlay-kali.qcow2 10G

  tasks:
    - name: Create Kali VM from cloud image
      community.libvirt.virt_install:
        name: kali
        state: present
        memory: 2048
        vcpus: 1
        disks:
          - path: "/tmp/overlay-kali.qcow2"
        import: true
        cloud_init:
          clouduser_ssh_key: "ssh-rsa (...)"
        networks:
          - network: default
        osinfo:
          name: debian13

Also tried using both disks and nothing, always the same error, Ansible fails stating it can’t found a file (and its path is redacted)

1 Like