Repository: cobbler/cobbler

Issue:
Reintroduce support for older Anaconda boot options.
### Describe the bug

Prior to RHEL 7 (and Fedora 17), anaconda was using different boot line options.
Cobbler has been (partially) switched to the newer options with https://github.com/cobbler/cobbler/commit/902d0c43b861f4eae360861acf1f07ced74a0648. However, while this allows cobbler to work with anaconda versions that have removed the deprecated options (like CentOS Stream 9), this breaks anaconda versions that don't have the newer options, that is everything earlier than RHEL 7 and Fedora 17. All these distributions are indeed not supported anymore, but there are still use cases where installing these legacy distros is needed.

### Steps to reproduce

1. Add RHEL 7
2. Install system
3. See error for `inst.ks` instead of `inst` on the generated boot config file.

### Expected behavior

Both old and new RHEL based distributions should be installable.

### Cobbler version

````paste below
Not applicable
````

### Operating system

Indpendant

### Cobbler log

````paste below
Not applicable
````

### Screenshots

Not applicable

### Additional information

Issue information was extracted from #2888



Discussion:

Resolving patch:
diff --git a/cobbler/actions/buildiso/netboot.py b/cobbler/actions/buildiso/netboot.py
--- a/cobbler/actions/buildiso/netboot.py
+++ b/cobbler/actions/buildiso/netboot.py
@@ -204,7 +204,10 @@ def _generate_append_redhat(self):
             self.append_line += (
                 f" proxy={self.data['proxy']} http_proxy={self.data['proxy']}"
             )
-        self.append_line += f" inst.ks={self.data['autoinstall']}"
+        if self.dist.os_version in ["rhel4", "rhel5", "rhel6", "fedora16"]:
+            self.append_line += " ks=%s" % self.data["autoinstall"]
+        else:
+            self.append_line += " inst.ks=%s" % self.data["autoinstall"]
 
     def _generate_append_debian(self, system):
         """
@@ -366,10 +369,13 @@ def generate_system(
         self.append_line += buildiso.add_remaining_kopts(self.data["kernel_options"])
         return self.append_line
 
-    def generate_profile(self, distro_breed: str, protocol: str = "http") -> str:
+    def generate_profile(
+        self, distro_breed: str, os_version: str, protocol: str = "http"
+    ) -> str:
         """
         Generate the append line for the kernel for a network installation.
         :param distro_breed: The name of the distribution breed.
+        :param os_version: The OS version of the distribution.
         :param protocol: The scheme that is used to read the autoyast file from the server
         :return: The generated append line.
         """
@@ -400,7 +406,10 @@ def generate_profile(self, distro_breed: str, protocol: str = "http") -> str:
                 self.append_line += (
                     f" proxy={self.data['proxy']} http_proxy={self.data['proxy']}"
                 )
-            self.append_line += f" inst.ks={self.data['autoinstall']}"
+            if os_version in ["rhel4", "rhel5", "rhel6", "fedora16"]:
+                self.append_line += " ks=%s" % self.data["autoinstall"]
+            else:
+                self.append_line += " inst.ks=%s" % self.data["autoinstall"]
         elif distro_breed in ["ubuntu", "debian"]:
             self.append_line += (
                 f" auto-install/enable=true url={self.data['autoinstall']}"
@@ -513,7 +522,7 @@ def _generate_netboot_profile(self, profile, cfglines: List[str]):
             )
 
         append_builder = AppendLineBuilder(distro_name=distname, data=data)
-        append_line = append_builder.generate_profile(dist.breed)
+        append_line = append_builder.generate_profile(dist.breed, dist.os_version)
         cfglines.append(append_line)
 
     def generate_netboot_iso(
diff --git a/cobbler/actions/buildiso/standalone.py b/cobbler/actions/buildiso/standalone.py
--- a/cobbler/actions/buildiso/standalone.py
+++ b/cobbler/actions/buildiso/standalone.py
@@ -25,7 +25,10 @@ def _generate_append_line_standalone(data: dict, distro, descendant) -> str:
     """
     append_line = f"  APPEND initrd={os.path.basename(distro.initrd)}"
     if distro.breed == "redhat":
