]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
First generating of kickstart file
authorFrank Brehm <frank@brehm-online.com>
Fri, 24 Jun 2022 11:20:51 +0000 (13:20 +0200)
committerFrank Brehm <frank@brehm-online.com>
Fri, 24 Jun 2022 11:20:51 +0000 (13:20 +0200)
etc/cobbler-distros.yaml.default
lib/cr_vmware_tpl/cobbler.py
lib/cr_vmware_tpl/config.py
requirements.txt

index 52be71a5571e38d41e34414cc0d89828a58c9848..60bc9845b0c4358cb506ac72b53d832e17c65c94 100644 (file)
@@ -4,6 +4,7 @@ cobbler-distros:
     distro: 'AlmaLinux-8.6-x86_64'
     description: 'AlmaLinux 8 x86_64'
     shortname: 'alma8'
+    ks_repo_url: 'https://repo02.pixelpark.com/Linux/yum/almalinux/8/BaseOS/x86_64/os'
     repos:
       - 'almalinux-8-x86_64-baseos'
       - 'almalinux-8-x86_64-appstream'
@@ -20,6 +21,7 @@ cobbler-distros:
     distro: 'CentOS-7.9-x86_64'
     description: 'CentOS 7 x86_64'
     shortname: 'centos7'
+    ks_repo_url: 'https://repo02.pixelpark.com/Linux/yum/centos/8/os/x86_64'
     repos:
       - 'centos-7-x86_64-baseos'
       - 'centos-7-x86_64-extras'
@@ -34,6 +36,7 @@ cobbler-distros:
     distro: 'CentOS-Stream-8-x86_64'
     description: 'CentOS Stream 8 x86_64'
     shortname: 'centos8'
+    ks_repo_url: 'https://repo02.pixelpark.com/Linux/yum/centos/8-stream/BaseOS/x86_64/os'
     repos:
       - 'centos-stream-8-x86_64-baseos'
       - 'centos-stream-8-x86_64-appstream'
@@ -50,6 +53,7 @@ cobbler-distros:
     distro: 'Oracle-Linux-7.9-x86_64'
     description: 'Oracle Enterprise Linux 7 x86_64'
     shortname: 'oel7'
+    ks_repo_url: 'https://repo02.pixelpark.com/Linux/yum/OracleLinux/OL7/ol7_latest'
     repos:
       - 'oraclelinux-7-x86_64-addons'
       - 'oraclelinux-7-x86_64-latest'
@@ -66,6 +70,7 @@ cobbler-distros:
     distro: 'Rocky-8.6-x86_64'
     description: 'Rocky Linux 8 x86_64'
     shortname: 'rocky8'
+    ks_repo_url: 'https://repo02.pixelpark.com/Linux/yum/rockylinux/8/BaseOS/x86_64/os'
     repos:
       - 'rocky-8-x86_64-baseos'
       - 'rocky-8-x86_64-appstream'
index 7f9294ee158f73fcb0bae730767fc042d354e405..52446441e19c528e4740eaac01c821eb4b0f0ef5 100644 (file)
@@ -28,6 +28,8 @@ from paramiko.ssh_exception import SSHException
 
 from packaging.version import Version
 
+import jinja2
+
 # Own modules
 
 from fb_tools.common import pp, to_str, is_sequence
@@ -679,6 +681,16 @@ class Cobbler(BaseHandler):
         remote_ks = self.cfg.system_ks
         LOG.info(_("Ensuring currentness of system kickstart script {!r}.").format(
             str(remote_ks)))
+
+        jinja_env = jinja2.Environment(
+            loader=jinja2.FileSystemLoader(str(self.base_dir / 'templates')),
+            autoescape=jinja2.select_autoescape(),
+        )
+        ks_template = jinja_env.get_template('el-standard.ks')
+        ks_content = ks_template.render(distro=self.cfg.current_distro)
+        if self.verbose > 1:
+            LOG.debug(_("Generated kickstart file content:") + '\n' + ks_content)
+
         return
         print_section_start(
             'ensure_system_ks', 'Ensuring currentness of system kickstart script', collapsed=True)
