Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[master] feat: Add OS grain mappings for AlmaLinux Kitten #66991

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/66991.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add detection for OS grains when running in [AlmaLinux Kitten](https://wiki.almalinux.org/release-notes/kitten-10.html)
12 changes: 11 additions & 1 deletion salt/grains/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1775,6 +1775,7 @@ def id_():
"cloudlinux": "CloudLinux",
"virtuozzo": "Virtuozzo",
"almalinux": "AlmaLinux",
"almalinuxk": "AlmaLinux",
"pidora": "Fedora",
"scientific": "ScientificLinux",
"synology": "Synology",
Expand Down Expand Up @@ -1846,6 +1847,7 @@ def _derive_os_grain(osfullname, os_id=None):
"CloudLinux": "RedHat",
"Virtuozzo": "RedHat",
"AlmaLinux": "RedHat",
"AlmaLinux Kitten": "RedHat",
"OVS": "RedHat",
"OEL": "RedHat",
"XCP": "RedHat",
Expand Down Expand Up @@ -2492,7 +2494,15 @@ def _osrelease_data(os, osfullname, osrelease):
grains["osrelease_info"],
)

if os in ("Debian", "FreeBSD", "OpenBSD", "NetBSD", "Mac", "Raspbian"):
if os in (
"Debian",
"FreeBSD",
"OpenBSD",
"NetBSD",
"Mac",
"Raspbian",
"AlmaLinux",
):
os_name = os
else:
os_name = osfullname
Expand Down
54 changes: 48 additions & 6 deletions tests/pytests/unit/grains/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,10 @@ def test_gnu_slash_linux_in_os_name():
orig_import = __import__
built_in = "builtins"

def _import_mock(name, *args):
def _import_mock(name, *args, **kwargs):
if name == "lsb_release":
raise ImportError("No module named lsb_release")
return orig_import(name, *args)
return orig_import(name, *args, **kwargs)

# - Skip the first if statement
# - Skip the selinux/systemd stuff (not pertinent)
Expand Down Expand Up @@ -526,10 +526,10 @@ def test_suse_os_from_cpe_data():
orig_import = __import__
built_in = "builtins"

def _import_mock(name, *args):
def _import_mock(name, *args, **kwargs):
if name == "lsb_release":
raise ImportError("No module named lsb_release")
return orig_import(name, *args)
return orig_import(name, *args, **kwargs)

distro_mock = MagicMock(
return_value=("SUSE Linux Enterprise Server ", "12", "x86_64")
Expand Down Expand Up @@ -595,10 +595,10 @@ def _run_os_grains_tests(os_release_data, os_release_map, expectation):
orig_import = __import__
built_in = "builtins"

def _import_mock(name, *args):
def _import_mock(name, *args, **kwargs):
if name == "lsb_release":
raise ImportError("No module named lsb_release")
return orig_import(name, *args)
return orig_import(name, *args, **kwargs)

suse_release_file = os_release_map.get("suse_release_file")

Expand Down Expand Up @@ -1155,6 +1155,48 @@ def test_almalinux_8_os_grains():
_run_os_grains_tests(_os_release_data, {}, expectation)


@pytest.mark.skip_unless_on_linux
def test_almalinux_kitten_os_grains():
"""
Test that 'os' grain will properly detect AlmaLinux Kitten
"""
# /etc/os-release data taken from an AlmaLinux Kitten VM, install ISO
# AlmaLinux-Kitten-10-20241018.0-x86_64_v2-minimal.iso. At the time of
# writting, there was no docker image for Kitten
_os_release_data = {
"NAME": "AlmaLinux Kitten",
"VERSION": "10 (Lion Cub)",
"ID": "almalinux",
"ID_LIKE": "rhel centos fedora",
"VERSION_ID": "10",
"PLATFORM_ID": "platform:el10",
"PRETTY_NAME": "AlmaLinux Kitten 10 (Lion Cub)",
"ANSI_COLOR": "0;34",
"LOGO": "fedora-logo-icon",
"CPE_NAME": "cpe:/o:almalinux:almalinux:10::baseos",
"HOME_URL": "https://almalinux.org/",
"DOCUMENTATION_URL": "https://wiki.almalinux.org/",
"VENDOR_NAME": "AlmaLinux",
"VENDOR_URL": "https://almalinux.org/",
"BUG_REPORT_URL": "https://bugs.almalinux.org/",
"ALMALINUX_MANTISBT_PROJECT": "AlmaLinux-10",
"ALMALINUX_MANTISBT_PROJECT_VERSION": "10",
"REDHAT_SUPPORT_PRODUCT": "AlmaLinux",
"REDHAT_SUPPORT_PRODUCT_VERSION": "10",
}
expectation = {
"os": "AlmaLinux",
"os_family": "RedHat",
"oscodename": "Lion Cub",
"osfullname": "AlmaLinux Kitten",
"osrelease": "10",
"osrelease_info": (10,),
"osmajorrelease": 10,
"osfinger": "AlmaLinux-10",
}
_run_os_grains_tests(_os_release_data, {}, expectation)


@pytest.mark.skip_unless_on_linux
def test_virtuozzo_7_os_grains():
"""
Expand Down
Loading