From 4b874656a915e8f5655f83db7a69087fb21bc6f2 Mon Sep 17 00:00:00 2001 From: Romain Dartigues Date: Sun, 17 Mar 2024 18:33:14 +0100 Subject: [PATCH] more types for AlmaLinux Untested yet. --- cdist/conf/type/__consul/manifest | 2 +- cdist/conf/type/__consul_agent/manifest | 9 +++++++-- cdist/conf/type/__consul_template/manifest | 4 ++-- cdist/conf/type/__filesystem/explorer/lsblk | 2 +- cdist/conf/type/__firewalld_start/gencode-remote | 2 +- cdist/conf/type/__hostname/gencode-remote | 4 ++-- cdist/conf/type/__hostname/manifest | 4 ++-- cdist/conf/type/__hwclock/manifest | 6 +++--- .../type/__install_bootloader_grub/explorer/target_os | 5 +++++ cdist/conf/type/__locale/manifest | 2 +- cdist/conf/type/__locale_system/manifest | 2 +- cdist/conf/type/__localedef/gencode-remote | 2 +- cdist/conf/type/__package_update_index/explorer/type | 2 +- cdist/conf/type/__package_upgrade_all/gencode-remote | 2 +- cdist/conf/type/__postfix_master/manifest | 2 +- cdist/conf/type/__postfix_postconf/explorer/value | 2 +- cdist/conf/type/__postfix_postconf/gencode-remote | 2 +- cdist/conf/type/__postfix_reload/gencode-remote | 2 +- cdist/conf/type/__postgres_conf/explorer/postgres_user | 2 +- cdist/conf/type/__sensible_editor/manifest | 2 +- cdist/conf/type/__sshd_config/manifest | 2 +- cdist/conf/type/__start_on_boot/explorer/state | 2 +- cdist/conf/type/__sysctl/gencode-remote | 2 +- cdist/conf/type/__sysctl/manifest | 2 +- cdist/conf/type/__timezone/manifest | 2 +- cdist/conf/type/__ufw/manifest | 4 ++++ cdist/conf/type/__unpack/gencode-remote | 2 +- cdist/conf/type/__unpack/manifest | 2 +- cdist/test/autil/fixtures/explorer/os | 5 +++++ cdist/test/autil/fixtures/explorer/os_version | 2 +- 30 files changed, 52 insertions(+), 33 deletions(-) diff --git a/cdist/conf/type/__consul/manifest b/cdist/conf/type/__consul/manifest index 156eb667..4871d832 100755 --- a/cdist/conf/type/__consul/manifest +++ b/cdist/conf/type/__consul/manifest @@ -24,7 +24,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - alpine|scientific|centos|redhat|ubuntu|debian|devuan|archlinux|gentoo) + almalinux|alpine|scientific|centos|redhat|ubuntu|debian|devuan|archlinux|gentoo) # any linux should work : ;; diff --git a/cdist/conf/type/__consul_agent/manifest b/cdist/conf/type/__consul_agent/manifest index 7b54529c..add6b1e9 100755 --- a/cdist/conf/type/__consul_agent/manifest +++ b/cdist/conf/type/__consul_agent/manifest @@ -136,7 +136,7 @@ init_upstart() manual_setup () { case "$os" in - alpine|scientific|centos|debian|devuan|redhat|ubuntu) + almalinux|alpine|scientific|centos|debian|devuan|redhat|ubuntu) # whitelist safeguard : ;; @@ -174,9 +174,14 @@ manual_setup () { devuan) init_sysvinit debian ;; - centos|redhat) + almalinux|centos|redhat) os_version="$(sed 's/[^0-9.]//g' "$__global/explorer/os_version")" major_version="${os_version%%.*}" + if [ "$os" = almalinux ] + then + init_systemd + return + fi case "$major_version" in [456]) init_sysvinit redhat diff --git a/cdist/conf/type/__consul_template/manifest b/cdist/conf/type/__consul_template/manifest index b02fc332..8793d6cc 100755 --- a/cdist/conf/type/__consul_template/manifest +++ b/cdist/conf/type/__consul_template/manifest @@ -22,7 +22,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - scientific|centos|redhat) + almalinux|scientific|centos|redhat) # whitelist safeguard service_onchange='service consul-template status >/dev/null && service consul-template reload || true' \ ;; @@ -151,7 +151,7 @@ require="__directory${conf_dir}" \ # Install init script to start on boot service="consul-template" case "$os" in - centos|redhat) + almalinux|centos|redhat) os_version="$(sed 's/[^0-9.]//g' "$__global/explorer/os_version")" major_version="${os_version%%.*}" case "$major_version" in diff --git a/cdist/conf/type/__filesystem/explorer/lsblk b/cdist/conf/type/__filesystem/explorer/lsblk index d376c09f..e37a1b64 100644 --- a/cdist/conf/type/__filesystem/explorer/lsblk +++ b/cdist/conf/type/__filesystem/explorer/lsblk @@ -27,7 +27,7 @@ else fi case "$os" in - alpine|centos|fedora|gentoo|redhat|suse|ubuntu) + almalinux|alpine|centos|fedora|gentoo|redhat|suse|ubuntu) if [ ! -x "$(command -v lsblk)" ]; then echo "lsblk is required for __filesystem type" >&2 exit 1 diff --git a/cdist/conf/type/__firewalld_start/gencode-remote b/cdist/conf/type/__firewalld_start/gencode-remote index 3e767f68..b94a35b9 100755 --- a/cdist/conf/type/__firewalld_start/gencode-remote +++ b/cdist/conf/type/__firewalld_start/gencode-remote @@ -64,7 +64,7 @@ else echo service \"$name\" \"$cmd\" ;; - amazon|scientific|centos|fedora|owl|redhat|suse) + almalinux|amazon|scientific|centos|fedora|owl|redhat|suse) echo service \"$name\" \"$cmd\" ;; diff --git a/cdist/conf/type/__hostname/gencode-remote b/cdist/conf/type/__hostname/gencode-remote index c1a97ac8..27878e50 100755 --- a/cdist/conf/type/__hostname/gencode-remote +++ b/cdist/conf/type/__hostname/gencode-remote @@ -32,7 +32,7 @@ else case ${os} in # RedHat-derivatives and BSDs - (centos|fedora|redhat|scientific|freebsd|macosx|netbsd|openbsd) + (almalinux|centos|fedora|redhat|scientific|freebsd|macosx|netbsd|openbsd) # Hostname is FQDN name_should=${__target_host:?} ;; @@ -67,7 +67,7 @@ in "&& hostnamectl set-hostname '${name_should}'" \ "|| hostname '${name_should}'" ;; - (centos|fedora|redhat|scientific|freebsd|netbsd|openbsd|gentoo|void) + (almalinux|centos|fedora|redhat|scientific|freebsd|netbsd|openbsd|gentoo|void) echo "hostname '${name_should}'" ;; (openwrt) diff --git a/cdist/conf/type/__hostname/manifest b/cdist/conf/type/__hostname/manifest index b80aa2ef..d9653a96 100755 --- a/cdist/conf/type/__hostname/manifest +++ b/cdist/conf/type/__hostname/manifest @@ -36,7 +36,7 @@ else case ${os} in # RedHat-derivatives and BSDs - (centos|fedora|redhat|scientific|freebsd|netbsd|openbsd|slackware|suse) + (almalinux|centos|fedora|redhat|scientific|freebsd|netbsd|openbsd|slackware|suse) # Hostname is FQDN name_should=${__target_host:?} ;; @@ -77,7 +77,7 @@ in # --value "\"$name_should\"" fi ;; - (centos|fedora|redhat|scientific) + (almalinux|centos|fedora|redhat|scientific) if test -z "${has_hostnamectl}" then # Only write to /etc/sysconfig/network on non-systemd versions. diff --git a/cdist/conf/type/__hwclock/manifest b/cdist/conf/type/__hwclock/manifest index 7d9ab88f..3fe53ac4 100755 --- a/cdist/conf/type/__hwclock/manifest +++ b/cdist/conf/type/__hwclock/manifest @@ -62,7 +62,7 @@ in unset CDIST_ORDER_DEPENDENCY fi ;; - (centos|fedora|redhat|scientific) + (almalinux|centos|fedora|redhat|scientific) os_version=$(cat "${__global:?}/explorer/os_version") os_major=$(expr "${os_version}" : '.* release \([0-9]*\)') case ${os} @@ -73,13 +73,13 @@ in (fedora) update_sysconfig=$(test "${os_major}" -lt 10 && echo true || echo false) ;; - (redhat|*) + (almalinux|redhat|*) case ${os_version} in ('Red Hat Enterprise Linux'*) update_sysconfig=$(test "${os_major}" -lt 6 && echo true || echo false) ;; - ('Red Hat Linux'*) + ('Red Hat Linux'*|'AlmaLinux'*) update_sysconfig=true ;; (*) diff --git a/cdist/conf/type/__install_bootloader_grub/explorer/target_os b/cdist/conf/type/__install_bootloader_grub/explorer/target_os index f235710a..193c06b2 100755 --- a/cdist/conf/type/__install_bootloader_grub/explorer/target_os +++ b/cdist/conf/type/__install_bootloader_grub/explorer/target_os @@ -70,6 +70,11 @@ if [ -f "$chroot/etc/owl-release" ]; then fi ### Redhat and derivatives +if grep -q ^AlmaLinux "$chroot/etc/redhat-release" 2>/dev/null; then + echo almalinux + exit 0 +fi + if grep -q ^CentOS "$chroot/etc/redhat-release" 2>/dev/null; then echo centos exit 0 diff --git a/cdist/conf/type/__locale/manifest b/cdist/conf/type/__locale/manifest index 9f1e17ac..cf42a7c4 100755 --- a/cdist/conf/type/__locale/manifest +++ b/cdist/conf/type/__locale/manifest @@ -30,7 +30,7 @@ case "$os" in # Debian needs a seperate package __package locales --state present ;; - archlinux|suse|ubuntu|scientific|centos|alpine) + almalinux|archlinux|suse|ubuntu|scientific|centos|alpine) : ;; *) diff --git a/cdist/conf/type/__locale_system/manifest b/cdist/conf/type/__locale_system/manifest index 4b996ebc..bb29d212 100755 --- a/cdist/conf/type/__locale_system/manifest +++ b/cdist/conf/type/__locale_system/manifest @@ -79,7 +79,7 @@ in archlinux) locale_conf="/etc/locale.conf" ;; - centos|redhat|scientific) + almalinux|centos|redhat|scientific) # shellcheck source=/dev/null version_id=$(. "${__global}/explorer/os_release" && echo "${VERSION_ID:-0}") if echo "${version_id}" | version_ge 7 diff --git a/cdist/conf/type/__localedef/gencode-remote b/cdist/conf/type/__localedef/gencode-remote index 4538151f..51f1041a 100755 --- a/cdist/conf/type/__localedef/gencode-remote +++ b/cdist/conf/type/__localedef/gencode-remote @@ -61,7 +61,7 @@ in printf '%s does not support locales.\n' "${os}" >&2 exit 1 ;; - (archlinux|debian|devuan|ubuntu|suse|centos|fedora|redhat|scientific) + (almalinux|archlinux|debian|devuan|ubuntu|suse|centos|fedora|redhat|scientific) # FIXME: The code below only works for glibc-based installations. # NOTE: Hardcoded, create a pull request in case it is at another diff --git a/cdist/conf/type/__package_update_index/explorer/type b/cdist/conf/type/__package_update_index/explorer/type index c98e1e67..20751d74 100644 --- a/cdist/conf/type/__package_update_index/explorer/type +++ b/cdist/conf/type/__package_update_index/explorer/type @@ -23,7 +23,7 @@ else # By default determine package manager based on operating system os="$("$__explorer/os")" case "$os" in - amazon|scientific|centos|fedora|redhat) echo "yum" ;; + almalinux|amazon|scientific|centos|fedora|redhat) echo "yum" ;; debian|ubuntu|devuan) echo "apt" ;; archlinux) echo "pacman" ;; alpine) echo "apk" ;; diff --git a/cdist/conf/type/__package_upgrade_all/gencode-remote b/cdist/conf/type/__package_upgrade_all/gencode-remote index d332e851..063ffee9 100755 --- a/cdist/conf/type/__package_upgrade_all/gencode-remote +++ b/cdist/conf/type/__package_upgrade_all/gencode-remote @@ -38,7 +38,7 @@ else # By default determine package manager based on operating system os="$(cat "$__global/explorer/os")" case "$os" in - amazon|scientific|centos|fedora|redhat) type="yum" ;; + almalinux|amazon|scientific|centos|fedora|redhat) type="yum" ;; debian|ubuntu|devuan) type="apt" ;; archlinux) type="pacman" ;; *) diff --git a/cdist/conf/type/__postfix_master/manifest b/cdist/conf/type/__postfix_master/manifest index 0960ea41..7f29f9ec 100755 --- a/cdist/conf/type/__postfix_master/manifest +++ b/cdist/conf/type/__postfix_master/manifest @@ -22,7 +22,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - ubuntu|debian|archlinux|scientific|centos|devuan) + almalinux|ubuntu|debian|archlinux|scientific|centos|devuan) : ;; *) diff --git a/cdist/conf/type/__postfix_postconf/explorer/value b/cdist/conf/type/__postfix_postconf/explorer/value index 67dacad8..403e602a 100755 --- a/cdist/conf/type/__postfix_postconf/explorer/value +++ b/cdist/conf/type/__postfix_postconf/explorer/value @@ -22,7 +22,7 @@ os=$("$__explorer/os") case "$os" in - alpine|ubuntu|debian|archlinux|suse|scientific|centos|devuan) + almalinux|alpine|ubuntu|debian|archlinux|suse|scientific|centos|devuan) : ;; *) diff --git a/cdist/conf/type/__postfix_postconf/gencode-remote b/cdist/conf/type/__postfix_postconf/gencode-remote index 279dddd4..6553ad71 100755 --- a/cdist/conf/type/__postfix_postconf/gencode-remote +++ b/cdist/conf/type/__postfix_postconf/gencode-remote @@ -22,7 +22,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - alpine|archlinux|centos|debian|devuan|suse|scientific|ubuntu) + almalinux|alpine|archlinux|centos|debian|devuan|suse|scientific|ubuntu) : ;; *) diff --git a/cdist/conf/type/__postfix_reload/gencode-remote b/cdist/conf/type/__postfix_reload/gencode-remote index 7720dc49..2b4e5611 100755 --- a/cdist/conf/type/__postfix_reload/gencode-remote +++ b/cdist/conf/type/__postfix_reload/gencode-remote @@ -22,7 +22,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - ubuntu|debian|archlinux|scientific|centos|devuan) + almalinux|ubuntu|debian|archlinux|scientific|centos|devuan) echo "postfix reload" ;; *) diff --git a/cdist/conf/type/__postgres_conf/explorer/postgres_user b/cdist/conf/type/__postgres_conf/explorer/postgres_user index c6582dc4..1a492d89 100644 --- a/cdist/conf/type/__postgres_conf/explorer/postgres_user +++ b/cdist/conf/type/__postgres_conf/explorer/postgres_user @@ -26,7 +26,7 @@ in (alpine) echo 'postgres' ;; - (centos|rhel|scientific) + (almalinux|centos|rhel|scientific) echo 'postgres' ;; (debian|devuan|ubuntu) diff --git a/cdist/conf/type/__sensible_editor/manifest b/cdist/conf/type/__sensible_editor/manifest index 1cdb0c2c..96f134b6 100644 --- a/cdist/conf/type/__sensible_editor/manifest +++ b/cdist/conf/type/__sensible_editor/manifest @@ -67,7 +67,7 @@ in (echo "${os_version}" | version_ge 10.04) || package_name='debianutils' pkg_type='apt' ;; - centos|fedora|redhat|scientific) + almalinux|centos|fedora|redhat|scientific) pkg_type='yum' ;; *) diff --git a/cdist/conf/type/__sshd_config/manifest b/cdist/conf/type/__sshd_config/manifest index e37afebb..0928bc62 100755 --- a/cdist/conf/type/__sshd_config/manifest +++ b/cdist/conf/type/__sshd_config/manifest @@ -24,7 +24,7 @@ state_should=$(cat "${__object:?}/parameter/state") case ${os} in - (alpine|centos|fedora|redhat|scientific|debian|devuan|ubuntu) + (almalinux|alpine|centos|fedora|redhat|scientific|debian|devuan|ubuntu) if test "${state_should}" != 'absent' then __package openssh-server --state present diff --git a/cdist/conf/type/__start_on_boot/explorer/state b/cdist/conf/type/__start_on_boot/explorer/state index b7a6cf0f..90fcb289 100644 --- a/cdist/conf/type/__start_on_boot/explorer/state +++ b/cdist/conf/type/__start_on_boot/explorer/state @@ -62,7 +62,7 @@ else [ -f "/etc/init/${name}.conf" ] && state="present" ;; - amazon|scientific|centos|fedora|owl|redhat) + almalinux|amazon|scientific|centos|fedora|owl|redhat) state=$(chkconfig --level "$runlevel" "$name" || echo absent) [ "$state" ] || state="present" ;; diff --git a/cdist/conf/type/__sysctl/gencode-remote b/cdist/conf/type/__sysctl/gencode-remote index f0f6deef..a2b584c1 100755 --- a/cdist/conf/type/__sysctl/gencode-remote +++ b/cdist/conf/type/__sysctl/gencode-remote @@ -30,7 +30,7 @@ fi os=$(cat "$__global/explorer/os") case "$os" in # Linux - redhat|centos|ubuntu|debian|devuan|archlinux|gentoo|coreos) + almalinux|redhat|centos|ubuntu|debian|devuan|archlinux|gentoo|coreos) flag='-w' ;; # BusyBox diff --git a/cdist/conf/type/__sysctl/manifest b/cdist/conf/type/__sysctl/manifest index 71dea7f7..cfd671b2 100755 --- a/cdist/conf/type/__sysctl/manifest +++ b/cdist/conf/type/__sysctl/manifest @@ -25,7 +25,7 @@ os=$(cat "$__global/explorer/os") case "$os" in # Linux - alpine|redhat|centos|ubuntu|debian|devuan|archlinux|coreos) + almalinux|alpine|redhat|centos|ubuntu|debian|devuan|archlinux|coreos) : ;; # BSD diff --git a/cdist/conf/type/__timezone/manifest b/cdist/conf/type/__timezone/manifest index 0eb7fb9c..8adf468b 100755 --- a/cdist/conf/type/__timezone/manifest +++ b/cdist/conf/type/__timezone/manifest @@ -42,7 +42,7 @@ case "$os" in # whitelist : ;; - scientific|centos) + almalinux|scientific|centos) __package tzdata --state present export require="__package/tzdata" __file /etc/sysconfig/clock \ diff --git a/cdist/conf/type/__ufw/manifest b/cdist/conf/type/__ufw/manifest index 370b7ff5..9466a995 100755 --- a/cdist/conf/type/__ufw/manifest +++ b/cdist/conf/type/__ufw/manifest @@ -25,6 +25,10 @@ case "$state" in os="$(cat "$__global/explorer/os")" case "$os" in + almalinux) + __package epel-release + require='__package/epel-release' __package ufw + ;; centos) # shellcheck source=/dev/null if (. "$__global/explorer/os_release" && [ "${VERSION_ID}" = "7" ]); then diff --git a/cdist/conf/type/__unpack/gencode-remote b/cdist/conf/type/__unpack/gencode-remote index c4451f73..2c4c5de0 100755 --- a/cdist/conf/type/__unpack/gencode-remote +++ b/cdist/conf/type/__unpack/gencode-remote @@ -33,7 +33,7 @@ case "$src" in ;; *.7z) case "$os" in - centos|fedora|redhat) + almalinux|centos|fedora|redhat) cmd='7za' ;; *) diff --git a/cdist/conf/type/__unpack/manifest b/cdist/conf/type/__unpack/manifest index 6bdf5a10..6f38c55f 100755 --- a/cdist/conf/type/__unpack/manifest +++ b/cdist/conf/type/__unpack/manifest @@ -23,7 +23,7 @@ case "$src" in debian|ubuntu|devuan) __package xz-utils ;; - alpine|centos) + almalinux|alpine|centos) __package xz ;; esac diff --git a/cdist/test/autil/fixtures/explorer/os b/cdist/test/autil/fixtures/explorer/os index 094685ea..9f4cd3d5 100755 --- a/cdist/test/autil/fixtures/explorer/os +++ b/cdist/test/autil/fixtures/explorer/os @@ -77,6 +77,11 @@ if [ -f /etc/owl-release ]; then fi ### Redhat and derivatives +if grep -q ^AlmaLinux /etc/redhat-release 2>/dev/null; then + echo almalinux + exit 0 +fi + if grep -q ^Scientific /etc/redhat-release 2>/dev/null; then echo scientific exit 0 diff --git a/cdist/test/autil/fixtures/explorer/os_version b/cdist/test/autil/fixtures/explorer/os_version index 380782cc..d5d4dae3 100755 --- a/cdist/test/autil/fixtures/explorer/os_version +++ b/cdist/test/autil/fixtures/explorer/os_version @@ -54,7 +54,7 @@ case "$($__explorer/os)" in owl) cat /etc/owl-release ;; - redhat|centos|mitel|scientific) + almalinux|redhat|centos|mitel|scientific) cat /etc/redhat-release ;; slackware)