- change from multiple arrays for managing packages to a hash - change to ensure_packages to prevent duplicate resource conflicts
35 lines
1023 B
Puppet
35 lines
1023 B
Puppet
# 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': {
|
|
include profiles::yum::global
|
|
$install_command = 'dnf install -y'
|
|
}
|
|
'Debian': {
|
|
include profiles::apt::global
|
|
$install_command = 'apt-get install -y'
|
|
}
|
|
default: {
|
|
fail("Unsupported OS family ${facts['os']['family']}")
|
|
}
|
|
}
|
|
|
|
# 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 = $packages_to_install.keys
|
|
$package_list = $packages.join(' ')
|
|
|
|
# install all the packages
|
|
exec { 'install_packages':
|
|
command => "${install_command} ${package_list}",
|
|
path => ['/bin', '/usr/bin'],
|
|
}
|
|
}
|