index 8a308f64b2624b778b1198622234681621260299..68b54e316f6fb68e70d92412db748c5dc2e1b64a 100644 (file)
@@ -58,13 +58,14 @@ class CobblerDistroInfo(FbGenericBaseObject):
     # -------------------------------------------------------------------------
     def __init__(
             self, name, shortname=None, distro=None, description=None, arch=DEFAULT_DISTRO_ARCH,
-            repos=None, snippets=None):
+            ks_repo_url=None, repos=None, snippets=None):
 
         self._name = None
         self._shortname = None
         self._distro = None
         self._description = None
         self._arch = DEFAULT_DISTRO_ARCH
+        self._ks_repo_url = None
         self.repos = CIStringSet()
         self.snippets = CIStringSet()
 
@@ -184,6 +185,25 @@ class CobblerDistroInfo(FbGenericBaseObject):
 
         self._description = desc
 
+    # -------------------------------------------------------------------------
+    @property
+    def ks_repo_url(self):
+        """The URL for the base installation repository."""
+        return getattr(self, '_ks_repo_url', None)
+
+    @ks_repo_url.setter
+    def ks_repo_url(self, value):
+        if value is None:
+            self._ks_repo_url = None
+            return
+
+        ks_repo_url = value.strip()
+        if ks_repo_url == '':
+            self._ks_repo_url = None
+            return
+
+        self._ks_repo_url = ks_repo_url
+
     # -------------------------------------------------------------------------
     def __repr__(self):
         """Typecasting into a string for reproduction."""
@@ -196,6 +216,7 @@ class CobblerDistroInfo(FbGenericBaseObject):
         fields.append("distro={!r}".format(self.distro))
         fields.append("arch={!r}".format(self.arch))
         fields.append("description={!r}".format(self.description))
+        fields.append("ks_repo_url={!r}".format(self.ks_repo_url))
 
         out += ", ".join(fields) + ")>"
 
@@ -220,6 +241,7 @@ class CobblerDistroInfo(FbGenericBaseObject):
         res['distro'] = self.distro
         res['arch'] = self.arch
         res['description'] = self.description
+        res['ks_repo_url'] = self.ks_repo_url
 
         return res
 
@@ -236,7 +258,7 @@ class CobblerDistroInfo(FbGenericBaseObject):
 
         new = self.__class__(
             self.name, shortname=self.shortname, distro=self.distro, arch=arch,
-            description=self.description)
+            ks_repo_url=self.ks_repo_url, description=self.description)
 
         for repo in self.repos:
             new.repos.add(repo)
@@ -256,19 +278,23 @@ class CobblerDistroInfo(FbGenericBaseObject):
             value = data[key]
 
             if key.lower() == 'shortname' and value.strip() != '':
-                new.shortname = value
+                new.shortname = value.strip()
                 continue
 
             if key.lower() == 'distro' and value.strip() != '':
-                new.distro = value
+                new.distro = value.strip()
                 continue
 
             if key.lower() == 'description' and value.strip() != '':
-                new.description = value
+                new.description = value.strip()
                 continue
 
             if key.lower() == 'arch' and value.strip() != '':
-                new.arch = value
+                new.arch = value.strip()
+                continue
+
+            if key.lower() == 'ks_repo_url' and value.strip() != '':
+                new.ks_repo_url = value.strip()
                 continue
 
             if key.lower() == 'repos':
@@ -651,6 +677,12 @@ class CrTplConfiguration(BaseMultiConfig):
                     distro_id)
                 raise CrTplConfigError(msg)
 
+            if not distro.ks_repo_url:
+                msg = _(
+                    "Did not found the base install repo URL of configured Cobbler "
+                    "distro {!r}.").format( distro_id)
+                raise CrTplConfigError(msg)
+
             if not len(distro.repos):
                 msg = _(
                     "Did not found repo definitions for configured Cobbler "
index d6c11a3b4e5b80c78469be004fd7a247a2060f81..dda7db9f95f882e940d4d4d24ad060ab518b379a 100644 (file)
@@ -7,6 +7,7 @@ Babel
 PyYAML
 toml
 hjson
+jinja2
 fb_logging
 fb_tools
 fb_vmware