Puppet Class: psick::packages
- Defined in:
- manifests/packages.pp
Summary
Generic class to manage packagesOverview
This class exposes entrypoints, and data defaults to manage system packages, expressed via arrays or hashes. Be aware of risks of duplicated resources, when specifying here packages that might be installed by other modules or classes. You can use different parameters to manage packages, they all manage package resources, using different approaches:
-
$packages_list An Array of packages to install. If $add_default_packages
if true, to this list is added the $packages_default array
-
$packages_hash An Hash of packages to manage, where keys are package names
and values are arguments passed to the package resurce
-
$packages_osfamily_hash An Hash of packages to manage, where keys are the
osfamily and values are a String, an Array of an Hash of packages to manage.
Windows)
psick::packages::resource_default_arguments:
provider: chocolatey
psick::packages::packages_list:
- "firefox"
- "flashplayerplugin"
psick::packages::delete_unmanaged: true
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'manifests/packages.pp', line 72
class psick::packages (
Array $packages_list = [],
Array $packages_default = [],
Boolean $add_default_packages = true,
Hash $packages_hash = {},
Hash $packages_osfamily_hash = {},
Hash $resource_default_arguments = {},
Boolean $delete_unmanaged = false,
Boolean $manage = $psick::manage,
Boolean $noop_manage = $psick::noop_manage,
Boolean $noop_value = $psick::noop_value,
) {
if $manage {
if $noop_manage {
noop($noop_value)
}
Package {
* => $resource_default_arguments,
}
# Purge umanaged packages if $delete_unmanaged == true (DANGER!)
if $delete_unmanaged {
resources { 'package':
purge => true,
}
}
# Packages management based on $packages_list
$packages = $add_default_packages ? {
true => $packages_list + $packages_default,
false => $packages_list,
}
$packages.each |$pkg| {
ensure_packages($pkg)
}
# Packages management based on $packages_hash
$packages_hash.each |$k,$v| {
package { $k:
* => $v,
}
}
# Packages management based on $packages_osfamily_hash
$packages_osfamily_hash.each |$k,$v| {
if $facts['os']['family'] == $k {
case $v {
Array: {
ensure_packages($v)
}
Hash: {
$v.each |$kk,$vv| {
package { $kk:
* => $vv,
}
}
}
String: {
package { $v:
ensure => present,
}
}
default: {
fail("Unsupported type for ${v}. Valid types are String, Array, Hash")
}
}
}
}
}
}
|