-        append_line += f" inst.ks=cdrom:/isolinux/{descendant.name}.cfg"
+        if distro.os_version in ["rhel4", "rhel5", "rhel6", "fedora16"]:
+            append_line += f" ks=cdrom:/isolinux/{descendant.name}.cfg"
+        else:
+            append_line += f" inst.ks=cdrom:/isolinux/{descendant.name}.cfg"
     elif distro.breed == "suse":
         append_line += (
             f" autoyast=file:///isolinux/{descendant.name}.cfg install=cdrom:///"
diff --git a/cobbler/tftpgen.py b/cobbler/tftpgen.py
--- a/cobbler/tftpgen.py
+++ b/cobbler/tftpgen.py
@@ -1090,8 +1090,10 @@ def build_kernel_options(
 
             if distro.breed is None or distro.breed == "redhat":
 
-                append_line += " inst.kssendmac"
-                append_line = f"{append_line} inst.ks={autoinstall_path}"
+                if distro.os_version in ["rhel4", "rhel5", "rhel6", "fedora16"]:
+                    append_line += " kssendmac ks=%s" % autoinstall_path
+                else:
+                    append_line += " inst.ks.sendmac inst.ks=%s" % autoinstall_path
                 ipxe = blended["enable_ipxe"]
                 if ipxe:
                     append_line = append_line.replace(


Test patch:
diff --git a/tests/actions/buildiso/append_line_test.py b/tests/actions/buildiso/append_line_test.py
--- a/tests/actions/buildiso/append_line_test.py
+++ b/tests/actions/buildiso/append_line_test.py
@@ -31,6 +31,27 @@ def test_generate_system(
     )
 
 
+def test_generate_system_redhat(
+    cobbler_api, create_distro, create_profile, create_system
+):
+    # Arrange
+    test_distro = create_distro()
+    test_distro.breed = "redhat"
+    cobbler_api.add_distro(test_distro)
+    test_profile = create_profile(test_distro.name)
+    test_system = create_system(profile_name=test_profile.name)
+    blendered_data = utils.blender(cobbler_api, False, test_system)
+    test_builder = AppendLineBuilder(test_distro.name, blendered_data)
+
+    # Act
+    result = test_builder.generate_system(test_distro, test_system, False)
+
+    # Assert
+    # Very basic test yes but this is the expected result atm
+    # TODO: Make tests more sophisticated
+    assert result == f"  APPEND initrd={test_distro.name}.img inst.ks=default.ks"
+
+
 def test_generate_profile(request, cobbler_api, create_distro, create_profile):
     # Arrange
     test_distro = create_distro()
@@ -39,7 +60,7 @@ def test_generate_profile(request, cobbler_api, create_distro, create_profile):
     test_builder = AppendLineBuilder(test_distro.name, blendered_data)
 
     # Act
-    result = test_builder.generate_profile("suse")
+    result = test_builder.generate_profile("suse", "opensuse15generic")
 
     # Assert
     # Very basic test yes but this is the expected result atm
@@ -49,3 +70,39 @@ def test_generate_profile(request, cobbler_api, create_distro, create_profile):
         == " append initrd=%s.img install=http://192.168.1.1:80/cblr/links/%s autoyast=default.ks"
         % (request.node.originalname, request.node.originalname)
     )
+
+
+def test_generate_profile_rhel7(cobbler_api, create_distro, create_profile):
+    # Arrange
+    test_distro = create_distro()
+    test_distro.breed = "redhat"
+    cobbler_api.add_distro(test_distro)
+    test_profile = create_profile(test_distro.name)
+    blendered_data = utils.blender(cobbler_api, False, test_profile)
+    test_builder = AppendLineBuilder(test_distro.name, blendered_data)
+
+    # Act
+    result = test_builder.generate_profile("redhat", "rhel7")
+
+    # Assert
+    # Very basic test yes but this is the expected result atm
+    # TODO: Make tests more sophisticated
+    assert result == f" append initrd={test_distro.name}.img inst.ks=default.ks"
+
+
+def test_generate_profile_rhel6(cobbler_api, create_distro, create_profile):
+    # Arrange
+    test_distro = create_distro()
+    test_distro.breed = "redhat"
+    cobbler_api.add_distro(test_distro)
+    test_profile = create_profile(test_distro.name)
+    blendered_data = utils.blender(cobbler_api, False, test_profile)
+    test_builder = AppendLineBuilder(test_distro.name, blendered_data)
+
+    # Act
+    result = test_builder.generate_profile("redhat", "rhel6")
+
+    # Assert
+    # Very basic test yes but this is the expected result atm
+    # TODO: Make tests more sophisticated
+    assert result == f" append initrd={test_distro.name}.img ks=default.ks"