Skip to content

Commit 4d7ffb1

Browse files
committed
Support failover yum repositories.
It is now possible to specify the `repo_base` parameter as array as well as a string. ```puppet class{ 'cvmfs': base_url => ['http://cvmrepo.s3.cern.ch/cvmrepo/yum/','http://cvmrepo.web.cern.ch/cvmrepo/yum'] } ``` in which both yum repositories will be used in failover. A second yum repository has been configured as a part of default repositories for yum installations. Note that when using Debian family of OS there will no failover and the first element of the array will be chosen if provided.
1 parent 7bedb80 commit 4d7ffb1

File tree

6 files changed

+80
-33
lines changed

6 files changed

+80
-33
lines changed

REFERENCE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,9 @@ Default value: `'present'`
406406

407407
##### <a name="-cvmfs--repo_base"></a>`repo_base`
408408

409-
Data type: `Stdlib::Httpurl`
409+
Data type: `Variant[Stdlib::Httpurl,Array[Stdlib::Httpurl,1]]`
410410

411-
URL containing stable, testing and config apt or yum repositories. Default in hiera data.
411+
URL containing stable, testing and config apt or yum repositories. If an array is specified then on RedHat family multiple repos will be configured with failover. On Debian family the array can have length 1 only, failover is not supported for Debian.
412412

413413
##### <a name="-cvmfs--repo_base_alt"></a>`repo_base_alt`
414414

data/family/RedHat.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22

3-
cvmfs::repo_base: https://cvmrepo.s3.cern.ch/cvmrepo/yum
3+
cvmfs::repo_base:
4+
- 'https://cvmrepo.s3.cern.ch/cvmrepo/yum'
5+
- 'https://cvmrepo.web.cern.ch/cvmrepo/yum'
46
cvmfs::repo_base_alt: https://cvmrepo.web.cern.ch/cvmrepo/yum
57
cvmfs::repo_gpgkey: https://cvmrepo.s3.cern.ch/cvmrepo/yum/RPM-GPG-KEY-CernVM-2048
68
cvmfs::repo_includepkgs:

