Defined Type: virtualbox::extpack

Defined in:
manifests/extpack.pp

Summary

This class (un)installs Oracle's VirtualBox extension pack.

Overview

Parameters:

  • source (String)

    Download extension pack from the given URL. Required string.

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

    Set to ‘present’ to install extension pack. Set to ‘absent’ to uninstall. Defaults to ‘present’

  • verify_checksum (Boolean) (defaults to: true)

    Whether to verify the checksum of the downloaded file. Optional boolean. Defaults to true.

  • checksum_string (Optional[String]) (defaults to: undef)

    If $verify_checksum is true, this is the checksum to use to validate the downloaded file against.

  • checksum_type (Enum['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512']) (defaults to: 'md5')

    If $verify_checksum is true, this is the algorithm to use to validate the checksum. Can be md5, sha1, sha224, sha256, sha384, or sha512. Defaults to ‘md5’

  • extpack_path (Stdlib::Absolutepath) (defaults to: '/usr/lib/virtualbox/ExtensionPacks')

    This is the path where VirtualBox looks for extension packs. Defaults to ‘/usr/lib/virtualbox/ExtensionPacks’



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

define virtualbox::extpack (
  String $source,
  Enum['present', 'absent'] $ensure                                                       = 'present',
  Boolean $verify_checksum                                                                = true,
  Optional[String] $checksum_string                                                       = undef,
  Enum['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512'] $checksum_type              = 'md5',
  Stdlib::Absolutepath $extpack_path                                                      = '/usr/lib/virtualbox/ExtensionPacks',
) {
  if $verify_checksum {
    $_checksum_type   = $checksum_type
    $_checksum_string = $checksum_string
  } else {
    $_checksum_type   = undef
    $_checksum_string = undef
  }

  $dest = "${extpack_path}/${name}"

  archive { "/usr/src/${name}.tgz":
    ensure          => $ensure,
    source          => $source,
    checksum        => $_checksum_string,
    checksum_type   => $_checksum_type,
    checksum_verify => $verify_checksum,
    extract         => false,
    require         => Class['virtualbox'],
  }

  case $ensure {
    'present': {
      exec { "${name} unpack":
        command => "mkdir -p ${dest} && tar --no-same-owner --no-same-permissions -xzf /usr/src/${name}.tgz -C ${dest}",
        creates => $dest,
        timeout => 120,
        path    => $facts['path'],
        require => Archive["/usr/src/${name}.tgz"],
      }
    }
    'absent': {
      file { $dest:
        ensure  => absent,
        recurse => true,
        purge   => true,
        force   => true,
      }
    }
    default: { fail('Unknown value for $ensure.') }
  }
}