Update packages after adding repos

Make sure we upgrade packages after adding
repos so we have the latest packages when
testing in integration and beaker.

Change-Id: Ide4863f859931231636f21299be9d45f693d3b61
This commit is contained in:
Tobias Urdin 2018-08-22 23:51:30 +02:00
parent a025a23601
commit 0a06eabd9b
2 changed files with 30 additions and 8 deletions

View File

@ -15,6 +15,7 @@ class openstack_integration::repos {
release => 'rocky', release => 'rocky',
package_require => true, package_require => true,
uca_location => pick($::uca_mirror_host, 'http://ubuntu-cloud.archive.canonical.com/ubuntu'), uca_location => pick($::uca_mirror_host, 'http://ubuntu-cloud.archive.canonical.com/ubuntu'),
before => File['/tmp/update-packages'],
} }
} }
'debian': { 'debian': {
@ -22,6 +23,7 @@ class openstack_integration::repos {
class { '::openstack_extras::repo::debian::debian': class { '::openstack_extras::repo::debian::debian':
release => 'queens', release => 'queens',
package_require => true, package_require => true,
before => File['/tmp/update-packages'],
} }
} }
default: { default: {
@ -35,11 +37,13 @@ class openstack_integration::repos {
apt::pin { 'ceph': apt::pin { 'ceph':
priority => 1001, priority => 1001,
originator => "Ceph ${ceph_version_cap}", originator => "Ceph ${ceph_version_cap}",
before => File['/tmp/update-packages'],
} }
} else { } else {
apt::pin { 'ceph': apt::pin { 'ceph':
priority => 1001, priority => 1001,
origin => 'download.ceph.com', origin => 'download.ceph.com',
before => File['/tmp/update-packages'],
} }
} }
$enable_sig = false $enable_sig = false
@ -64,6 +68,7 @@ class openstack_integration::repos {
'gpgcheck' => 'no', 'gpgcheck' => 'no',
}, },
}, },
before => File['/tmp/update-packages'],
} }
# TODO(tobasco): Remove this CBS candidate repo for Mimic when Storage SIG release it. # TODO(tobasco): Remove this CBS candidate repo for Mimic when Storage SIG release it.
$ceph_mirror_fallback = $ceph_version_real ? { $ceph_mirror_fallback = $ceph_version_real ? {
@ -89,6 +94,7 @@ class openstack_integration::repos {
matches => [ 'fedora*.repo' ], matches => [ 'fedora*.repo' ],
rmdirs => false, rmdirs => false,
require => Class['::openstack_extras::repo::redhat::redhat'], require => Class['::openstack_extras::repo::redhat::redhat'],
before => File['/tmp/update-packages'],
} }
} }
} }
@ -101,6 +107,30 @@ class openstack_integration::repos {
enable_sig => $enable_sig, enable_sig => $enable_sig,
enable_epel => $enable_epel, enable_epel => $enable_epel,
ceph_mirror => $ceph_mirror, ceph_mirror => $ceph_mirror,
before => File['/tmp/update-packages'],
}
# We want to upgrade packages after repos is added but only once
# to not break idempotency. Must be done in here so it applies to
# both integration and beaker tests.
if $::osfamily == 'RedHat' {
if $::operatingsystem == 'Fedora' {
$yum_cmd = '/usr/bin/dnf'
} else {
$yum_cmd = '/usr/bin/yum'
}
$update_cmd = "${yum_cmd} update -y"
} else {
$update_cmd = '/usr/bin/apt upgrade -y'
}
file { '/tmp/update-packages':
ensure => 'present',
notify => Exec['update-packages'],
}
exec { 'update-packages':
command => $update_cmd,
refreshonly => true,
} }
} }

View File

@ -204,14 +204,6 @@ if [ "${MANAGE_REPOS}" = true ]; then
print_header 'Puppet failed to install repositories.' print_header 'Puppet failed to install repositories.'
exit 1 exit 1
fi fi
if is_fedora; then
print_header 'Updating packages'
$SUDO $YUM update -y
if [ $? -ne 0 ]; then
print_header 'Error updating packages'
exit 1
fi
fi
fi fi
print_header "Running Puppet Scenario: ${SCENARIO} (1st time)" print_header "Running Puppet Scenario: ${SCENARIO} (1st time)"