Merge pull request 'feat: change packages to Hash' (#120) from neoloc/packages_hash into develop
Reviewed-on: https://git.query.consul/unkinben/puppet-prod/pulls/120
This commit is contained in:
commit
6a3123e12e
@ -3,16 +3,10 @@ lookup_options:
|
|||||||
hiera_classes:
|
hiera_classes:
|
||||||
merge:
|
merge:
|
||||||
strategy: deep
|
strategy: deep
|
||||||
profiles::packages::install:
|
profiles::packages::include:
|
||||||
merge:
|
merge:
|
||||||
strategy: deep
|
strategy: deep
|
||||||
profiles::packages::install_exclude:
|
profiles::packages::exclude:
|
||||||
merge:
|
|
||||||
strategy: deep
|
|
||||||
profiles::packages::remove:
|
|
||||||
merge:
|
|
||||||
strategy: deep
|
|
||||||
profiles::packages::remove_exclude:
|
|
||||||
merge:
|
merge:
|
||||||
strategy: deep
|
strategy: deep
|
||||||
profiles::pki::vault::alt_names:
|
profiles::pki::vault::alt_names:
|
||||||
@ -178,59 +172,71 @@ profiles::consul::client::node_rules:
|
|||||||
segment: ''
|
segment: ''
|
||||||
disposition: read
|
disposition: read
|
||||||
|
|
||||||
profiles::packages::install:
|
profiles::packages::include:
|
||||||
- bash-completion
|
bash-completion: {}
|
||||||
- bzip2
|
bzip2: {}
|
||||||
- ccze
|
ccze: {}
|
||||||
- curl
|
curl: {}
|
||||||
- dstat
|
dstat: {}
|
||||||
- expect
|
expect: {}
|
||||||
- gcc
|
gcc: {}
|
||||||
- gzip
|
gzip: {}
|
||||||
- git
|
git: {}
|
||||||
- htop
|
htop: {}
|
||||||
- inotify-tools
|
inotify-tools: {}
|
||||||
- iotop
|
iotop: {}
|
||||||
- jq
|
jq: {}
|
||||||
- lz4
|
lz4: {}
|
||||||
- mtr
|
mtr: {}
|
||||||
- ncdu
|
ncdu: {}
|
||||||
- neovim
|
neovim: {}
|
||||||
- p7zip
|
p7zip: {}
|
||||||
- pbzip2
|
pbzip2: {}
|
||||||
- pigz
|
pigz: {}
|
||||||
- pv
|
pv: {}
|
||||||
- python3.11
|
python3.11: {}
|
||||||
- rsync
|
rsync: {}
|
||||||
- screen
|
screen: {}
|
||||||
- socat
|
socat: {}
|
||||||
- strace
|
strace: {}
|
||||||
- sysstat
|
sysstat: {}
|
||||||
- tar
|
tar: {}
|
||||||
- tmux
|
tmux: {}
|
||||||
- traceroute
|
traceroute: {}
|
||||||
- unzip
|
unzip: {}
|
||||||
- vim
|
vim: {}
|
||||||
- vnstat
|
vnstat: {}
|
||||||
- wget
|
wget: {}
|
||||||
- zsh
|
zsh: {}
|
||||||
- zstd
|
zstd: {}
|
||||||
|
iwl100-firmware:
|
||||||
profiles::packages::remove:
|
ensure: absent
|
||||||
- iwl100-firmware
|
iwl1000-firmware:
|
||||||
- iwl1000-firmware
|
ensure: absent
|
||||||
- iwl105-firmware
|
iwl105-firmware:
|
||||||
- iwl135-firmware
|
ensure: absent
|
||||||
- iwl2000-firmware
|
iwl135-firmware:
|
||||||
- iwl2030-firmware
|
ensure: absent
|
||||||
- iwl3160-firmware
|
iwl2000-firmware:
|
||||||
- iwl5000-firmware
|
ensure: absent
|
||||||
- iwl5150-firmware
|
iwl2030-firmware:
|
||||||
- iwl6000-firmware
|
ensure: absent
|
||||||
- iwl6000g2a-firmware
|
iwl3160-firmware:
|
||||||
- iwl6050-firmware
|
ensure: absent
|
||||||
- iwl7260-firmware
|
iwl5000-firmware:
|
||||||
- puppet7-release
|
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:
|
profiles::base::scripts::scripts:
|
||||||
puppet: puppetwrapper.py
|
puppet: puppetwrapper.py
|
||||||
|
|||||||
@ -8,12 +8,12 @@ profiles::puppet::agent::puppet_version: '7.26.0'
|
|||||||
hiera_include:
|
hiera_include:
|
||||||
- profiles::almalinux::base
|
- profiles::almalinux::base
|
||||||
|
|
||||||
profiles::packages::install:
|
profiles::packages::include:
|
||||||
- lzo
|
lzo: {}
|
||||||
- network-scripts
|
network-scripts: {}
|
||||||
- policycoreutils
|
policycoreutils: {}
|
||||||
- unar
|
unar: {}
|
||||||
- xz
|
xz: {}
|
||||||
|
|
||||||
lm-sensors::package: lm_sensors
|
lm-sensors::package: lm_sensors
|
||||||
|
|
||||||
|
|||||||
@ -6,10 +6,10 @@ profiles::apt::puppet7::mirror: http://apt.puppetlabs.com
|
|||||||
profiles::apt::puppet7::repo: puppet7
|
profiles::apt::puppet7::repo: puppet7
|
||||||
profiles::pki::vaultca::ca_cert-path: /usr/local/share/ca-certificates/
|
profiles::pki::vaultca::ca_cert-path: /usr/local/share/ca-certificates/
|
||||||
|
|
||||||
profiles::packages::install:
|
profiles::packages::include:
|
||||||
- lzop
|
lzop: {}
|
||||||
- python3.11-venv
|
python3.11-venv: {}
|
||||||
- xz-utils
|
xz-utils: {}
|
||||||
|
|
||||||
lm-sensors::package: lm-sensors
|
lm-sensors::package: lm-sensors
|
||||||
networking::nwmgr_dns_none: false
|
networking::nwmgr_dns_none: false
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
profiles::packages::install:
|
profiles::packages::include:
|
||||||
- policycoreutils
|
policycoreutils: {}
|
||||||
|
|
||||||
puppetdb::master::config::create_puppet_service_resource: false
|
puppetdb::master::config::create_puppet_service_resource: false
|
||||||
#puppetdb::master::config::puppetdb_host: "%{lookup('profiles::puppet::puppetdb::puppetdb_host')}"
|
#puppetdb::master::config::puppetdb_host: "%{lookup('profiles::puppet::puppetdb::puppetdb_host')}"
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
---
|
---
|
||||||
profiles::packages::install:
|
profiles::packages::include:
|
||||||
- cobbler
|
cobbler: {}
|
||||||
- cobbler3.2-web
|
cobbler3.2-web: {}
|
||||||
- httpd
|
httpd: {}
|
||||||
- syslinux
|
syslinux: {}
|
||||||
- dnf-plugins-core
|
dnf-plugins-core: {}
|
||||||
- debmirror
|
debmirror: {}
|
||||||
- pykickstart
|
pykickstart: {}
|
||||||
- fence-agents
|
fence-agents: {}
|
||||||
- selinux-policy-devel
|
selinux-policy-devel: {}
|
||||||
- ipxe-bootimgs
|
ipxe-bootimgs: {}
|
||||||
|
|
||||||
profiles::pki::vault::alt_names:
|
profiles::pki::vault::alt_names:
|
||||||
- cobbler.main.unkin.net
|
- cobbler.main.unkin.net
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
---
|
---
|
||||||
profiles::packages::install:
|
profiles::packages::include:
|
||||||
- puppetserver
|
puppetserver: {}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
profiles::packages::install:
|
profiles::packages::include:
|
||||||
- createrepo
|
createrepo: {}
|
||||||
|
|
||||||
profiles::pki::vault::alt_names:
|
profiles::pki::vault::alt_names:
|
||||||
- repos.main.unkin.net
|
- repos.main.unkin.net
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
---
|
---
|
||||||
profiles::packages::install:
|
profiles::packages::include:
|
||||||
- "%{hiera('lm-sensors::package')}"
|
"%{hiera('lm-sensors::package')}": {}
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
# profiles::firstrun::packages
|
# 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
|
# include the correct package repositories, define the install_packages exec
|
||||||
case $facts['os']['family'] {
|
case $facts['os']['family'] {
|
||||||
'RedHat': {
|
'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
|
# 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(' ')
|
$package_list = $packages.join(' ')
|
||||||
|
|
||||||
# install all the packages
|
# install all the packages
|
||||||
|
|||||||
@ -1,23 +1,19 @@
|
|||||||
# This class manages the installation of packages for the base profile
|
# This class manages the installation of packages for the base profile
|
||||||
#
|
#
|
||||||
# Parameters:
|
# Parameters:
|
||||||
# - $install: An array of package names to be installed
|
# - $include: A hash of package names to be managed
|
||||||
# - $remove: An array of package names to be removed
|
# - $exclude: An array of package names to be removed from managed hash
|
||||||
#
|
#
|
||||||
class profiles::packages (
|
class profiles::packages (
|
||||||
Array $install = [],
|
Hash $include = {},
|
||||||
Array $install_exclude = [],
|
Array[String] $exclude = [],
|
||||||
Array $remove = [],
|
|
||||||
Array $remove_exclude = [],
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
# Filter out excluded packages
|
# Filter the include hash to remove the packages listed in exclude
|
||||||
$install_real = $install.filter |$item| { !$install_exclude.any |$exclude_item| { $exclude_item == $item } }
|
$filtered_include = filter($include) |$key, $value| {
|
||||||
$remove_real = $remove.filter |$item| { !$remove_exclude.any |$exclude_item| { $exclude_item == $item } }
|
!($key in $exclude)
|
||||||
|
}
|
||||||
|
|
||||||
# Ensure packages to install are installed
|
# Manage packages
|
||||||
ensure_packages($install_real, {'ensure' => 'present'})
|
ensure_packages($filtered_include)
|
||||||
|
|
||||||
# Ensure packages to remove are absent
|
|
||||||
ensure_packages($remove_real, {'ensure' => 'absent'})
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user