feat: change packages to Hash
- change from multiple arrays for managing packages to a hash - change to ensure_packages to prevent duplicate resource conflicts
This commit is contained in:
@@ -1,23 +1,19 @@
|
||||
# This class manages the installation of packages for the base profile
|
||||
#
|
||||
# Parameters:
|
||||
# - $install: An array of package names to be installed
|
||||
# - $remove: An array of package names to be removed
|
||||
# - $include: A hash of package names to be managed
|
||||
# - $exclude: An array of package names to be removed from managed hash
|
||||
#
|
||||
class profiles::packages (
|
||||
Array $install = [],
|
||||
Array $install_exclude = [],
|
||||
Array $remove = [],
|
||||
Array $remove_exclude = [],
|
||||
Hash $include = {},
|
||||
Array[String] $exclude = [],
|
||||
) {
|
||||
|
||||
# Filter out excluded packages
|
||||
$install_real = $install.filter |$item| { !$install_exclude.any |$exclude_item| { $exclude_item == $item } }
|
||||
$remove_real = $remove.filter |$item| { !$remove_exclude.any |$exclude_item| { $exclude_item == $item } }
|
||||
# Filter the include hash to remove the packages listed in exclude
|
||||
$filtered_include = filter($include) |$key, $value| {
|
||||
!($key in $exclude)
|
||||
}
|
||||
|
||||
# Ensure packages to install are installed
|
||||
ensure_packages($install_real, {'ensure' => 'present'})
|
||||
|
||||
# Ensure packages to remove are absent
|
||||
ensure_packages($remove_real, {'ensure' => 'absent'})
|
||||
# Manage packages
|
||||
ensure_packages($filtered_include)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user