stackhpc / stackhpc/ansible-role-libvirt-vm

Failed to use this roles with lvm

Open
#61 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jinja
Stars
135
Forks
73
Avg merge
4d 22h
Merged PRs (30d)
1

Description

I've failed to use this roles with lvm (at least on debian 10)

Error

if data to created VM is :

  volumes:
    - name: 'ns2'
      type: 'volume'
      capacity: '10GB'
      pool: 'lvm_pool'
      format: 'raw'

The role is crashing with this error

    "msg": "internal error: qemu unexpectedly closed the monitor: 2020-09-11T12:51:05.508705Z qemu-system-x86_64: -drive file=/dev/lvm_pool/ns3,format=raw,if=none,id=drive-virtio-disk0: Could not open '/dev/lvm_pool/ns3': Permission denied"

Debugging

  • Debugging, virsh dumpxml <nodename> give me :
    <disk type='volume' device='disk'>
      <driver name='qemu' type='raw'/>
      <source pool='lvm_pool' volume='ns3'/>
      <target dev='vda' bus='virtio'/>
    </disk>
  • Update the node via virsh edit <node>
    • replace <disk type='volume' device='disk'> with <disk type='block' device='disk'>
    • replace <source pool='lvm_pool' volume='ns3'/> with <source dev='/dev/lvm_pool/ns3'/>

It's now can boot

Change need

To permit these two line change (done on virsh edit) via ansible and your role :

  • Need to add this in the template vm.xml.j2 :
      {% elif volume.pool is defined %}
      <source dev='/dev/{{ volume.pool }}/{{ volume.name }}'/>
  • Need to change type from volume to block, so my variable will be :
  volumes:
    - name: 'ns2'
      type: 'block'
      capacity: '10GB'
      pool: 'lvm_pool'
      format: 'raw'
  • As it's now a block volume, the tasks Ensure the VM volumes exist will be skipped (due to when condition)
    So needed to update volumes.yml condition (line 30)

from : when: item.type | default(libvirt_volume_default_type) == 'volume'
to : when: item.type | default(libvirt_volume_default_type) == 'volume' or ( item.type | default(libvirt_volume_default_type) == 'block' and item.pool is defined )

  • Maybe, it's will also good to update the README to have a lvm example .

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with vm.xml.j2 and volumes.yml around the named line 30 condition to trace how LVM-backed volumes are rendered and created. Check the README for the existing volume examples. Done means an Ansible configuration using a pool-backed block volume can create the volume and boot the VM without the reported permission error.

Written by the indexing model from the issue text.

Assessment

Tech stack
ansible
Domain
infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.