stackhpc / ansible-role-libvirt-vm

This role configures and creates VMs on a KVM hypervisor.
128 stars 67 forks source link

Allow uploading volumes from host that launched the playbook #78

Closed jlsm-se closed 3 years ago

jlsm-se commented 3 years ago

For example if I have a file my-cloud-image.qcow2 (in the same directory as my playbook) that I want to create a new VM and boot from and I have two storage pools configured: "vms" (/var/lib/libvirt/vms) and "images" (/var/lib/libvirt/images)

libvirt_vm_image_cache_path: /var/lib/libvirt/images                                                                                                                                                         
libvirt_vms:                                                                                                                                                                                                 
  - name: test.example.com                                                                                                                                                                          
    state: present                                                                                                                                                                                           
    memory_mb: 4096                                                                                                                                                                                          
    vcpus: 2                                                                                                                                                                                                                                                                                                                                                                              
    volumes:                                                                                                                                                                                                                                                                                                                                              
      - name: test.example.com-root-disk                                                                                                                                                                        
        type: volume                                                                                                                                                                                         
        checksum: f3cd51fag5a6561d2e49e40d026625948c642c57                                                                                                                                                   
        capacity: 25GB                                                                                                                                                                                       
        format: qcow2                                                                                                                                                                                        
        pool: vms                                                                                                                                                                                            
        image: my-cloud-image.qcow2                                                                                                                                       
        remote_src: false 

With this patch, my-cloud-image.qcow2 would be copied to /var/lib/libvirt/images and /var/lib/libvirt/vms/test.example.com-root-disk would be created from it as the boot disk.