migration: split libvirt & nova configs
When running micro-services on compute nodes, nova & libvirt are separated & isolated (ie: containers). nova::migration::libvirt used to configure both nova & libvirt to support migration. This patch makes possible to select what we want (libvirt, nova or both). It will configure all by default for backward compatibility. Depends-On: I33e565638f39ace819645215912303d6e431870c Change-Id: I1a1cb827512b12289558b296a7e64ce2dc71f00a
This commit is contained in:
@@ -166,8 +166,6 @@ class nova::compute::libvirt (
|
|||||||
if $vncserver_listen != '0.0.0.0' and $vncserver_listen != '::0' {
|
if $vncserver_listen != '0.0.0.0' and $vncserver_listen != '::0' {
|
||||||
fail('For migration support to work, you MUST set vncserver_listen to \'0.0.0.0\' or \'::0\'')
|
fail('For migration support to work, you MUST set vncserver_listen to \'0.0.0.0\' or \'::0\'')
|
||||||
} else {
|
} else {
|
||||||
# TODO(emilien): explode ::nova::migration::libvirt to select what bits we want to configure
|
|
||||||
# and allow micro services between libvirt & nova-compute.
|
|
||||||
include ::nova::migration::libvirt
|
include ::nova::migration::libvirt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -36,6 +36,14 @@
|
|||||||
# (optional) Set uuid not equal to output from dmidecode (boolean)
|
# (optional) Set uuid not equal to output from dmidecode (boolean)
|
||||||
# Defaults to false
|
# Defaults to false
|
||||||
#
|
#
|
||||||
|
# [*configure_libvirt*]
|
||||||
|
# (optional) Whether or not configure libvirt bits.
|
||||||
|
# Defaults to true.
|
||||||
|
#
|
||||||
|
# [*configure_nova*]
|
||||||
|
# (optional) Whether or not configure libvirt bits.
|
||||||
|
# Defaults to true.
|
||||||
|
#
|
||||||
class nova::migration::libvirt(
|
class nova::migration::libvirt(
|
||||||
$use_tls = false,
|
$use_tls = false,
|
||||||
$auth = 'none',
|
$auth = 'none',
|
||||||
@@ -43,156 +51,164 @@ class nova::migration::libvirt(
|
|||||||
$block_migration_flag = undef,
|
$block_migration_flag = undef,
|
||||||
$live_migration_tunnelled = $::os_service_default,
|
$live_migration_tunnelled = $::os_service_default,
|
||||||
$override_uuid = false,
|
$override_uuid = false,
|
||||||
|
$configure_libvirt = true,
|
||||||
|
$configure_nova = true,
|
||||||
){
|
){
|
||||||
|
|
||||||
include ::nova::deps
|
include ::nova::deps
|
||||||
|
|
||||||
|
validate_re($auth, [ '^sasl$', '^none$' ], 'Valid options for auth are none and sasl.')
|
||||||
|
|
||||||
if $use_tls {
|
if $use_tls {
|
||||||
$listen_tls = '1'
|
$listen_tls = '1'
|
||||||
$listen_tcp = '0'
|
$listen_tcp = '0'
|
||||||
nova_config {
|
|
||||||
'libvirt/live_migration_uri': value => 'qemu+tls://%s/system';
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$listen_tls = '0'
|
$listen_tls = '0'
|
||||||
$listen_tcp = '1'
|
$listen_tcp = '1'
|
||||||
}
|
}
|
||||||
|
|
||||||
if $live_migration_flag {
|
if $configure_nova {
|
||||||
|
if $use_tls {
|
||||||
|
nova_config {
|
||||||
|
'libvirt/live_migration_uri': value => 'qemu+tls://%s/system';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if $live_migration_flag {
|
||||||
|
nova_config {
|
||||||
|
'libvirt/live_migration_flag': value => $live_migration_flag
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if $block_migration_flag {
|
||||||
|
nova_config {
|
||||||
|
'libvirt/block_migration_flag': value => $block_migration_flag
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nova_config {
|
nova_config {
|
||||||
'libvirt/live_migration_flag': value => $live_migration_flag
|
'libvirt/live_migration_tunnelled': value => $live_migration_tunnelled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if $block_migration_flag {
|
if $configure_libvirt {
|
||||||
nova_config {
|
Anchor['nova::config::begin']
|
||||||
'libvirt/block_migration_flag': value => $block_migration_flag
|
-> File_line<| tag == 'libvirt-file_line'|>
|
||||||
}
|
-> Anchor['nova::config::end']
|
||||||
}
|
|
||||||
|
|
||||||
nova_config {
|
File_line<| tag == 'libvirt-file_line' |>
|
||||||
'libvirt/live_migration_tunnelled': value => $live_migration_tunnelled
|
~> Service['libvirt']
|
||||||
}
|
|
||||||
|
|
||||||
validate_re($auth, [ '^sasl$', '^none$' ], 'Valid options for auth are none and sasl.')
|
if $override_uuid {
|
||||||
|
if ! $::libvirt_uuid {
|
||||||
|
$host_uuid = generate('/bin/cat', '/proc/sys/kernel/random/uuid')
|
||||||
|
file { '/etc/libvirt/libvirt_uuid':
|
||||||
|
content => $host_uuid,
|
||||||
|
require => Package['libvirt'],
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$host_uuid = $::libvirt_uuid
|
||||||
|
}
|
||||||
|
|
||||||
Anchor['nova::config::begin']
|
augeas { 'libvirt-conf-uuid':
|
||||||
-> File_line<| tag == 'libvirt-file_line'|>
|
context => '/files/etc/libvirt/libvirtd.conf',
|
||||||
-> Anchor['nova::config::end']
|
changes => [
|
||||||
|
"set host_uuid ${host_uuid}",
|
||||||
File_line<| tag == 'libvirt-file_line' |>
|
],
|
||||||
~> Service['libvirt']
|
notify => Service['libvirt'],
|
||||||
|
|
||||||
if $override_uuid {
|
|
||||||
if ! $::libvirt_uuid {
|
|
||||||
$host_uuid = generate('/bin/cat', '/proc/sys/kernel/random/uuid')
|
|
||||||
file { '/etc/libvirt/libvirt_uuid':
|
|
||||||
content => $host_uuid,
|
|
||||||
require => Package['libvirt'],
|
require => Package['libvirt'],
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$host_uuid = $::libvirt_uuid
|
|
||||||
}
|
}
|
||||||
|
|
||||||
augeas { 'libvirt-conf-uuid':
|
case $::osfamily {
|
||||||
context => '/files/etc/libvirt/libvirtd.conf',
|
'RedHat': {
|
||||||
changes => [
|
file_line { '/etc/libvirt/libvirtd.conf listen_tls':
|
||||||
"set host_uuid ${host_uuid}",
|
|
||||||
],
|
|
||||||
notify => Service['libvirt'],
|
|
||||||
require => Package['libvirt'],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case $::osfamily {
|
|
||||||
'RedHat': {
|
|
||||||
file_line { '/etc/libvirt/libvirtd.conf listen_tls':
|
|
||||||
path => '/etc/libvirt/libvirtd.conf',
|
|
||||||
line => "listen_tls = ${listen_tls}",
|
|
||||||
match => 'listen_tls =',
|
|
||||||
tag => 'libvirt-file_line',
|
|
||||||
}
|
|
||||||
|
|
||||||
file_line { '/etc/libvirt/libvirtd.conf listen_tcp':
|
|
||||||
path => '/etc/libvirt/libvirtd.conf',
|
|
||||||
line => "listen_tcp = ${listen_tcp}",
|
|
||||||
match => 'listen_tcp =',
|
|
||||||
tag => 'libvirt-file_line',
|
|
||||||
}
|
|
||||||
|
|
||||||
if $use_tls {
|
|
||||||
file_line { '/etc/libvirt/libvirtd.conf auth_tls':
|
|
||||||
path => '/etc/libvirt/libvirtd.conf',
|
path => '/etc/libvirt/libvirtd.conf',
|
||||||
line => "auth_tls = \"${auth}\"",
|
line => "listen_tls = ${listen_tls}",
|
||||||
match => 'auth_tls =',
|
match => 'listen_tls =',
|
||||||
tag => 'libvirt-file_line',
|
tag => 'libvirt-file_line',
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
file_line { '/etc/libvirt/libvirtd.conf auth_tcp':
|
file_line { '/etc/libvirt/libvirtd.conf listen_tcp':
|
||||||
path => '/etc/libvirt/libvirtd.conf',
|
path => '/etc/libvirt/libvirtd.conf',
|
||||||
line => "auth_tcp = \"${auth}\"",
|
line => "listen_tcp = ${listen_tcp}",
|
||||||
match => 'auth_tcp =',
|
match => 'listen_tcp =',
|
||||||
|
tag => 'libvirt-file_line',
|
||||||
|
}
|
||||||
|
|
||||||
|
if $use_tls {
|
||||||
|
file_line { '/etc/libvirt/libvirtd.conf auth_tls':
|
||||||
|
path => '/etc/libvirt/libvirtd.conf',
|
||||||
|
line => "auth_tls = \"${auth}\"",
|
||||||
|
match => 'auth_tls =',
|
||||||
|
tag => 'libvirt-file_line',
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
file_line { '/etc/libvirt/libvirtd.conf auth_tcp':
|
||||||
|
path => '/etc/libvirt/libvirtd.conf',
|
||||||
|
line => "auth_tcp = \"${auth}\"",
|
||||||
|
match => 'auth_tcp =',
|
||||||
|
tag => 'libvirt-file_line',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
file_line { '/etc/sysconfig/libvirtd libvirtd args':
|
||||||
|
path => '/etc/sysconfig/libvirtd',
|
||||||
|
line => 'LIBVIRTD_ARGS="--listen"',
|
||||||
|
match => 'LIBVIRTD_ARGS=',
|
||||||
tag => 'libvirt-file_line',
|
tag => 'libvirt-file_line',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file_line { '/etc/sysconfig/libvirtd libvirtd args':
|
'Debian': {
|
||||||
path => '/etc/sysconfig/libvirtd',
|
file_line { '/etc/libvirt/libvirtd.conf listen_tls':
|
||||||
line => 'LIBVIRTD_ARGS="--listen"',
|
|
||||||
match => 'LIBVIRTD_ARGS=',
|
|
||||||
tag => 'libvirt-file_line',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
'Debian': {
|
|
||||||
file_line { '/etc/libvirt/libvirtd.conf listen_tls':
|
|
||||||
path => '/etc/libvirt/libvirtd.conf',
|
|
||||||
line => "listen_tls = ${listen_tls}",
|
|
||||||
match => 'listen_tls =',
|
|
||||||
tag => 'libvirt-file_line',
|
|
||||||
}
|
|
||||||
|
|
||||||
file_line { '/etc/libvirt/libvirtd.conf listen_tcp':
|
|
||||||
path => '/etc/libvirt/libvirtd.conf',
|
|
||||||
line => "listen_tcp = ${listen_tcp}",
|
|
||||||
match => 'listen_tcp =',
|
|
||||||
tag => 'libvirt-file_line',
|
|
||||||
}
|
|
||||||
|
|
||||||
if $use_tls {
|
|
||||||
file_line { '/etc/libvirt/libvirtd.conf auth_tls':
|
|
||||||
path => '/etc/libvirt/libvirtd.conf',
|
path => '/etc/libvirt/libvirtd.conf',
|
||||||
line => "auth_tls = \"${auth}\"",
|
line => "listen_tls = ${listen_tls}",
|
||||||
match => 'auth_tls =',
|
match => 'listen_tls =',
|
||||||
tag => 'libvirt-file_line',
|
tag => 'libvirt-file_line',
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
file_line { '/etc/libvirt/libvirtd.conf auth_tcp':
|
file_line { '/etc/libvirt/libvirtd.conf listen_tcp':
|
||||||
path => '/etc/libvirt/libvirtd.conf',
|
path => '/etc/libvirt/libvirtd.conf',
|
||||||
line => "auth_tcp = \"${auth}\"",
|
line => "listen_tcp = ${listen_tcp}",
|
||||||
match => 'auth_tcp =',
|
match => 'listen_tcp =',
|
||||||
|
tag => 'libvirt-file_line',
|
||||||
|
}
|
||||||
|
|
||||||
|
if $use_tls {
|
||||||
|
file_line { '/etc/libvirt/libvirtd.conf auth_tls':
|
||||||
|
path => '/etc/libvirt/libvirtd.conf',
|
||||||
|
line => "auth_tls = \"${auth}\"",
|
||||||
|
match => 'auth_tls =',
|
||||||
|
tag => 'libvirt-file_line',
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
file_line { '/etc/libvirt/libvirtd.conf auth_tcp':
|
||||||
|
path => '/etc/libvirt/libvirtd.conf',
|
||||||
|
line => "auth_tcp = \"${auth}\"",
|
||||||
|
match => 'auth_tcp =',
|
||||||
|
tag => 'libvirt-file_line',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if $::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemmajrelease, '16') >= 0 {
|
||||||
|
# If systemd is being used then libvirtd is already being launched correctly and
|
||||||
|
# adding -d causes a second consecutive start to fail which causes puppet to fail.
|
||||||
|
$libvirtd_opts = 'libvirtd_opts="-l"'
|
||||||
|
} else {
|
||||||
|
$libvirtd_opts = 'libvirtd_opts="-d -l"'
|
||||||
|
}
|
||||||
|
|
||||||
|
file_line { "/etc/default/${::nova::compute::libvirt::libvirt_service_name} libvirtd opts":
|
||||||
|
path => "/etc/default/${::nova::compute::libvirt::libvirt_service_name}",
|
||||||
|
line => $libvirtd_opts,
|
||||||
|
match => 'libvirtd_opts=',
|
||||||
tag => 'libvirt-file_line',
|
tag => 'libvirt-file_line',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if $::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemmajrelease, '16') >= 0 {
|
default: {
|
||||||
# If systemd is being used then libvirtd is already being launched correctly and
|
warning("Unsupported osfamily: ${::osfamily}, make sure you are configuring this yourself")
|
||||||
# adding -d causes a second consecutive start to fail which causes puppet to fail.
|
|
||||||
$libvirtd_opts = 'libvirtd_opts="-l"'
|
|
||||||
} else {
|
|
||||||
$libvirtd_opts = 'libvirtd_opts="-d -l"'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
file_line { "/etc/default/${::nova::compute::libvirt::libvirt_service_name} libvirtd opts":
|
|
||||||
path => "/etc/default/${::nova::compute::libvirt::libvirt_service_name}",
|
|
||||||
line => $libvirtd_opts,
|
|
||||||
match => 'libvirtd_opts=',
|
|
||||||
tag => 'libvirt-file_line',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
warning("Unsupported osfamily: ${::osfamily}, make sure you are configuring this yourself")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -120,6 +120,25 @@ describe 'nova::migration::libvirt' do
|
|||||||
it { expect { is_expected.to contain_class('nova::compute::libvirt') }.to \
|
it { expect { is_expected.to contain_class('nova::compute::libvirt') }.to \
|
||||||
raise_error(Puppet::Error, /Valid options for auth are none and sasl./) }
|
raise_error(Puppet::Error, /Valid options for auth are none and sasl./) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when not configuring libvirt' do
|
||||||
|
let :params do
|
||||||
|
{
|
||||||
|
:configure_libvirt => false
|
||||||
|
}
|
||||||
|
end
|
||||||
|
it { is_expected.not_to contain_file_line('/etc/libvirt/libvirtd.conf listen_tls') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when not configuring nova and tls enabled' do
|
||||||
|
let :params do
|
||||||
|
{
|
||||||
|
:configure_nova => false,
|
||||||
|
:use_tls => true,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
it { is_expected.not_to contain_nova_config('libvirt/live_migration_uri').with_value('qemu+tls://%s/system') }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO (degorenko): switch to on_supported_os function when we got Xenial
|
# TODO (degorenko): switch to on_supported_os function when we got Xenial
|
||||||
|
Reference in New Issue
Block a user