Merge "Initial changes for testing VM creation for CentOS"
This commit is contained in:
commit
7e8d35a14a
@ -0,0 +1,20 @@
|
||||
---
|
||||
libvirt_service_name: libvirtd
|
||||
required_packages:
|
||||
- qemu-img
|
||||
- qemu-kvm-tools
|
||||
- qemu-kvm
|
||||
- qemu-kvm-common
|
||||
- sgabios
|
||||
- libvirt
|
||||
- libvirt-client
|
||||
- libvirt-daemon
|
||||
- libvirt-daemon-config-network
|
||||
- libvirt-daemon-config-nwfilter
|
||||
- libvirt-daemon-driver-network
|
||||
- libvirt-daemon-driver-nodedev
|
||||
- libvirt-daemon-driver-nwfilter
|
||||
- libvirt-daemon-driver-qemu
|
||||
- libvirt-daemon-driver-secret
|
||||
- libvirt-daemon-driver-storage
|
||||
- libvirt-daemon-kvm
|
@ -0,0 +1,8 @@
|
||||
---
|
||||
libvirt_service_name: libvirt-bin
|
||||
required_packages:
|
||||
- libvirt-bin
|
||||
- qemu-utils
|
||||
- qemu-kvm
|
||||
- qemu-system-x86
|
||||
- sgabios
|
@ -0,0 +1,12 @@
|
||||
---
|
||||
libvirt_service_name: libvirtd
|
||||
required_packages:
|
||||
- qemu-img
|
||||
- qemu-kvm-tools
|
||||
- qemu-kvm
|
||||
- qemu-kvm-common
|
||||
- qemu-system-x86
|
||||
- sgabios
|
||||
- libvirt
|
||||
- libvirt-client
|
||||
- libvirt-daemon
|
@ -38,6 +38,15 @@ VM_EMULATOR=${VM_EMULATOR:-/usr/bin/qemu-system-x86_64}
|
||||
VM_CPU=${VM_CPU:-1}
|
||||
VM_RAM=${VM_RAM:-3072}
|
||||
VM_DISK=${VM_DISK:-10}
|
||||
VM_MACHINE="pc-1.0"
|
||||
|
||||
# CentOS provides a single emulator package
|
||||
# which differs from other distributions, and
|
||||
# needs to be explicitly set.
|
||||
if [ -e /etc/centos-release ]; then
|
||||
VM_EMULATOR=/usr/libexec/qemu-kvm
|
||||
VM_MACHINE="pc"
|
||||
fi
|
||||
|
||||
# VM network
|
||||
VM_NET_BRIDGE=${VM_NET_BRIDGE:-default}
|
||||
@ -95,6 +104,12 @@ function create_node {
|
||||
|
||||
if [ -n "$LOGDIR" ] ; then
|
||||
mkdir -p "$LOGDIR"
|
||||
if [ -e /etc/centos-release ]; then
|
||||
# NOTE(TheJulia): For some unknown reason, libvirt's log folder permissions
|
||||
# on CentOS ship in an inoperable state. Users must be able to read a folder
|
||||
# to open files in the folder structure.
|
||||
chmod o+rx "$LOGDIR/.."
|
||||
fi
|
||||
fi
|
||||
|
||||
PREALLOC=
|
||||
@ -112,15 +127,20 @@ function create_node {
|
||||
volume_path=$(virsh vol-path --pool $LIBVIRT_STORAGE_POOL $VOL_NAME)
|
||||
# Pre-touch the VM to set +C, as it can only be set on empty files.
|
||||
touch "$volume_path"
|
||||
chattr +C "$volume_path" || true
|
||||
|
||||
# NOTE(TheJulia): CentOS default installs with an XFS root, and chattr
|
||||
# fails to set +C on XFS. This could be more elegent, however the use
|
||||
# case is for CI testing.
|
||||
if [ ! -e /etc/centos-release ]; then
|
||||
chattr +C "$volume_path" || true
|
||||
fi
|
||||
vm_xml="
|
||||
<domain type='qemu'>
|
||||
<name>${NAME}</name>
|
||||
<memory unit='KiB'>${MEM}</memory>
|
||||
<vcpu>${CPU}</vcpu>
|
||||
<os>
|
||||
<type arch='${ARCH}' machine='pc-1.0'>hvm</type>
|
||||
<type arch='${ARCH}' machine='${VM_MACHINE}'>hvm</type>
|
||||
<boot dev='network'/>
|
||||
<bootmenu enable='no'/>
|
||||
<bios useserial='yes'/>
|
||||
|
@ -14,27 +14,16 @@
|
||||
#
|
||||
# TODO: Consider converting to ansible virt module.
|
||||
---
|
||||
- name: "Install testing apt packages for Ubuntu/Debian"
|
||||
when: ansible_os_family == 'Debian'
|
||||
apt: name={{ item }} state=present
|
||||
with_items:
|
||||
- libvirt-bin
|
||||
- qemu-utils
|
||||
- qemu-kvm
|
||||
- qemu-system-x86
|
||||
- sgabios
|
||||
- name: "Install testing yum packages for RedHat/CentOS/Fedora/OpenSuse"
|
||||
when: ansible_os_family in ['CentOS', 'Fedora', 'OpenSuse', 'RedHat']
|
||||
yum: name={{ item }} state=present
|
||||
with_items:
|
||||
- libvirt-client
|
||||
- qemu-img
|
||||
- qemu-kvm-tools
|
||||
- qemu-kvm
|
||||
- qemu-system-x86
|
||||
- sgabios
|
||||
- name: "Load Distribution defaults"
|
||||
include_vars: "{{ item }}"
|
||||
with_first_found:
|
||||
- "../defaults/required_defaults_{{ ansible_distribution }}.yml"
|
||||
- "../defaults/required_defaults_{{ ansible_os_family }}.yml"
|
||||
- name: "Install required packages"
|
||||
action: "{{ ansible_pkg_mgr }} name={{item}} state=present"
|
||||
with_items: required_packages
|
||||
- name: "Restart libvirt service"
|
||||
service: name=libvirt-bin state=restarted
|
||||
service: name={{libvirt_service_name}} state=restarted
|
||||
- name: "Create virtual machines"
|
||||
script: create_vm_nodes-for-role.sh
|
||||
environment:
|
||||
|
Loading…
x
Reference in New Issue
Block a user