/ansible-role-srv_kvm

An Ansible Role to install and configure a kvm host.

Primary LanguageJinjaBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Github (tag) Github (license) Github (issues) Github (pull requests)

Travis (com)

Ansible (min. version) Ansible (platforms) Ansible (tags)

Ansible Role: srv_kvm

An Ansible Role to install and configure a kvm host.

Motivation

KVM in combination with libvirt is the major Linux hypervisor. Installing and configuring KVM is a very common task for most operators and engineers.

Description

This role configures a KVM hypervisor:

  • install qemu-kvm
  • install libvirt
  • install ksm support and service
  • install kvm nesting support

Requirements

Used Modules:

Installation

Install from Ansible Galaxy

ansible-galaxy install while_true_do.srv_kvm

Install from Github

git clone https://github.com/while-true-do/ansible-role-srv_kvm.git while_true_do.srv_kvm

Usage

Role Variables

---
# defaults file for while_true_do.srv_kvm

## Package Management
wtd_srv_kvm_package:
  - qemu-kvm
  - libvirt
# State can be present|latest|absent
wtd_srv_kvm_package_state: "present"

wtd_srv_kvm_ksm_package:
  - ksmtuned
# State can be present|latest|absent
wtd_srv_kvm_ksm_package_state: "present"

## Service Management
wtd_srv_kvm_service: "libvirtd"
# State can be started|stopped
wtd_srv_kvm_service_state: "started"
wtd_srv_kvm_service_enabled: true

wtd_srv_kvm_ksm_service:
  - ksm
  - ksmtuned
# State can be started|stopped
wtd_srv_kvm_ksm_service_state: "started"
wtd_srv_kvm_ksm_service_enabled: true

## Configuration Management
wtd_srv_kvm_conf_nested_enabled: true

# State can be started|stopped
wtd_srv_kvm_conf_ksm:
# MONITOR_INTERVAL: 60
# SLEEP_MSEC: 10
# NPAGES_BOOST: 300
# NPAGES_DECAY: -50
# NPAGES_MIN: 64
# NPAGES_MAX: 1250
# THRES_COEF: 20
# THRES_CONST: 2048

## Host Management
wtd_srv_kvm_reboot_enabled: true
wtd_srv_kvm_reboot_msg: "System is going down to apply kvm configuration."
wtd_srv_kvm_reboot_timeout: 3600

Example Playbook

Running Ansible Roles can be done in a playbook.

Simple

---
- hosts: all
  roles:
    - role: while_true_do.srv_kvm

Advanced

Don't install ksm support and don't reboot after kvm installation.

- hosts: all
  roles:
    - role: while_true_do.srv_kvm
      wtd_srv_kvm_ksm_package_state: "absent"
      wtd_srv_kvm_reboot_enabled: false

Known Issues

  1. RedHat Testing is currently not possible in public, due to limitations in subscriptions.
  2. Some services and features cannot be tested properly, due to limitations in docker.

Testing

Most of the "generic" tests are located in the Test Library.

Ansible specific testing is done with Molecule.

Infrastructure testing is done with testinfra.

Automated testing is done with Travis CI.

Contribute

Thank you so much for considering to contribute. We are very happy, when somebody is joining the hard work. Please fell free to open Bugs, Feature Requests or Pull Requests after reading the Contribution Guideline.

See who has contributed already in the kudos.txt.

License

This work is licensed under a BSD-3-Clause License.

Contact