kvmhost_setup Role Reference¶
Complete reference documentation for the main orchestration role in the Qubinode KVM Host Setup Collection.
📋 Role Overview¶
Purpose: Main orchestration role that coordinates all KVM host setup tasks Type: Orchestration role Dependencies: All other collection roles Minimum Ansible: 2.13.0
🔧 Variables Reference¶
Core Configuration Variables¶
Basic Setup¶
Variable |
Type |
Default |
Required |
Description |
---|---|---|---|---|
|
boolean |
|
No |
Set to true when host is virtual or running in a container |
|
boolean |
|
No |
Set to true to enable libvirt and KVM |
|
boolean |
|
No |
Set to true to enable Cockpit web interface |
|
boolean |
|
No |
Configure the user bash shell login prompt |
Network Configuration¶
Variable |
Type |
Default |
Required |
Description |
---|---|---|---|---|
|
string |
|
Yes |
KVM host IP address |
|
string |
|
Yes |
KVM host IP address (alias) |
|
string |
|
Yes |
Primary network interface |
|
string |
|
Yes |
Network gateway |
|
string |
|
Yes |
Network netmask |
|
integer |
|
Yes |
CIDR prefix length |
|
string |
|
No |
Boot protocol (dhcp/static) |
|
string |
|
No |
Bridge type |
|
string |
|
No |
Bridge network name |
|
string |
|
No |
Host domain name |
|
string |
|
No |
Primary DNS server |
Storage Configuration¶
Variable |
Type |
Default |
Required |
Description |
---|---|---|---|---|
|
string |
|
No |
Libvirt images directory |
|
boolean |
|
No |
Configure libvirt storage |
|
string |
|
No |
VM disk images directory |
|
string |
|
No |
Default storage pool name |
User Configuration¶
Variable |
Type |
Default |
Required |
Description |
---|---|---|---|---|
|
string |
|
Yes |
SSH username for KVM server |
|
boolean |
|
No |
Add admin_user to libvirt group |
|
string |
|
No |
Libvirt admin group |
|
list |
|
No |
Users whose shell will be configured |
Advanced Configuration Variables¶
Performance Optimization¶
Variable |
Type |
Default |
Required |
Description |
---|---|---|---|---|
|
boolean |
|
No |
Enable KVM performance optimizations |
|
integer |
|
No |
Hugepages percentage of total memory |
|
string |
|
No |
CPU frequency governor |
|
boolean |
|
No |
Enable CPU isolation for VMs |
|
boolean |
|
No |
Enable Kernel Same-page Merging |
|
integer |
|
No |
KSM pages to scan |
|
integer |
|
No |
KSM sleep interval |
|
boolean |
|
No |
Enable nested virtualization |
|
boolean |
|
No |
Enable network performance optimizations |
Network Performance Sysctls¶
Variable |
Type |
Default |
Description |
---|---|---|---|
|
dict |
See below |
System kernel parameters for optimization |
kvm_performance_sysctls:
# Memory management
vm.swappiness: 1
vm.vfs_cache_pressure: 50
vm.dirty_background_ratio: 5
vm.dirty_ratio: 10
vm.dirty_writeback_centisecs: 500
vm.dirty_expire_centisecs: 3000
# Network performance
net.core.default_qdisc: fq_codel
net.ipv4.tcp_congestion_control: bbr
net.core.rmem_max: 268435456
net.core.wmem_max: 268435456
net.core.rmem_default: 65536
net.core.wmem_default: 65536
net.core.netdev_max_backlog: 5000
# Bridge optimizations
net.bridge.bridge-nf-call-ip6tables: 0
net.bridge.bridge-nf-call-iptables: 0
net.bridge.bridge-nf-call-arptables: 0
Complex Data Structures¶
Libvirt Host Networks¶
libvirt_host_networks:
- name: "{{ vm_libvirt_net | default('qubinet') }}"
create: true
mode: bridge
bridge_device: "{{ kvm_host_bridge_name | default(qubinode_bridge_name) }}"
ifcfg_type: "{{ kvm_bridge_type }}"
ifcfg_bootproto: "{{ kvm_host_bootproto }}"
bridge_slave_dev: "{{ kvm_host_interface }}"
gateway: "{{ kvm_host_gw }}"
mask_prefix: "{{ kvm_host_mask_prefix }}"
ipaddress: "{{ kvm_host_ip }}"
mask: "{{ kvm_host_netmask }}"
mac: "{{ kvm_host_macaddr }}"
Storage Pools Configuration¶
libvirt_host_storage_pools:
- name: default
state: active
autostart: true
path: "{{ kvm_host_libvirt_dir }}"
🔄 Task Flow¶
Main Task Sequence¶
RHEL Version Detection (
rhel_version_detection.yml
)GPG Key Verification (
gpg_verification.yml
)Variable Validation (
verify_variables.yml
)Package Installation (with GPG verification)
Shell Configuration (
configure_shell.yml
) - if enabledCockpit Setup (
cockpit_setup.yml
) - if enabledRocky Linux Setup (
rocky_linux.yml
) - if Rocky LinuxRHPDS Configuration (
rhpds_instance.yml
) - if GUID setRemote User Setup (
configure_remote_user.yml
) - if GUID setLibvirt Setup (
libvirt_setup.yml
) - if enabledKVM Feature Detection (
kvm_feature_detection.yml
)Performance Optimization (
performance_optimization.yml
)
Conditional Execution¶
# Cockpit setup conditions
when: enable_cockpit|bool and ansible_distribution != "Rocky"
# Rocky Linux specific
when: enable_cockpit|bool and (ansible_distribution == "Rocky")
# RHPDS environment
when: enable_cockpit|bool and lookup('env', 'GUID', default='') != ""
# Libvirt setup
when: lib_virt_setup|bool
# Performance optimization
when: enable_kvm_performance_optimization|default(true)|bool
📤 Return Values and Facts¶
Generated Facts¶
Fact |
Type |
Description |
---|---|---|
|
dict |
Detected KVM hardware features |
|
list |
Configured libvirt networks |
|
list |
Created storage pools |
|
list |
Applied performance optimizations |
Example Return Values¶
kvm_features_detected:
nested_virtualization: true
hardware_acceleration: true
cpu_features: ["vmx", "svm"]
libvirt_networks_configured:
- name: "qubinet"
bridge: "qubibr0"
state: "active"
storage_pools_created:
- name: "default"
path: "/var/lib/libvirt/images"
state: "active"
🔗 Dependencies¶
Role Dependencies¶
This role orchestrates the following roles:
kvmhost_base
- Base system configurationkvmhost_networking
- Network bridge setupkvmhost_libvirt
- Libvirt configurationkvmhost_storage
- Storage managementkvmhost_cockpit
- Web interface setupkvmhost_user_config
- User environment
Collection Dependencies¶
collections:
- community.libvirt
- ansible.posix
- community.general
System Dependencies¶
libvirt-daemon
qemu-kvm
NetworkManager
Python 3.9+
📝 Usage Examples¶
Basic Usage¶
- hosts: kvm_hosts
become: true
vars:
admin_user: "kvmadmin"
kvm_host_ipaddr: "192.168.1.100"
kvm_host_interface: "ens3"
roles:
- tosin2013.qubinode_kvmhost_setup_collection.kvmhost_setup
Advanced Configuration¶
- hosts: kvm_hosts
become: true
vars:
# User configuration
admin_user: "kvmadmin"
# Network configuration
kvm_host_ipaddr: "10.0.1.100"
kvm_host_interface: "ens3"
kvm_host_gw: "10.0.1.1"
kvm_host_netmask: "255.255.255.0"
kvm_host_mask_prefix: 24
qubinode_bridge_name: "kvmbr0"
# Feature toggles
enable_cockpit: true
configure_shell: true
lib_virt_setup: true
# Performance optimization
enable_kvm_performance_optimization: true
kvm_hugepages_percent: 30
kvm_cpu_governor: "performance"
roles:
- tosin2013.qubinode_kvmhost_setup_collection.kvmhost_setup
Container Testing Configuration¶
- hosts: test_hosts
become: true
vars:
cicd_test: true # Disable hardware-specific features
admin_user: "testuser"
configure_shell: false # Skip shell config in containers
roles:
- tosin2013.qubinode_kvmhost_setup_collection.kvmhost_setup