CentOS: automatical package update after reposities setup

Change-Id: Iec248a80c430f3b10a34886f28aa8bc791c9f806
(cherry picked from commit 0245bebbbf)
This commit is contained in:
Takashi Kajinami 2020-08-19 19:15:56 +09:00
parent 80a6efa08b
commit eb992610c9
2 changed files with 30 additions and 7 deletions

View File

@ -69,6 +69,11 @@
# (optional) URL of CentOS mirror.
# Defaults to 'http://mirror.centos.org'
#
# [*update_packages*]
# (optional) Whether to update all packages after yum repositories are
# configured.
# Defaults to false
#
class openstack_extras::repo::redhat::redhat(
$release = $::openstack_extras::repo::redhat::params::release,
$manage_rdo = true,
@ -83,6 +88,7 @@ class openstack_extras::repo::redhat::redhat(
$package_require = false,
$manage_priorities = true,
$centos_mirror_url = 'http://mirror.centos.org',
$update_packages = false,
) inherits openstack_extras::repo::redhat::params {
validate_legacy(String, 'validate_string', $release)
@ -205,14 +211,24 @@ class openstack_extras::repo::redhat::redhat(
}
if ($::operatingsystem == 'Fedora') or (Integer.new($os_major) >= 8) {
exec { 'yum_refresh':
command => '/usr/bin/dnf clean all',
refreshonly => true,
} -> Package <||>
$yum_command = 'dnf'
} else {
$yum_command = 'yum'
}
exec { 'yum_refresh':
command => '/usr/bin/yum clean all',
command => "/usr/bin/${yum_command} clean all",
refreshonly => true,
} -> Package <||>
}
if $update_packages {
exec { 'yum_update':
command => "/usr/bin/${yum_command} update -y",
refreshonly => true,
}
Exec['yum_refresh'] -> Exec['yum_update'] -> Package <||>
}
else {
Exec['yum_refresh'] -> Package <||>
}
}

View File

@ -0,0 +1,7 @@
---
features:
- |
The new ``update_package`` parameter has been added to the
``openstack_extras::repo::redhat::redhat`` class. This parameter is set to
false by default, but when it is set to true then all packages are updated
once dnf/yum repositories are configured.