manifests/apt.pp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22
# @api private
33
#
44
class cvmfs::apt (
5-
Stdlib::Httpurl $repo_base = $cvmfs::repo_base,
5+
Variant[Stdlib::Httpurl,Array[Stdlib::Httpurl,1]] $repo_base = $cvmfs::repo_base,
66
Stdlib::Httpurl $repo_gpgkey = $cvmfs::repo_gpgkey,
77
Boolean $repo_testing_enabled = $cvmfs::repo_testing_enabled,
88
Boolean $repo_future_enabled = $cvmfs::repo_future_enabled,
99
Optional[Stdlib::Httpurl] $repo_proxy = $cvmfs::repo_proxy,
1010
Boolean $repo_gpgcheck = $cvmfs::repo_gpgcheck,
11-
1211
) {
12+
# We already reject arrays of more than one element in init.pp
13+
$_location = Array($repo_base,true)[0]
14+
1315
Apt::Source {
1416
allow_unsigned => ! $repo_gpgcheck,
1517
comment => 'CernVM File System',
16-
location => $repo_base,
18+
location => $_location,
1719
key => {
1820
ensure => refreshed,
1921
id => 'FD80468D49B3B24C341741FC8CE0A76C497EA957',

manifests/init.pp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@
9090
# @param cvmfs_debuglog Create a debug log file at this location.
9191
# @param cvmfs_max_ttl Max ttl.
9292
# @param cvmfs_version Version of cvmfs to install.
93-
# @param repo_base URL containing stable, testing and config apt or yum repositories. Default in hiera data.
93+
# @param repo_base
94+
# URL containing stable, testing and config apt or yum repositories. If an array is specified then on RedHat family multiple repos will be configured with failover. On Debian family the array can have length 1 only, failover is not supported for Debian.
9495
# @param repo_base_alt URL containing stable, Same as repo_base, hosted on a different backend. Default in hiera data.
9596
# @param repo_includepkgs Specify an includepkgs to the yum repos to ignore other packages.
9697
# @param repo_priority Yum priority of repositories
@@ -145,7 +146,7 @@
145146
# @param cvmfs_yum_includepkgs Deprecated, use repo_includepkgs
146147
#
147148
class cvmfs (
148-
Stdlib::Httpurl $repo_base,
149+
Variant[Stdlib::Httpurl,Array[Stdlib::Httpurl,1]] $repo_base,
149150
Stdlib::Httpurl $repo_base_alt,
150151
Stdlib::Httpurl $repo_gpgkey,
151152
Variant[Undef,String] $cvmfs_http_proxy,
@@ -238,6 +239,11 @@
238239
}
239240
}
240241

242+
# Unsupported combinations
243+
if $facts['os']['family'] == 'Debian' and $repo_base =~ Array[Any,2] {
244+
fail('With Debian family OSes only a single url for the \"repo_base\" parameter is supported')
245+
}
246+
241247
if $repo_manage {
242248
case $facts['os']['family'] {
243249
'RedHat': {

manifests/yum.pp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# @api private
33
#
44
class cvmfs::yum (
5-
Stdlib::Httpurl $repo_base = $cvmfs::repo_base,
5+
Variant[Stdlib::Httpurl,Array[Stdlib::Httpurl,1]] $repo_base = $cvmfs::repo_base,
66
Stdlib::Httpurl $repo_base_alt = $cvmfs::repo_base_alt,
77
Stdlib::Httpurl $repo_gpgkey = $cvmfs::repo_gpgkey,
88
Integer $repo_priority = $cvmfs::repo_priority,
@@ -33,28 +33,32 @@
3333
default => 'EL'
3434
}
3535

36+
$_repo_base = Array($repo_base, true)
37+
$_major = $facts['os']['release']['major']
38+
$_arch = $facts['os']['architecture']
39+
3640
yumrepo { 'cvmfs':
37-
descr => "CVMFS yum repository for ${_dir}${facts['os']['release']['major']}",
38-
baseurl => "${repo_base}/cvmfs/${_dir}/${facts['os']['release']['major']}/${facts['os']['architecture']}",
41+
descr => "CVMFS yum repository for ${_dir}${_major}",
42+
baseurl => $_repo_base.map | $_r | { "${_r}/cvmfs/${_dir}/${_major}/${_arch}" }.join(' '),
3943
enabled => true,
4044
}
4145

4246
yumrepo { 'cvmfs-testing':
43-
descr => "CVMFS-testing yum repository for ${_dir}${facts['os']['release']['major']}. Same binaries as production repo, released earlier. Very stable.",
44-
baseurl => "${repo_base}/cvmfs-testing/${_dir}/${facts['os']['release']['major']}/${facts['os']['architecture']}",
47+
descr => "CVMFS-testing yum repository for ${_dir}${_major}. Same binaries as production repo, released earlier. Very stable.",
48+
baseurl => $_repo_base.map | $_r | { "${_r}/cvmfs-testing/${_dir}/${_major}/${_arch}" }.join(' '),
4549
enabled => $repo_testing_enabled,
4650
}
4751

4852
yumrepo { 'cvmfs-future':
49-
descr => "CVMFS-future yum repository for ${_dir}${facts['os']['release']['major']}. Tagged pre-releases. Stable.",
53+
descr => "CVMFS-future yum repository for ${_dir}${_major}. Tagged pre-releases. Stable.",
5054
# note the use of repo_base_alt - this is in principle a mirror of repo_base, but prereleases are published there first
51-
baseurl => "${repo_base_alt}/cvmfs-future/${_dir}/${facts['os']['release']['major']}/${facts['os']['architecture']}",
55+
baseurl => "${repo_base_alt}/cvmfs-future/${_dir}/${_major}/${_arch}",
5256
enabled => $repo_future_enabled,
5357
}
5458

5559
yumrepo { 'cvmfs-config':
56-
descr => "CVMFS config yum repository for ${_dir}${facts['os']['release']['major']}",
57-
baseurl => "${repo_base}/cvmfs-config/${_dir}/${facts['os']['release']['major']}/${facts['os']['architecture']}",
60+
descr => "CVMFS config yum repository for ${_dir}${_major}",
61+
baseurl => $_repo_base.map | $_r | { "${_r}/cvmfs-config/${_dir}/${_major}/${_arch}" }.join(' '),
5862
enabled => $repo_config_enabled,
5963
}
6064
}

spec/classes/init_spec.rb

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,30 +96,30 @@
9696
when '8'
9797
it {
9898
is_expected.to contain_yumrepo('cvmfs').
99-
with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs/EL/8/x86_64').
99+
with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs/EL/8/x86_64 https://cvmrepo.web.cern.ch/cvmrepo/yum/cvmfs/EL/8/x86_64').
100100
with_gpgkey('https://cvmrepo.s3.cern.ch/cvmrepo/yum/RPM-GPG-KEY-CernVM')
101101
}
102102

103-
it { is_expected.to contain_yumrepo('cvmfs-testing').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs-testing/EL/8/x86_64') }
104-
it { is_expected.to contain_yumrepo('cvmfs-config').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs-config/EL/8/x86_64') }
103+
it { is_expected.to contain_yumrepo('cvmfs-testing').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs-testing/EL/8/x86_64 https://cvmrepo.web.cern.ch/cvmrepo/yum/cvmfs-testing/EL/8/x86_64') }
104+
it { is_expected.to contain_yumrepo('cvmfs-config').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs-config/EL/8/x86_64 https://cvmrepo.web.cern.ch/cvmrepo/yum/cvmfs-config/EL/8/x86_64') }
105105
when '9'
106106
it {
107107
is_expected.to contain_yumrepo('cvmfs').
108-
with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs/EL/9/x86_64').
108+
with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs/EL/9/x86_64 https://cvmrepo.web.cern.ch/cvmrepo/yum/cvmfs/EL/9/x86_64').
109109
with_gpgkey('https://cvmrepo.s3.cern.ch/cvmrepo/yum/RPM-GPG-KEY-CernVM')
110110
}
111111

112-
it { is_expected.to contain_yumrepo('cvmfs-testing').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs-testing/EL/9/x86_64') }
113-
it { is_expected.to contain_yumrepo('cvmfs-config').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs-config/EL/9/x86_64') }
112+
it { is_expected.to contain_yumrepo('cvmfs-testing').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs-testing/EL/9/x86_64 https://cvmrepo.web.cern.ch/cvmrepo/yum/cvmfs-testing/EL/9/x86_64') }
113+
it { is_expected.to contain_yumrepo('cvmfs-config').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs-config/EL/9/x86_64 https://cvmrepo.web.cern.ch/cvmrepo/yum/cvmfs-config/EL/9/x86_64') }
114114
else
115115
it {
116116
is_expected.to contain_yumrepo('cvmfs').
117-
with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs/EL/10/x86_64').
117+
with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs/EL/10/x86_64 https://cvmrepo.web.cern.ch/cvmrepo/yum/cvmfs/EL/10/x86_64').
118118
with_gpgkey('https://cvmrepo.s3.cern.ch/cvmrepo/yum/RPM-GPG-KEY-CernVM-2048')
119119
}
120120

121-
it { is_expected.to contain_yumrepo('cvmfs-testing').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs-testing/EL/10/x86_64') }
122-
it { is_expected.to contain_yumrepo('cvmfs-config').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs-config/EL/10/x86_64') }
121+
it { is_expected.to contain_yumrepo('cvmfs-testing').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs-testing/EL/10/x86_64 https://cvmrepo.web.cern.ch/cvmrepo/yum/cvmfs-testing/EL/10/x86_64') }
122+
it { is_expected.to contain_yumrepo('cvmfs-config').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs-config/EL/10/x86_64 https://cvmrepo.web.cern.ch/cvmrepo/yum/cvmfs-config/EL/10/x86_64') }
123123
end
124124
it do
125125
is_expected.to contain_yumrepo('cvmfs').with(
@@ -152,13 +152,13 @@
152152
when 'Fedora'
153153
case facts[:os]['release']['major']
154154
when '41'
155-
it { is_expected.to contain_yumrepo('cvmfs').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs/fedora/41/x86_64') }
156-
it { is_expected.to contain_yumrepo('cvmfs-testing').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs-testing/fedora/41/x86_64') }
157-
it { is_expected.to contain_yumrepo('cvmfs-config').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs-config/fedora/41/x86_64') }
155+
it { is_expected.to contain_yumrepo('cvmfs').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs/fedora/41/x86_64 https://cvmrepo.web.cern.ch/cvmrepo/yum/cvmfs/fedora/41/x86_64') }
156+
it { is_expected.to contain_yumrepo('cvmfs-testing').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs-testing/fedora/41/x86_64 https://cvmrepo.web.cern.ch/cvmrepo/yum/cvmfs-testing/fedora/41/x86_64') }
157+
it { is_expected.to contain_yumrepo('cvmfs-config').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs-config/fedora/41/x86_64 https://cvmrepo.web.cern.ch/cvmrepo/yum/cvmfs-config/fedora/41/x86_64') }
158158
else
159-
it { is_expected.to contain_yumrepo('cvmfs').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs/fedora/42/x86_64') }
160-
it { is_expected.to contain_yumrepo('cvmfs-testing').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs-testing/fedora/42/x86_64') }
161-
it { is_expected.to contain_yumrepo('cvmfs-config').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs-config/fedora/42/x86_64') }
159+
it { is_expected.to contain_yumrepo('cvmfs').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs/fedora/42/x86_64 https://cvmrepo.web.cern.ch/cvmrepo/yum/cvmfs/fedora/42/x86_64') }
160+
it { is_expected.to contain_yumrepo('cvmfs-testing').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs-testing/fedora/42/x86_64 https://cvmrepo.web.cern.ch/cvmrepo/yum/cvmfs/fedora/42/x86_64') }
161+
it { is_expected.to contain_yumrepo('cvmfs-config').with_baseurl('https://cvmrepo.s3.cern.ch/cvmrepo/yum/cvmfs-config/fedora/42/x86_64 https://cvmrepo.web.cern.ch/cvmrepo/yum/cvmfs/fedora/42/x86_64') }
162162
end
163163
else
164164
case facts[:os]['distro']['codename']
@@ -260,7 +260,7 @@
260260
end
261261
end
262262

263-
context 'with repo_base set to http://example.org/base' do
263+
context 'with repo_base set to a string http://example.org/base' do
264264
let(:params) do
265265
{ repo_base: 'http://example.org/base',
266266
cvmfs_http_proxy: :undef }
@@ -277,6 +277,39 @@
277277
end
278278
end
279279

280+
context 'with repo_base set to array of size 1 [http://example.org/base]' do
281+
let(:params) do
282+
{ repo_base: ['http://example.org/base'],
283+
cvmfs_http_proxy: :undef }
284+
end
285+
286+
case facts[:os]['family']
287+
when 'RedHat'
288+
it { is_expected.to contain_yumrepo('cvmfs').with_baseurl(%r{^http://example.org/base/cvmfs/(fedora|EL)/\d+/x86_64$}) }
289+
it { is_expected.to contain_yumrepo('cvmfs-testing').with_baseurl(%r{^http://example.org/base/cvmfs-testing/(EL|fedora)/\d+/x86_64$}) }
290+
it { is_expected.to contain_yumrepo('cvmfs-config').with_baseurl(%r{^http://example.org/base/cvmfs-config/(EL|fedora)/\d+/x86_64$}) }
291+
else
292+
it { is_expected.to contain_apt__source('cvmfs').with_location('http://example.org/base') }
293+
it { is_expected.to contain_apt__source('cvmfs-testing').with_location('http://example.org/base') }
294+
end
295+
end
296+
297+
context 'with repo_base set to an array of size 2 [http://example.org/base,http://example.net/base]' do
298+
let(:params) do
299+
{ repo_base: ['http://example.org/base', 'http://example.net/base'],
300+
cvmfs_http_proxy: :undef }
301+
end
302+
303+
case facts[:os]['family']
304+
when 'RedHat'
305+
it { is_expected.to contain_yumrepo('cvmfs').with_baseurl(%r{^http://example.org/base/cvmfs/(fedora|EL)/\d+/x86_64 http://example.net/base/cvmfs/(fedora|EL)/\d+/x86_64$}) }
306+
it { is_expected.to contain_yumrepo('cvmfs-testing').with_baseurl(%r{^http://example.org/base/cvmfs-testing/(EL|fedora)/\d+/x86_64 http://example.net/base/cvmfs-testing/(EL|fedora)/\d+/x86_64$}) }
307+
it { is_expected.to contain_yumrepo('cvmfs-config').with_baseurl(%r{^http://example.org/base/cvmfs-config/(EL|fedora)/\d+/x86_64 http://example.net/base/cvmfs-config/(EL|fedora)/\d+/x86_64$}) }
308+
else
309+
it { is_expected.to compile.and_raise_error(%r{Debian family OSes only a single url}) }
310+
end
311+
end
312+
280313
context 'with cvmfs_quota_ratio set' do
281314
let(:params) do
282315
{ cvmfs_quota_limit: 'auto',

0 commit comments

Comments
 (0)