From 1d1b727772b4c866cabacb0a6b942285c4c31be9 Mon Sep 17 00:00:00 2001 From: Sergey Cherevko Date: Mon, 20 Jan 2025 16:25:50 +0300 Subject: [PATCH 1/2] Added MSVSphere support --- salt/cloud/deploy/bootstrap-salt.sh | 87 ++++++++++++++++++- salt/grains/core.py | 4 +- .../pkg/integration/test_enabled_disabled.py | 1 + .../pytests/pkg/integration/test_salt_user.py | 1 + tests/pytests/pkg/integration/test_version.py | 1 + tests/support/pkg.py | 7 +- 6 files changed, 95 insertions(+), 6 deletions(-) diff --git a/salt/cloud/deploy/bootstrap-salt.sh b/salt/cloud/deploy/bootstrap-salt.sh index c632146..d530c3f 100644 --- a/salt/cloud/deploy/bootstrap-salt.sh +++ b/salt/cloud/deploy/bootstrap-salt.sh @@ -1081,7 +1081,7 @@ __strip_duplicates() { __sort_release_files() { KNOWN_RELEASE_FILES=$(echo "(arch|alpine|centos|debian|ubuntu|fedora|redhat|suse|\ mandrake|mandriva|gentoo|slackware|turbolinux|unitedlinux|void|lsb|system|\ - oracle|os|almalinux|rocky)(-|_)(release|version)" | sed -E 's:[[:space:]]::g') + oracle|os|almalinux|rocky|msvsphere)(-|_)(release|version)" | sed -E 's:[[:space:]]::g') primary_release_files="" secondary_release_files="" # Sort know VS un-known files first @@ -1095,7 +1095,7 @@ __sort_release_files() { done # Now let's sort by know files importance, max important goes last in the max_prio list - max_prio="redhat-release centos-release oracle-release fedora-release almalinux-release rocky-release" + max_prio="redhat-release centos-release oracle-release fedora-release almalinux-release rocky-release sphere-release" for entry in $max_prio; do if [ "$(echo "${primary_release_files}" | grep "$entry")" != "" ]; then primary_release_files=$(echo "${primary_release_files}" | sed -e "s:\\(.*\\)\\($entry\\)\\(.*\\):\\2 \\1 \\3:g") @@ -1226,6 +1226,7 @@ __gather_linux_system_info() { oracle ) n="Oracle Linux" ;; almalinux ) n="AlmaLinux" ;; rocky ) n="Rocky Linux" ;; + rocky ) n="MSVSphere" ;; system ) while read -r line; do [ "${n}x" != "systemx" ] && break @@ -1973,14 +1974,14 @@ elif [ "${DISTRO_NAME_L}" = "debian" ]; then __debian_codename_translation fi -if [ "$(echo "${DISTRO_NAME_L}" | grep -E '(debian|ubuntu|centos|gentoo|red_hat|oracle|scientific|amazon|fedora|macosx|almalinux|rocky)')" = "" ] && [ "$ITYPE" = "stable" ] && [ "$STABLE_REV" != "latest" ]; then +if [ "$(echo "${DISTRO_NAME_L}" | grep -E '(debian|ubuntu|centos|gentoo|red_hat|oracle|scientific|amazon|fedora|macosx|almalinux|rocky|msvsphere)')" = "" ] && [ "$ITYPE" = "stable" ] && [ "$STABLE_REV" != "latest" ]; then echoerror "${DISTRO_NAME} does not have major version pegged packages support" exit 1 fi # Only RedHat based distros have testing support if [ "${ITYPE}" = "testing" ]; then - if [ "$(echo "${DISTRO_NAME_L}" | grep -E '(centos|red_hat|amazon|oracle|almalinux|rocky)')" = "" ]; then + if [ "$(echo "${DISTRO_NAME_L}" | grep -E '(centos|red_hat|amazon|oracle|almalinux|rocky|msvsphere)')" = "" ]; then echoerror "${DISTRO_NAME} does not have testing packages support" exit 1 fi @@ -5719,6 +5720,84 @@ install_almalinux_check_services() { # ####################################################################################################################### +####################################################################################################################### +# +# MSVSphere Install Functions +# +install_msvsphere_stable_deps() { + install_centos_stable_deps || return 1 + return 0 +} + +install_msvsphere_git_deps() { + install_centos_git_deps || return 1 + return 0 +} + +install_msvsphere_onedir_deps() { + install_centos_onedir_deps || return 1 + return 0 +} + +install_msvsphere_testing_deps() { + install_centos_testing_deps || return 1 + return 0 +} + +install_msvsphere_stable() { + install_centos_stable || return 1 + return 0 +} + +install_msvsphere_git() { + install_centos_git || return 1 + return 0 +} + +install_msvsphere_onedir() { + install_centos_onedir || return 1 + return 0 +} + +install_msvsphere_testing() { + install_centos_testing || return 1 + return 0 +} + +install_msvsphere_stable_post() { + install_centos_stable_post || return 1 + return 0 +} + +install_msvsphere_git_post() { + install_centos_git_post || return 1 + return 0 +} + +install_msvsphere_onedir_post() { + install_centos_onedir_post || return 1 + return 0 +} + +install_msvsphere_testing_post() { + install_centos_testing_post || return 1 + return 0 +} + +install_msvsphere_restart_daemons() { + install_centos_restart_daemons || return 1 + return 0 +} + +install_msvsphere_check_services() { + install_centos_check_services || return 1 + return 0 +} +# +# Ended MSVSphere Install Functions +# +####################################################################################################################### + ####################################################################################################################### # # Rocky Linux Install Functions diff --git a/salt/grains/core.py b/salt/grains/core.py index 17a1d68..bbd3830 100644 --- a/salt/grains/core.py +++ b/salt/grains/core.py @@ -1772,6 +1772,7 @@ _OS_NAME_MAP = { "cloudserve": "CloudLinux", "cloudlinux": "CloudLinux", "almalinux": "AlmaLinux", + "msvsphere": "MSVSphere", "pidora": "Fedora", "scientific": "ScientificLinux", "synology": "Synology", @@ -2145,7 +2146,7 @@ def _os_release_quirks_for_oscodename(os_release): # Astra Linux has no version codename, but Salt used # to report the variant ID as oscodename. return os_release.get("VARIANT_ID") - if os_release["ID"] in ("almalinux", "rocky"): + if os_release["ID"] in ("almalinux", "rocky", "msvsphere"): # VERSION_CODENAME is not set, but the codename is # mentioned in PRETTY_NAME and VERSION. match = _VERSION_RE.match(os_release.get("VERSION", "")) @@ -2234,6 +2235,7 @@ def _linux_distribution_data(): "debian", "linuxmint", "mendel", + "msvsphere", "pop", "rocky", "ubuntu", diff --git a/tests/pytests/pkg/integration/test_enabled_disabled.py b/tests/pytests/pkg/integration/test_enabled_disabled.py index 99097b1..b4eef3c 100644 --- a/tests/pytests/pkg/integration/test_enabled_disabled.py +++ b/tests/pytests/pkg/integration/test_enabled_disabled.py @@ -14,6 +14,7 @@ def test_services(install_salt, salt_cli, salt_minion): elif install_salt.distro_id in ( "almalinux", "rocky", + "msvsphere", "centos", "redhat", "amzn", diff --git a/tests/pytests/pkg/integration/test_salt_user.py b/tests/pytests/pkg/integration/test_salt_user.py index 74bf458..2f50614 100644 --- a/tests/pytests/pkg/integration/test_salt_user.py +++ b/tests/pytests/pkg/integration/test_salt_user.py @@ -191,6 +191,7 @@ def test_paths_log_rotation( if install_salt.distro_id not in ( "almalinux", "rocky", + "msvsphere", "centos", "redhat", "amzn", diff --git a/tests/pytests/pkg/integration/test_version.py b/tests/pytests/pkg/integration/test_version.py index 24a665d..61e967c 100644 --- a/tests/pytests/pkg/integration/test_version.py +++ b/tests/pytests/pkg/integration/test_version.py @@ -128,6 +128,7 @@ def test_compare_pkg_versions_redhat_rc(version, install_salt): if install_salt.distro_id not in ( "almalinux", "rocky", + "msvsphere", "centos", "redhat", "amzn", diff --git a/tests/support/pkg.py b/tests/support/pkg.py index d9c6487..eed579a 100644 --- a/tests/support/pkg.py +++ b/tests/support/pkg.py @@ -114,6 +114,7 @@ class SaltPkgInstall: if self.distro_id in ( "almalinux", "rocky", + "msvsphere", "centos", "redhat", "amzn", @@ -131,6 +132,7 @@ class SaltPkgInstall: if self.distro_id in ( "almalinux", "rocky", + "msvsphere", "centos", "redhat", "amzn", @@ -147,6 +149,7 @@ class SaltPkgInstall: if self.distro_id in ( "almalinux", "rocky", + "msvsphere", "centos", "redhat", "amzn", @@ -171,6 +174,7 @@ class SaltPkgInstall: if self.distro_id in ( "almalinux", "rocky", + "msvsphere", "centos", "redhat", "amzn", @@ -611,7 +615,7 @@ class SaltPkgInstall: "3006.0" ) distro_name = self.distro_name - if distro_name in ("almalinux", "rocky", "centos", "fedora"): + if distro_name in ("almalinux", "rocky", "centos", "fedora", "msvsphere"): distro_name = "redhat" root_url = "salt/py3/" if self.classic: @@ -620,6 +624,7 @@ class SaltPkgInstall: if self.distro_name in [ "almalinux", "rocky", + "msvsphere", "redhat", "centos", "amazon", -- 2.43.5