kubevirt_vm: Allow to specify DataVolume templates

By allowing to specify DataVolume templates VMs with persistent storage
can be created using the kubevirt_vm module.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This commit is contained in:
Felix Matouschek
2023-07-17 11:05:02 +02:00
parent 1e94c19ac4
commit bce4f17188
4 changed files with 185 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
- hosts: localhost
tasks:
- name: Create VM
kubernetes.kubevirt.kubevirt_vm:
state: present
name: testvm-with-dv
namespace: default
labels:
app: test
instancetype:
name: u1.medium
preference:
name: fedora
data_volume_templates:
- metadata:
name: testdv
spec:
source:
registry:
url: docker://quay.io/containerdisks/fedora:latest
storage:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
spec:
domain:
devices: {}
volumes:
- dataVolume:
name: testdv
name: datavolume
- cloudInitNoCloud:
userData: |-
#cloud-config
# The default username is: fedora
ssh_authorized_keys:
- ssh-ed25519 AAAA...
name: cloudinit
wait: yes

View File

@@ -0,0 +1,8 @@
- hosts: localhost
tasks:
- name: Delete VM
kubernetes.kubevirt.kubevirt_vm:
name: testvm-with-dv
namespace: default
state: absent
wait: yes