Enable support for Libvirt modular daemons

This change enables support for modular libvirt
daemon configurations.

Also deprecating modular_libvirt param so that modular-libvirt
is default configuration and once we remove non-modular libvirt
configuration in next release, this param can be removed.

Depends-On: https://review.opendev.org/c/openstack/puppet-nova/+/814000
Depends-On: https://review.opendev.org/c/openstack/puppet-nova/+/815113
Co-Authored-By: Bogdan Dobrelya <bdobreli@redhat.com>
Co-Authored-By: Martin Schuppert <mschuppert@redhat.com>
Change-Id: Id9c1bfcc88f60f61877fe34b1ee01677d3bcc1b0
(cherry picked from commit bbdad5c27e)
This commit is contained in:
Rajesh Tailor 2021-08-03 18:02:55 +05:30
parent c13fd723ca
commit 9edca8fd9a
3 changed files with 164 additions and 36 deletions

View File

@ -35,11 +35,44 @@
# (Optional) SASL Password for libvirtd TLS connections
# Defaults to '' (disabled)
#
# [*virtproxyd_config*]
# (Optional) Overrides for virtproxyd config options
# Defaults to {}
#
# [*virtqemud_config*]
# (Optional) Overrides for virtqemud config options
# Defaults to {}
#
# [*virtnodedevd_config*]
# (Optional) Overrides for virtnodedevd config options
# Defaults to {}
#
# [*virtstoraged_config*]
# (Optional) Overrides for virtstoraged config options
# Defaults to {}
#
# [*virtsecretd_config*]
# (Optional) Overrides for virtsecretd config options
# Defaults to {}
#
# DEPRECATED PARAMETERS
#
# [*modular_libvirt*]
# (Optional) Whether to enable modular libvirt daemons or not.
# Defaults to false
#
class tripleo::profile::base::nova::libvirt (
$step = Integer(hiera('step')),
$libvirtd_config = {},
$virtlogd_config = {},
$virtproxyd_config = {},
$virtqemud_config = {},
$virtnodedevd_config = {},
$virtstoraged_config = {},
$virtsecretd_config = {},
$tls_password = '',
# DEPRECATED PARAMETERS
$modular_libvirt = false,
) {
include tripleo::profile::base::nova::compute_libvirt_shared
@ -49,20 +82,43 @@ class tripleo::profile::base::nova::libvirt (
include nova::compute::libvirt::virtlogd
include nova::compute::libvirt::services
$libvirtd_config_default = {
$libvirt_daemon_config_default = {
unix_sock_group => {value => '"libvirt"'},
auth_unix_ro => {value => '"none"'},
auth_unix_rw => {value => '"none"'},
unix_sock_ro_perms => {value => '"0777"'},
unix_sock_ro_perms => {value => '"0444"'},
unix_sock_rw_perms => {value => '"0770"'}
}
class { 'nova::compute::libvirt::config':
libvirtd_config => merge($libvirtd_config_default, $libvirtd_config)
}
if $modular_libvirt {
include nova::compute::libvirt::virtproxyd
include nova::compute::libvirt::virtqemud
include nova::compute::libvirt::virtnodedevd
include nova::compute::libvirt::virtstoraged
include nova::compute::libvirt::virtsecretd
class { 'nova::compute::libvirt::virtlogd::config':
virtlogd_config => $virtlogd_config
$virtproxyd_config_default = $libvirt_daemon_config_default
$virtqemud_config_default = $libvirt_daemon_config_default
$virtnodedevd_config_default = $libvirt_daemon_config_default
$virtstoraged_config_default = $libvirt_daemon_config_default
$virtsecretd_config_default = $libvirt_daemon_config_default
class { 'nova::compute::libvirt::config':
virtlogd_config => $virtlogd_config,
virtproxyd_config => merge($virtproxyd_config_default, $virtproxyd_config),
virtqemud_config => merge($virtqemud_config_default, $virtqemud_config),
virtnodedevd_config => merge($virtnodedevd_config_default, $virtnodedevd_config),
virtstoraged_config => merge($virtstoraged_config_default, $virtstoraged_config),
virtsecretd_config => merge($virtsecretd_config_default, $virtsecretd_config),
}
} else {
$libvirtd_config_default = $libvirt_daemon_config_default
class { 'nova::compute::libvirt::config':
virtlogd_config => $virtlogd_config,
libvirtd_config => merge($libvirtd_config_default, $libvirtd_config),
}
}
# This removal of files in /etc/libvirt/qemu should not happen inside containers

View File

@ -0,0 +1,15 @@
---
features:
- |
This change adds functionality to enable modular libvirt daemons
support. Also all the daemons runs in separate containers, so the
configuration is done for all the daemon containers.
Here is the list of daemons added in this change.
- virtnodedevd
- virtproxyd
- virtqemud
- virtsecretd
- virtstoraged
More information regarding modular libvirt daemons is available here.
`Libvirt Daemons <https://libvirt.org/daemons.html>` _.

View File

@ -19,8 +19,18 @@ require 'spec_helper'
describe 'tripleo::profile::base::nova::libvirt' do
shared_examples_for 'tripleo::profile::base::nova::libvirt' do
let(:libvirt_daemon_config_default) do {
"unix_sock_group" => {"value" => '"libvirt"'},
"auth_unix_ro" => {"value" => '"none"'},
"auth_unix_rw" => {"value" => '"none"'},
"unix_sock_ro_perms" => {"value" => '"0444"'},
"unix_sock_rw_perms" => {"value" => '"0770"'}
}
end
context 'with step less than 4' do
let(:params) { { :step => 1, } }
let(:params) { { :step => 1, :modular_libvirt => false} }
let(:pre_condition) do
<<-eos
class { 'tripleo::profile::base::nova::compute_libvirt_shared':
@ -33,11 +43,15 @@ eos
is_expected.to contain_class('tripleo::profile::base::nova::compute_libvirt_shared')
is_expected.to_not contain_class('tripleo::profile::base::nova')
is_expected.to_not contain_class('nova::compute::libvirt::virtlogd')
is_expected.to_not contain_class('nova::compute::libvirt::virtnodedevd')
is_expected.to_not contain_class('nova::compute::libvirt::virtproxyd')
is_expected.to_not contain_class('nova::compute::libvirt::virtqemud')
is_expected.to_not contain_class('nova::compute::libvirt::virtsecretd')
is_expected.to_not contain_class('nova::compute::libvirt::virtstoraged')
is_expected.to_not contain_class('nova::compute::libvirt::services')
is_expected.to_not contain_file('/etclibvirt/qemu/networks/autostart/default.xml')
is_expected.to_not contain_file('/etclibvirt/qemu/networks/default.xml')
is_expected.to_not contain_exec('libvirt-default-net-destroy')
is_expected.to_not contain_class('nova::compute::libvirt::virtlogd::config')
is_expected.to_not contain_exec('set libvirt sasl credentials')
}
end
@ -61,27 +75,77 @@ eos
eos
end
let(:params) { { :step => 4, } }
let(:params) { { :step => 4, :modular_libvirt => false} }
it {
is_expected.to contain_class('tripleo::profile::base::nova::libvirt')
is_expected.to contain_class('tripleo::profile::base::nova::compute_libvirt_shared')
is_expected.to contain_class('tripleo::profile::base::nova')
is_expected.to contain_class('nova::compute::libvirt::virtlogd')
is_expected.to_not contain_class('nova::compute::libvirt::virtnodedevd')
is_expected.to_not contain_class('nova::compute::libvirt::virtproxyd')
is_expected.to_not contain_class('nova::compute::libvirt::virtqemud')
is_expected.to_not contain_class('nova::compute::libvirt::virtsecretd')
is_expected.to_not contain_class('nova::compute::libvirt::virtstoraged')
is_expected.to contain_class('nova::compute::libvirt::services')
is_expected.to contain_class('nova::compute::libvirt::qemu')
is_expected.to contain_class('nova::migration::qemu')
is_expected.to contain_file('/etc/libvirt/qemu/networks/autostart/default.xml').with_ensure('absent')
is_expected.to contain_file('/etc/libvirt/qemu/networks/default.xml').with_ensure('absent')
is_expected.to contain_exec('libvirt-default-net-destroy')
is_expected.to contain_class('nova::compute::libvirt::config').with_libvirtd_config({
"unix_sock_group" => {"value" => '"libvirt"'},
"auth_unix_ro" => {"value" => '"none"'},
"auth_unix_rw" => {"value" => '"none"'},
"unix_sock_ro_perms" => {"value" => '"0777"'},
"unix_sock_rw_perms" => {"value" => '"0770"'}
})
is_expected.to contain_class('nova::compute::libvirt::virtlogd::config')
is_expected.to contain_class('nova::compute::libvirt::config').with_libvirtd_config(
libvirt_daemon_config_default)
is_expected.to contain_package('cyrus-sasl-scram')
is_expected.to contain_file('/etc/sasl2/libvirt.conf')
is_expected.to contain_file('/etc/libvirt/auth.conf').with_ensure('absent')
is_expected.to contain_exec('set libvirt sasl credentials').with_command(
'saslpasswd2 -d -a libvirt -u overcloud migration'
)
}
end
context 'modular-libvirt with step 4' do
let(:pre_condition) do
<<-eos
class { 'tripleo::profile::base::nova':
step => #{params[:step]},
oslomsg_rpc_hosts => [ '127.0.0.1' ],
}
class { 'tripleo::profile::base::nova::migration':
step => #{params[:step]}
}
class { 'tripleo::profile::base::nova::migration::client':
step => #{params[:step]}
}
class { 'tripleo::profile::base::nova::compute_libvirt_shared':
step => #{params[:step]}
}
eos
end
let(:params) { { :step => 4, :modular_libvirt => true} }
it {
is_expected.to contain_class('tripleo::profile::base::nova::compute_libvirt_shared')
is_expected.to contain_class('tripleo::profile::base::nova')
is_expected.to contain_class('nova::compute::libvirt::virtlogd')
is_expected.to contain_class('nova::compute::libvirt::virtnodedevd')
is_expected.to contain_class('nova::compute::libvirt::virtproxyd')
is_expected.to contain_class('nova::compute::libvirt::virtqemud')
is_expected.to contain_class('nova::compute::libvirt::virtsecretd')
is_expected.to contain_class('nova::compute::libvirt::virtstoraged')
is_expected.to contain_class('nova::compute::libvirt::services')
is_expected.to contain_class('nova::compute::libvirt::qemu')
is_expected.to contain_class('nova::migration::qemu')
is_expected.to contain_file('/etc/libvirt/qemu/networks/autostart/default.xml').with_ensure('absent')
is_expected.to contain_file('/etc/libvirt/qemu/networks/default.xml').with_ensure('absent')
is_expected.to contain_exec('libvirt-default-net-destroy')
is_expected.to contain_class('nova::compute::libvirt::config').with_virtnodedevd_config(libvirt_daemon_config_default)
is_expected.to contain_class('nova::compute::libvirt::config').with_virtqemud_config(libvirt_daemon_config_default)
is_expected.to contain_class('nova::compute::libvirt::config').with_virtproxyd_config(libvirt_daemon_config_default)
is_expected.to contain_class('nova::compute::libvirt::config').with_virtstoraged_config(libvirt_daemon_config_default)
is_expected.to contain_class('nova::compute::libvirt::config').with_virtsecretd_config(libvirt_daemon_config_default)
is_expected.to contain_package('cyrus-sasl-scram')
is_expected.to contain_file('/etc/sasl2/libvirt.conf')
is_expected.to contain_file('/etc/libvirt/auth.conf').with_ensure('absent')
@ -110,24 +174,23 @@ eos
eos
end
let(:params) { { :step => 4, :libvirtd_config => { "unix_sock_group" => {"value" => '"foobar"'}} } }
let(:params) { { :step => 4, :modular_libvirt => false, :libvirtd_config => { "unix_sock_group" => {"value" => '"foobar"'}} } }
it {
is_expected.to contain_class('tripleo::profile::base::nova::libvirt')
is_expected.to contain_class('tripleo::profile::base::nova')
is_expected.to contain_class('nova::compute::libvirt::virtlogd')
is_expected.to_not contain_class('nova::compute::libvirt::virtnodedevd')
is_expected.to_not contain_class('nova::compute::libvirt::virtproxyd')
is_expected.to_not contain_class('nova::compute::libvirt::virtqemud')
is_expected.to_not contain_class('nova::compute::libvirt::virtsecretd')
is_expected.to_not contain_class('nova::compute::libvirt::virtstoraged')
is_expected.to contain_class('nova::compute::libvirt::services')
is_expected.to contain_file('/etc/libvirt/qemu/networks/autostart/default.xml').with_ensure('absent')
is_expected.to contain_file('/etc/libvirt/qemu/networks/default.xml').with_ensure('absent')
is_expected.to contain_exec('libvirt-default-net-destroy')
is_expected.to contain_class('nova::compute::libvirt::config').with_libvirtd_config({
"unix_sock_group" => {"value" => '"foobar"'},
"auth_unix_ro" => {"value" => '"none"'},
"auth_unix_rw" => {"value" => '"none"'},
"unix_sock_ro_perms" => {"value" => '"0777"'},
"unix_sock_rw_perms" => {"value" => '"0770"'}
})
is_expected.to contain_class('nova::compute::libvirt::virtlogd::config')
is_expected.to contain_class('nova::compute::libvirt::config').with_libvirtd_config(
libvirt_daemon_config_default.merge(params[:libvirtd_config]))
is_expected.to contain_package('cyrus-sasl-scram')
is_expected.to contain_file('/etc/sasl2/libvirt.conf')
is_expected.to contain_file('/etc/libvirt/auth.conf').with_ensure('absent')
@ -156,7 +219,7 @@ eos
eos
end
let(:params) { { :step => 4, :tls_password => 'foo'} }
let(:params) { { :step => 4, :tls_password => 'foo', :modular_libvirt => false} }
it {
is_expected.to contain_class('tripleo::profile::base::nova::libvirt')
@ -169,14 +232,8 @@ eos
is_expected.to contain_file('/etc/libvirt/qemu/networks/autostart/default.xml').with_ensure('absent')
is_expected.to contain_file('/etc/libvirt/qemu/networks/default.xml').with_ensure('absent')
is_expected.to contain_exec('libvirt-default-net-destroy')
is_expected.to contain_class('nova::compute::libvirt::config').with_libvirtd_config({
"unix_sock_group" => {"value" => '"libvirt"'},
"auth_unix_ro" => {"value" => '"none"'},
"auth_unix_rw" => {"value" => '"none"'},
"unix_sock_ro_perms" => {"value" => '"0777"'},
"unix_sock_rw_perms" => {"value" => '"0770"'}
})
is_expected.to contain_class('nova::compute::libvirt::virtlogd::config')
is_expected.to contain_class('nova::compute::libvirt::config').with_libvirtd_config(
libvirt_daemon_config_default)
is_expected.to contain_package('cyrus-sasl-scram')
is_expected.to contain_file('/etc/sasl2/libvirt.conf')
is_expected.to contain_file('/etc/libvirt/auth.conf').with_ensure('present')