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:
parent
01fc6aacd7
commit
cc01259a64
@ -3,16 +3,10 @@ lookup_options:
|
||||
hiera_classes:
|
||||
merge:
|
||||
strategy: deep
|
||||
profiles::packages::install:
|
||||
profiles::packages::include:
|
||||
merge:
|
||||
strategy: deep
|
||||
profiles::packages::install_exclude:
|
||||
merge:
|
||||
strategy: deep
|
||||
profiles::packages::remove:
|
||||
merge:
|
||||
strategy: deep
|
||||
profiles::packages::remove_exclude:
|
||||
profiles::packages::exclude:
|
||||
merge:
|
||||
strategy: deep
|
||||
profiles::pki::vault::alt_names:
|
||||
@ -172,59 +166,71 @@ profiles::consul::client::node_rules:
|
||||
segment: ''
|
||||
disposition: read
|
||||
|
||||
profiles::packages::install:
|
||||
- bash-completion
|
||||
- bzip2
|
||||
- ccze
|
||||
- curl
|
||||
- dstat
|
||||
- expect
|
||||
- gcc
|
||||
- gzip
|
||||
- git
|
||||
- htop
|
||||
- inotify-tools
|
||||
- iotop
|
||||
- jq
|
||||
- lz4
|
||||
- mtr
|
||||
- ncdu
|
||||
- neovim
|
||||
- p7zip
|
||||
- pbzip2
|
||||
- pigz
|
||||
- pv
|
||||
- python3.11
|
||||
- rsync
|
||||
- screen
|
||||
- socat
|
||||
- strace
|
||||
- sysstat
|
||||
- tar
|
||||
- tmux
|
||||
- traceroute
|
||||
- unzip
|
||||
- vim
|
||||
- vnstat
|
||||
- wget
|
||||
- zsh
|
||||
- zstd
|
||||
|
||||
profiles::packages::remove:
|
||||
- iwl100-firmware
|
||||
- iwl1000-firmware
|
||||
- iwl105-firmware
|
||||
- iwl135-firmware
|
||||
- iwl2000-firmware
|
||||
- iwl2030-firmware
|
||||
- iwl3160-firmware
|
||||
- iwl5000-firmware
|
||||
- iwl5150-firmware
|
||||
- iwl6000-firmware
|
||||
- iwl6000g2a-firmware
|
||||
- iwl6050-firmware
|
||||
- iwl7260-firmware
|
||||
- puppet7-release
|
||||
profiles::packages::include:
|
||||
bash-completion: {}
|
||||
bzip2: {}
|
||||
ccze: {}
|
||||
curl: {}
|
||||
dstat: {}
|
||||
expect: {}
|
||||
gcc: {}
|
||||
gzip: {}
|
||||
git: {}
|
||||
htop: {}
|
||||
inotify-tools: {}
|
||||
iotop: {}
|
||||
jq: {}
|
||||
lz4: {}
|
||||
mtr: {}
|
||||
ncdu: {}
|
||||
neovim: {}
|
||||
p7zip: {}
|
||||
pbzip2: {}
|
||||
pigz: {}
|
||||
pv: {}
|
||||
python3.11: {}
|
||||
rsync: {}
|
||||
screen: {}
|
||||
socat: {}
|
||||
strace: {}
|
||||
sysstat: {}
|
||||
tar: {}
|
||||
tmux: {}
|
||||
traceroute: {}
|
||||
unzip: {}
|
||||
vim: {}
|
||||
vnstat: {}
|
||||
wget: {}
|
||||
zsh: {}
|
||||
zstd: {}
|
||||
iwl100-firmware:
|
||||
ensure: absent
|
||||
iwl1000-firmware:
|
||||
ensure: absent
|
||||
iwl105-firmware:
|
||||
ensure: absent
|
||||
iwl135-firmware:
|
||||
ensure: absent
|
||||
iwl2000-firmware:
|
||||
ensure: absent
|
||||
iwl2030-firmware:
|
||||
ensure: absent
|
||||
iwl3160-firmware:
|
||||
ensure: absent
|
||||
iwl5000-firmware:
|
||||
ensure: absent
|
||||
iwl5150-firmware:
|
||||
ensure: absent
|
||||
iwl6000-firmware:
|
||||
ensure: absent
|
||||
iwl6000g2a-firmware:
|
||||
ensure: absent
|
||||
iwl6050-firmware:
|
||||
ensure: absent
|
||||
iwl7260-firmware:
|
||||
ensure: absent
|
||||
puppet7-release:
|
||||
ensure: absent
|
||||
|
||||
profiles::base::scripts::scripts:
|
||||
puppet: puppetwrapper.py
|
||||
|
||||
@ -8,12 +8,12 @@ profiles::puppet::agent::puppet_version: '7.26.0'
|
||||
hiera_include:
|
||||
- profiles::almalinux::base
|
||||
|
||||
profiles::packages::install:
|
||||
- lzo
|
||||
- network-scripts
|
||||
- policycoreutils
|
||||
- unar
|
||||
- xz
|
||||
profiles::packages::include:
|
||||
lzo: {}
|
||||
network-scripts: {}
|
||||
policycoreutils: {}
|
||||
unar: {}
|
||||
xz: {}
|
||||
|
||||
lm-sensors::package: lm_sensors
|
||||
|
||||
|
||||
@ -6,10 +6,10 @@ profiles::apt::puppet7::mirror: http://apt.puppetlabs.com
|
||||
profiles::apt::puppet7::repo: puppet7
|
||||
profiles::pki::vaultca::ca_cert-path: /usr/local/share/ca-certificates/
|
||||
|
||||
profiles::packages::install:
|
||||
- lzop
|
||||
- python3.11-venv
|
||||
- xz-utils
|
||||
profiles::packages::include:
|
||||
lzop: {}
|
||||
python3.11-venv: {}
|
||||
xz-utils: {}
|
||||
|
||||
lm-sensors::package: lm-sensors
|
||||
networking::nwmgr_dns_none: false
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
---
|
||||
profiles::packages::install:
|
||||
- policycoreutils
|
||||
profiles::packages::include:
|
||||
policycoreutils: {}
|
||||
|
||||
puppetdb::master::config::create_puppet_service_resource: false
|
||||
#puppetdb::master::config::puppetdb_host: "%{lookup('profiles::puppet::puppetdb::puppetdb_host')}"
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
---
|
||||
profiles::packages::install:
|
||||
- cobbler
|
||||
- cobbler3.2-web
|
||||
- httpd
|
||||
- syslinux
|
||||
- dnf-plugins-core
|
||||
- debmirror
|
||||
- pykickstart
|
||||
- fence-agents
|
||||
- selinux-policy-devel
|
||||
- ipxe-bootimgs
|
||||
profiles::packages::include:
|
||||
cobbler: {}
|
||||
cobbler3.2-web: {}
|
||||
httpd: {}
|
||||
syslinux: {}
|
||||
dnf-plugins-core: {}
|
||||
debmirror: {}
|
||||
pykickstart: {}
|
||||
fence-agents: {}
|
||||
selinux-policy-devel: {}
|
||||
ipxe-bootimgs: {}
|
||||
|
||||
profiles::pki::vault::alt_names:
|
||||
- cobbler.main.unkin.net
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
---
|
||||
profiles::packages::install:
|
||||
- puppetserver
|
||||
profiles::packages::include:
|
||||
puppetserver: {}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
---
|
||||
profiles::packages::install:
|
||||
- createrepo
|
||||
profiles::packages::include:
|
||||
createrepo: {}
|
||||
|
||||
profiles::pki::vault::alt_names:
|
||||
- repos.main.unkin.net
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
---
|
||||
profiles::packages::install:
|
||||
- "%{hiera('lm-sensors::package')}"
|
||||
profiles::packages::include:
|
||||
"%{hiera('lm-sensors::package')}": {}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user