diff options
-rw-r--r-- | common/vm-deploy.yml | 16 | ||||
-rw-r--r-- | roles/vm/guest/deploy/defaults/main.yml | 3 | ||||
-rw-r--r-- | roles/vm/guest/deploy/tasks/main.yml | 3 |
3 files changed, 17 insertions, 5 deletions
diff --git a/common/vm-deploy.yml b/common/vm-deploy.yml index bc2e8039..5368df3e 100644 --- a/common/vm-deploy.yml +++ b/common/vm-deploy.yml @@ -8,19 +8,29 @@ fail: msg: "the host '{{ install_hostname }}' does not belong to the group 'kvmguests'" when: - - "'kvmguests' not in group_names" + - "'kvmguests' not in group_names" - name: check if the host system belongs to the kvmhosts group fail: msg: "the host '{{ vm_host.name }}' does not belong to the group 'kvmhosts'" when: - - "'kvmhosts' not in hostvars[vm_host.name].group_names" + - "'kvmhosts' not in hostvars[vm_host.name].group_names" - name: check if there is only one output image fail: msg: "the output_images variable must only contain a single image" when: - - (output_images | length) != 1 + - (output_images | length) != 1 + + - name: get primary disk config + set_fact: + vm_deploy_primary_disk: "{{ (install.disks.virtio | default({}) | combine(install.disks.scsi | default({})))[(install.disks.primary | basename)] | default({'type': ''}) }}" + + - name: check if primary disk is of type image + fail: + msg: "the primary disk must be pointing to a disk device of type image" + when: + - vm_deploy_primary_disk.type != 'image' - name: deploy vm diff --git a/roles/vm/guest/deploy/defaults/main.yml b/roles/vm/guest/deploy/defaults/main.yml index c067ecbc..63deb439 100644 --- a/roles/vm/guest/deploy/defaults/main.yml +++ b/roles/vm/guest/deploy/defaults/main.yml @@ -5,3 +5,6 @@ vm_deploy_decompressors: "application/zstd": unzstd "application/x-bzip2": bunzip2 "application/x-xz": unxz + +# vm_deploy_primary_disk: +# path: /srv/root.img diff --git a/roles/vm/guest/deploy/tasks/main.yml b/roles/vm/guest/deploy/tasks/main.yml index f22af8af..5fb5b56f 100644 --- a/roles/vm/guest/deploy/tasks/main.yml +++ b/roles/vm/guest/deploy/tasks/main.yml @@ -7,7 +7,6 @@ register: output_image_info ## TODO: prepare directory for disk images - ## TODO: compute disk path based on install.disks.primary and install.disks.(scsi|virtio) ## TODO: actually call this directly and make file replacement atomic!! ## Probably by writing and action plugin based on this: https://github.com/socratesx/Ansible-Decompress - name: copy disk image @@ -15,7 +14,7 @@ prompt: | Please copy the image to the vm-host i.e. by calling this: - cat {{ output_image_info.stat.path }} | {{ vm_deploy_decompressors[output_image_info.stat.mimetype] }} | ssh {{ vm_host.name }} 'cat > {{ install.disks.scsi.sda.path }}' + cat {{ output_image_info.stat.path }} | {{ vm_deploy_decompressors[output_image_info.stat.mimetype] }} | ssh {{ vm_host.name }} 'cat > {{ vm_deploy_primary_disk.path }}' When done press ENTER to continue or CTRL-C then A to abort. |