Giter Site home page Giter Site logo

kvm_provision_lab's People

Contributors

tronde avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

ranjeetbadhe

kvm_provision_lab's Issues

[RFE] Improve configuration options for network interfaces

Currently this role supports connecting domains to the default network, only. That's due to the current code in the templates:

    <interface type='network'>
      <source network='{{ item.value.vm_net }}'/>
      <model type='virtio'/>
      <link state='up'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </interface>

With this code it's not possible to connect a domain to a network in bridged mode..

The <interface> tag for a bridged network would look like:

    <interface type='bridge'>
      <source bridge='{{ item.value.vm_net }}'/>
      <model type='virtio'/>
      <link state='up'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </interface>

Maybe the <address type/> and <alias name/> are not even necessary in template file. I'll have to check on that.

To improve this role to enable it configuring domains to connect to bridged networks a new variable, e.g. if_type, could be introduced carrying the network type [network|bridge]. So in the template files it would look like the following:

     <interface type='{{ item.value.if_type }}'>
      <source {{ item.value.if_type }}='{{ item.value.vm_net }}'/>
      <model type='virtio'/>
      <link state='up'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </interface>

Documentation

A second HDD created by this role is not useable in guest.

Playbook and var file being used

---
- name: Provision Debian lab VMs
  hosts: localhost
  debugger: never
  vars_files:
    - roles/kvm_provision_lab/vars/debian11_with_2nd_disk.yml
  tasks:
    - name: Run role kvm_provision_lab
      include_role:
        name: kvm_provision_lab
---
libvirt_pool_dir: "/var/lib/libvirt/images"
vm_root_pass: "Password"
ssh_key: "ansible_id_rsa.pub"

guests:
  debian-t1:
    vm_ram_mb: 1024
    vm_vcpus: 1
    vm_net: default
    os_type: debian11
    file_type: qcow2
    base_image_name: debian11-template
    vm_template: "debian11-template"
    second_hdd: true
    second_hdd_size: 2G

Expected result

I would have expected that the guest is created with a second disk of a useable size of 2 GiB.

Actual result

The guest OS shows a usaable size of a few KiB for /dev/vdb:

# lsblk /dev/vdb
NAME MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
vdb  254:16   0 192.5K  0 disk

The command qemu-img info /var/lib/libvirt/images/debian-t1-vdb.qcow2 shows it has a usable size of 2 GiB though:

$ qemu-img info /var/lib/libvirt/images/debian-t1-vdb.qcow2 
image: /var/lib/libvirt/images/debian-t1-vdb.qcow2
file format: qcow2
virtual size: 2 GiB (2147483648 bytes)
disk size: 196 KiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    compression type: zlib
    lazy refcounts: false
    refcount bits: 16
    corrupt: false
    extended l2: false

Additional information

When an additional disk is created by running qemu-img create -q -f qcow2 /var/lib/libvirt/images/debian-t1-vdc.qcow2 2G and attached to the VM it shows the correct size in guest OS:

# lsblk /dev/vd{b,c}
NAME MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
vdb  254:16   0 192.5K  0 disk 
vdc  254:32   0     2G  0 disk

And it gets weird:

$ qemu-img info /var/lib/libvirt/images/debian-t1-vdc.qcow2
image: /var/lib/libvirt/images/debian-t1-vdc.qcow2
file format: qcow2
virtual size: 2 GiB (2147483648 bytes)
disk size: 196 KiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    compression type: zlib
    lazy refcounts: false
    refcount bits: 16
    corrupt: false
    extended l2: false

$ qemu-img compare /var/lib/libvirt/images/debian-t1-vdb.qcow2 /var/lib/libvirt/images/debian-t1-vdc.qcow2
Images are identical.
``

So far I have absolutely no clue and now idea what causes this. Help would be much appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.