forked from CERIT-SC/puppet-yum
-
-
Notifications
You must be signed in to change notification settings - Fork 99
/
install.pp
53 lines (50 loc) · 1.59 KB
/
install.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
#
# @summary Installs/removes rpms from local file/URL via yum install command.
#
# @note This can be better than using just the rpm provider because it will pull all the dependencies.
#
# @param source file or URL where RPM is available
# @param ensure the desired state of the package
# @param timeout optional timeout for the installation
# @param require_verify optional argument, will reinstall if rpm verify fails
#
# @example Sample usage:
# yum::install { 'epel-release':
# ensure => 'present',
# source => 'https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm',
# }
#
define yum::install (
String $source,
Enum['present', 'installed', 'absent', 'purged'] $ensure = 'present',
Boolean $require_verify = false,
Optional[Integer] $timeout = undef,
) {
Exec {
path => '/bin:/usr/bin:/sbin:/usr/sbin',
environment => 'LC_ALL=C',
}
case $ensure {
'present', 'installed', default: {
if $require_verify {
exec { "yum-reinstall-${name}":
command => "yum -y reinstall '${source}'",
onlyif => "rpm -q '${name}'",
unless => "rpm -V '${name}'",
timeout => $timeout,
before => Exec["yum-install-${name}"],
}
}
exec { "yum-install-${name}":
command => "yum -y install '${source}'",
unless => "rpm -q '${name}'",
timeout => $timeout,
}
}
'absent', 'purged': {
package { $name:
ensure => $ensure,
}
}
}
}