Defined Type: yum::install

Defined in:
manifests/install.pp

Summary

Installs/removes rpms from local file/URL via yum install command.

Overview

Note:

This can be better than using just the rpm provider because it will pull all the dependencies.

Examples:

Sample usage:

yum::install { 'epel-release':
  ensure => 'present',
  source => 'https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm',
}

Parameters:

  • source (String)

    file or URL where RPM is available

  • ensure (Enum['present', 'installed', 'absent', 'purged']) (defaults to: 'present')

    the desired state of the package

  • timeout (Optional[Integer]) (defaults to: undef)

    optional timeout for the installation

  • require_verify (Boolean) (defaults to: false)

    optional argument, will reinstall if rpm verify fails



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
# File 'manifests/install.pp', line 17

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,
      }
    }
  }
}