CentOS: Ensure /etc/sysconfig/libvirtd(-guests) exists
Last build of libvirt in CentOS9 has removed default config files in /etc/sysconfig . This is making some file_line resources to fail as the original files no longer exist. This patch is creating empty files if the target files don't exist, so that this is compatible with centos8 and centos9 (before and after default config files removal). [1] https://bugzilla.redhat.com/show_bug.cgi?id=2042529 Closes-Bug: #1959601 Change-Id: Iff9daf3d284c725d40ecfb85500d77951c3fefcd
This commit is contained in:

committed by
Takashi Kajinami

parent
1b7ccd8c08
commit
99830f8a2d
@@ -58,11 +58,20 @@ class nova::compute::libvirt_guests (
|
||||
include nova::deps
|
||||
|
||||
Anchor['nova::config::begin']
|
||||
-> File<| tag =='libvirt-guests-file' |>
|
||||
-> File_line<| tag == 'libvirt-guests-file_line'|>
|
||||
-> Anchor['nova::config::end']
|
||||
|
||||
case $::osfamily {
|
||||
'RedHat': {
|
||||
# NOTE(tkajinam): Since libvirt 8.1.0, the sysconfig files are
|
||||
# no longer provided by packages.
|
||||
file { '/etc/sysconfig/libvirt-guests':
|
||||
ensure => present,
|
||||
path => '/etc/sysconfig/libvirt-guests',
|
||||
tag => 'libvirt-guests-file',
|
||||
}
|
||||
|
||||
file_line { '/etc/sysconfig/libvirt-guests ON_BOOT':
|
||||
path => '/etc/sysconfig/libvirt-guests',
|
||||
line => "ON_BOOT=${on_boot}",
|
||||
|
@@ -222,6 +222,7 @@ class nova::migration::libvirt(
|
||||
if $configure_libvirt {
|
||||
Anchor['nova::config::begin']
|
||||
-> Libvirtd_config<||>
|
||||
-> File<| tag == 'libvirt-file'|>
|
||||
-> File_line<| tag == 'libvirt-file_line'|>
|
||||
-> Anchor['nova::config::end']
|
||||
|
||||
@@ -348,6 +349,14 @@ class nova::migration::libvirt(
|
||||
$libvirtd_args = ''
|
||||
}
|
||||
|
||||
# NOTE(tkajinam): Since libvirt 8.1.0, the sysconfig files are
|
||||
# no longer provided by packages.
|
||||
file { '/etc/sysconfig/libvirtd':
|
||||
ensure => present,
|
||||
path => '/etc/sysconfig/libvirtd',
|
||||
tag => 'libvirt-file',
|
||||
}
|
||||
|
||||
file_line { '/etc/sysconfig/libvirtd libvirtd args':
|
||||
path => '/etc/sysconfig/libvirtd',
|
||||
line => "LIBVIRTD_ARGS=${libvirtd_args}",
|
||||
|
@@ -39,9 +39,26 @@ describe 'nova::compute::libvirt_guests' do
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_file_line('/etc/sysconfig/libvirt-guests ON_BOOT').with(:line => 'ON_BOOT=ignore') }
|
||||
it { is_expected.to contain_file_line('/etc/sysconfig/libvirt-guests ON_SHUTDOWN').with(:line => "ON_SHUTDOWN=shutdown") }
|
||||
it { is_expected.to contain_file_line('/etc/sysconfig/libvirt-guests SHUTDOWN_TIMEOUT').with(:line => "SHUTDOWN_TIMEOUT=300") }
|
||||
it { is_expected.to contain_file('/etc/sysconfig/libvirt-guests').with(
|
||||
:ensure => 'present',
|
||||
:path => '/etc/sysconfig/libvirt-guests',
|
||||
:tag => 'libvirt-guests-file',
|
||||
) }
|
||||
it { is_expected.to contain_file_line('/etc/sysconfig/libvirt-guests ON_BOOT').with(
|
||||
:path => '/etc/sysconfig/libvirt-guests',
|
||||
:line => 'ON_BOOT=ignore',
|
||||
:tag => 'libvirt-guests-file_line'
|
||||
) }
|
||||
it { is_expected.to contain_file_line('/etc/sysconfig/libvirt-guests ON_SHUTDOWN').with(
|
||||
:path => '/etc/sysconfig/libvirt-guests',
|
||||
:line => "ON_SHUTDOWN=shutdown",
|
||||
:tag => 'libvirt-guests-file_line'
|
||||
) }
|
||||
it { is_expected.to contain_file_line('/etc/sysconfig/libvirt-guests SHUTDOWN_TIMEOUT').with(
|
||||
:path => '/etc/sysconfig/libvirt-guests',
|
||||
:line => "SHUTDOWN_TIMEOUT=300",
|
||||
:tag => 'libvirt-guests-file_line'
|
||||
) }
|
||||
|
||||
it { is_expected.to contain_package('libvirt-guests').with(
|
||||
:name => 'libvirt-client',
|
||||
|
@@ -482,6 +482,11 @@ describe 'nova::migration::libvirt' do
|
||||
:libvirt_version => '4.5' }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_file('/etc/sysconfig/libvirtd').with(
|
||||
:ensure => 'present',
|
||||
:path => '/etc/sysconfig/libvirtd',
|
||||
:tag => 'libvirt-file',
|
||||
)}
|
||||
it { is_expected.to contain_file_line('/etc/sysconfig/libvirtd libvirtd args').with(
|
||||
:path => '/etc/sysconfig/libvirtd',
|
||||
:line => 'LIBVIRTD_ARGS="--listen"',
|
||||
@@ -500,6 +505,11 @@ describe 'nova::migration::libvirt' do
|
||||
:libvirt_version => '5.6' }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_file('/etc/sysconfig/libvirtd').with(
|
||||
:ensure => 'present',
|
||||
:path => '/etc/sysconfig/libvirtd',
|
||||
:tag => 'libvirt-file',
|
||||
)}
|
||||
it { is_expected.to contain_file_line('/etc/sysconfig/libvirtd libvirtd args').with(
|
||||
:path => '/etc/sysconfig/libvirtd',
|
||||
:line => 'LIBVIRTD_ARGS=',
|
||||
@@ -519,6 +529,11 @@ describe 'nova::migration::libvirt' do
|
||||
:libvirt_version => '5.6' }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_file('/etc/sysconfig/libvirtd').with(
|
||||
:ensure => 'present',
|
||||
:path => '/etc/sysconfig/libvirtd',
|
||||
:tag => 'libvirt-file',
|
||||
)}
|
||||
it { is_expected.to contain_file_line('/etc/sysconfig/libvirtd libvirtd args').with(
|
||||
:path => '/etc/sysconfig/libvirtd',
|
||||
:line => 'LIBVIRTD_ARGS=',
|
||||
|
Reference in New Issue
Block a user