|
| 1 | +Libvirt VM |
| 2 | +========== |
| 3 | + |
| 4 | +This role configures an creates (or destroys) a VM on a KVM hypervisor. |
| 5 | + |
| 6 | +Requirements |
| 7 | +------------ |
| 8 | + |
| 9 | +The host should have Virtualization Technology (VT) enabled and should |
| 10 | +be preconfigured with libvirt/KVM. |
| 11 | + |
| 12 | +Role Variables |
| 13 | +-------------- |
| 14 | + |
| 15 | +`libvirt_vm_state`: set to `present` to create or `absent` to destroy the VM. |
| 16 | +Defaults to `present`. |
| 17 | + |
| 18 | +`libvirt_vm_name`: the name to assign to the VM. |
| 19 | + |
| 20 | +`libvirt_vm_memory_mb`: the memory to assign to the VM, in megabytes. |
| 21 | + |
| 22 | +`libvirt_vm_vcpus`: the number of VCPU cores to assign to the VM. |
| 23 | + |
| 24 | +`libvirt_vm_volumes`: a list of volumes to attach to the VM. Each volume is |
| 25 | +defined with the following dict: |
| 26 | +- `name`: Name to associate with the volume being created. |
| 27 | +- `device`: `disk` |
| 28 | +- `format`: options include `raw`, `qcow2`, `vmdk`. See `man virsh` for the |
| 29 | +full range. Default is `qcow2` |
| 30 | +- `capacity`: volume capacity (can be suffixed with M,G,T or MB,GB,TB, etc) |
| 31 | +- `image`: (optional) a URL to an image with which the volume is initalised. |
| 32 | +- `pool`: Name or UUID of the storage pool from which the volume should be |
| 33 | +allocated. |
| 34 | + |
| 35 | +`libvirt_vm_interfaces`: a list of network interfaces to attach to the VM. |
| 36 | +Each network interface is defined with the following dict: |
| 37 | +- `network`: Name of the network to which an interface should be attached. |
| 38 | + |
| 39 | +`libvirt_vm_image_cache_path`: path to cache downloaded images. |
| 40 | + |
| 41 | +Dependencies |
| 42 | +------------ |
| 43 | + |
| 44 | +None |
| 45 | + |
| 46 | +Example Playbook |
| 47 | +---------------- |
| 48 | + |
| 49 | + --- |
| 50 | + - name: Create a VM |
| 51 | + hosts: hypervisor |
| 52 | + roles: |
| 53 | + - role: stackhpc.libvirt-vm |
| 54 | + libvirt_vm_state: present |
| 55 | + libvirt_vm_name: 'my-vm' |
| 56 | + libvirt_vm_memory_mb: 512 |
| 57 | + libvirt_vm_vcpus: 2 |
| 58 | + libvirt_vm_volumes: |
| 59 | + - name: 'data' |
| 60 | + device: 'disk' |
| 61 | + format: 'qcow2' |
| 62 | + capacity: '400GB' |
| 63 | + pool: 'my-pool' |
| 64 | + libvirt_vm_interfaces: |
| 65 | + - network: 'br-datacentre' |
| 66 | + |
| 67 | +Author Information |
| 68 | +------------------ |
| 69 | + |
| 70 | +- Mark Goddard ( <[email protected]>) |
0 commit comments