16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'manifests/copr.pp', line 16
define yum::copr (
String $copr_repo = $title,
Boolean $manage_prereq_plugin = true,
Enum['enabled', 'disabled', 'removed'] $ensure = 'enabled',
) {
$prereq_plugin = $facts['package_provider'] ? {
'dnf' => 'dnf-plugins-core',
default => 'yum-plugin-copr',
}
if $manage_prereq_plugin {
stdlib::ensure_packages([$prereq_plugin])
}
if $facts['package_provider'] == 'dnf' {
case $ensure {
'enabled': {
exec { "dnf -y copr enable ${copr_repo}":
path => '/bin:/usr/bin:/sbin/:/usr/sbin',
unless => "dnf copr list | egrep -q '${copr_repo}\$'",
require => Package[$prereq_plugin],
}
}
'disabled': {
exec { "dnf -y copr disable ${copr_repo}":
path => '/bin:/usr/bin:/sbin/:/usr/sbin',
unless => "dnf copr list | egrep -q '${copr_repo} (disabled)\$'",
require => Package[$prereq_plugin],
}
}
'removed': {
exec { "dnf -y copr remove ${copr_repo}":
path => '/bin:/usr/bin:/sbin/:/usr/sbin',
onlyif => "dnf copr list | egrep -q '${copr_repo}'",
require => Package[$prereq_plugin],
}
}
default: {
fail("The value for ensure for `yum::copr` must be enabled, disabled or removed, but it is ${ensure}.")
}
}
} else {
$copr_repo_name_part = regsubst($copr_repo, '/', '-', 'G')
case $ensure {
'enabled': {
exec { "yum -y copr enable ${copr_repo}":
path => '/bin:/usr/bin:/sbin/:/usr/sbin',
onlyif => "test ! -e /etc/yum.repos.d/_copr_${copr_repo_name_part}.repo",
require => Package[$prereq_plugin],
}
}
'disabled', 'removed': {
exec { "yum -y copr disable ${copr_repo}":
path => '/bin:/usr/bin:/sbin/:/usr/sbin',
onlyif => "test -e /etc/yum.repos.d/_copr_${copr_repo_name_part}.repo",
require => Package[$prereq_plugin],
}
}
default: {
fail("The value for ensure for `yum::copr` must be enabled, disabled or removed, but it is ${ensure}.")
}
}
}
}
|