Skip to content

YvanY0/ked

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KVM Environment Deployment

As the name describes, kvm-env-deployment is a self-service ansible playbook for deploying a KVM test environment.

Caution
This repository is currently only supports RHEL9+

Use Ansible

Ansible can be installed by many methods:

  • Install a released version via pip.

  • Install community version from EPEL repository.

Example command

variables.yml
virt_install_method: "local"
pkg_id: "6620"
force_install: false
suite_type: "kar"
ignore_untested: true
example
$ ansible-playbook -i localhost, -u root -e "@variables.yml" site.yml

Playbooks

Provided as a deployment playbook for kvm test environment, it contains two roles: pre_stage and virt_install.

Provided as a test playbook to execute the test suite only, it contains one role: test_suite.

Includes all the roles of the above two playbooks. It is the top level playbook that defines the entire infrastructure.

Roles

pre_stage

pre_stage contains many tasks that need to be prepared early.

Order of the tasks

  1. Create a bridge

  2. Ensure environmental dependencies are resolved

    1. Update certificate

    2. Install dependent packages

  3. Bootstrap "Kvm Automation Runner"

virt_install

virt_install will install specified packages that exist in the virt module.

Tip
Please use the virt_install_method variable to switch the installer.

Order of tasks

  1. Create YUM repository file

    • Remote Virt Repository

      1. Create the virt repository file with the given uri (Requires virt_repo_link)

    • Local Private Virt Repository

      1. Using specified NVR ID to generate a list with all packages via brew

      2. Download all packages to local path

      3. Create a local repository using createrepo

      4. Create the private virt repository file

  2. Install specified virt packages

  3. Enable and start libvirt related services/sockets

  4. Redefine the virbr0

test_suite

task-suite executes a command, after completion, the test results will be compressed and passed to the ansible execution host, analyze the results and finally delete the log directory of the remote host.

Order of tasks

  1. Execute test suite

  2. Copy logs to ansible execution host

  3. Show test results

  4. Analyze test results

Configurable extra variables

There are some configurable extra variables for this playbook, they are divided into global [1] extra variables and role-specific [2] extra variables. Global extra variables mean that they will be used in 2 or more roles, while role-specific extra variables will only be used in a single role.

Using yaml/json format in --extra-vars/-e argument can more efficient manage multiple sets of extra variables.

Example usage:

string
{"str_key": "hello"}
numeric
{"int_key": 1, "float_key": 1.0}
bool
{"bool_key": true}
ansible fact
{"fact_key": "{{ ansible_distribution_version }}"}

Global extra variables

kar_path

The path of where the kar repository should be checked out, it used for pre_stage and test_suite.

Role-specific extra variables

pre_stage

bridge_type

Type of bridge to be created. Currently, supports linux_bridge and ovs_bridge.

ovs_pkg

Specify the Open vSwitch version, only used for ovs_bridge.

bridge_name

The bridge name.

cloned_mac

Clone MAC address from the source NIC

dep_pkgs

Some basic dependent packages you want to install for your system.

bootstrap_args

Arguments specified during the kar bootstrap phase.

virt_install

virt_install_method

Virt installer, remote will use the given uri, and local will download all virt rpm packages then create a local repo via createrepo, they will both create a YUM repository file. If you want to use virt packages provided by the system, please use system.

virt_repo_link

Only when virt_install_method=remote
An available virt repo link, it can from brewroot or anywhere.

pkg_id

Only when virt_install_method=local
ID of NVR. If it’s not set, the playbook will obtain the qemu-kvm version of ansible execution host to capture the package ID.

brew_root

Only when virt_install_method=local
File share web server url of brew.

virt_pkgs_path

Only when virt_install_method=local
Directory to index of the local virt repository.

virt_pkgs

A common list of basic virt packages to be installed.

virt_ext_pkgs

An extra list of virt packages to be installed.

force_install

Whether to force the installation if specified packages are already installed.

virbr0_subnet

Redefine the virbr0’s network information, a valid subnet can be set. For instance: virbr0_subnet: 192.168.2

test_suite

suite_type

Test suite to be executed, the valid options are kar and kvm_unit_test.

vt_type

Only when suite_type=kar
The VT_TYPE of kar, supported configurations are qemu and libvirt, and the default is qemu.

kar_args

Only when suite_type=kar
Arguments you want to add when executing python3 ConfigTest.py, except for --customsparams.

kar_customsparams

Only when suite_type=kar
Multiple sets of variables for --customsparams need to be enclosed in quotes, so split it into an independent extra variable.
Noted that special characters need to be escaped. E.g: \n\\n

unittest_job_dir

Only when suite_type=kvm_unit_test
Forces using of an alternate job results directory for kvm-unit-test.

test_harness_log_dir

Ansible execution host directory where you want to save test results.

ignore_untested

When the status of some test cases is SKIP/CANCEL, whether judged that the result of the playbook as failure.


1. vars/global.yml
2. roles/xxx/vars/main.yml

About

Ansible playbook to deploy a kvm environment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors