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:
2024-07-27 04:09:59 +10:00
parent 01fc6aacd7
commit cc01259a64
10 changed files with 115 additions and 106 deletions
+9 -2
View File
@@ -1,5 +1,7 @@
# profiles::firstrun::packages
class profiles::firstrun::packages {
class profiles::firstrun::packages (
Hash $manage = lookup('profiles::packages::include'),
) {
# include the correct package repositories, define the install_packages exec
case $facts['os']['family'] {
'RedHat': {
@@ -15,8 +17,13 @@ class profiles::firstrun::packages {
}
}
# filter out packages with 'ensure' set to 'absent'
$packages_to_install = $manage.filter |$package, $options| {
!($options['ensure'] and $options['ensure'] == 'absent')
}
# get all the packages to install, and convert into a space separated list
$packages = hiera_array('profiles::packages::install', [])
$packages = $packages_to_install.keys
$package_list = $packages.join(' ')
# install all the packages