From 0245bebbbf00dfe2fa7abc0b4699590d9834ac14 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Wed, 19 Aug 2020 19:15:56 +0900 Subject: [PATCH] CentOS: automatical package update after reposities setup Change-Id: Iec248a80c430f3b10a34886f28aa8bc791c9f806 --- manifests/repo/redhat/redhat.pp | 30 ++++++++++++++----- ...dhat-update_packages-d52c3fe93e97ac76.yaml | 7 +++++ 2 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 releasenotes/notes/repo-redhat-update_packages-d52c3fe93e97ac76.yaml diff --git a/manifests/repo/redhat/redhat.pp b/manifests/repo/redhat/redhat.pp index d5aa080..e84e7a0 100644 --- a/manifests/repo/redhat/redhat.pp +++ b/manifests/repo/redhat/redhat.pp @@ -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 { - exec { 'yum_refresh': - command => '/usr/bin/yum clean all', + $yum_command = 'yum' + } + + exec { 'yum_refresh': + command => "/usr/bin/${yum_command} clean all", + refreshonly => true, + } + + if $update_packages { + exec { 'yum_update': + command => "/usr/bin/${yum_command} update -y", refreshonly => true, - } -> Package <||> + } + Exec['yum_refresh'] -> Exec['yum_update'] -> Package <||> + } + else { + Exec['yum_refresh'] -> Package <||> } } diff --git a/releasenotes/notes/repo-redhat-update_packages-d52c3fe93e97ac76.yaml b/releasenotes/notes/repo-redhat-update_packages-d52c3fe93e97ac76.yaml new file mode 100644 index 0000000..8a76692 --- /dev/null +++ b/releasenotes/notes/repo-redhat-update_packages-d52c3fe93e97ac76.yaml @@ -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.