]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Ensuring authorized_keys for root on the webserver.
authorFrank Brehm <frank.brehm@pixelpark.com>
Fri, 29 May 2020 12:12:57 +0000 (14:12 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Fri, 29 May 2020 12:12:57 +0000 (14:12 +0200)
lib/cr_vmware_tpl/cobbler.py
lib/cr_vmware_tpl/config.py
lib/cr_vmware_tpl/handler.py

index fd9abfe685369a7c84f45c03e00321a27b13d2c0..efbe9f9a76fdea704fa124ce3148a94b9cefba74 100644 (file)
@@ -349,6 +349,15 @@ class Cobbler(BaseHandler):
 
         self.scp_to(local_file, remote_file)
 
+    # -------------------------------------------------------------------------
+    def ensure_root_authkeys(self):
+
+        bname = 'auth_keys_pp_betrieb'
+        local_file = self.base_dir / 'keys' / bname
+        remote_file = self.config.cobbler_ws_docroot / self.config.cobbler_ws_rel_filesdir / bname
+
+        self.ensure_remote_file(local_file, remote_file)
+
     # -------------------------------------------------------------------------
     def ensure_profile_ks(self):
 
index 9e20716a5d356c2b09d750505a5d3da6a5ad6c75..12aab8fe29853821bbba9c5e096d5346eded8893 100644 (file)
@@ -21,7 +21,7 @@ from fb_tools.config import ConfigError, BaseConfiguration
 
 from .xlate import XLATOR
 
-__version__ = '1.4.3'
+__version__ = '1.5.0'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -90,6 +90,9 @@ class CrTplConfiguration(BaseConfiguration):
         'pixelpark.com',
         'pixelpark.de',
     ]
+    default_cobbler_ws_base_url = 'http://cobbler.pixelpark.com'
+    default_cobbler_ws_docroot = Path('/var/www/html')
+    default_cobbler_ws_rel_filesdir = Path('custom/vmware-template-files')
 
     ssh_privkey = 'id_rsa_cr_vmw_tpl'
 
@@ -143,6 +146,9 @@ class CrTplConfiguration(BaseConfiguration):
         self.cobbler_profile_repos = copy.copy(self.default_cobbler_profile_repos)
         self.cobbler_nameservers = copy.copy(self.default_cobbler_nameservers)
         self.cobbler_dns_search = copy.copy(self.default_cobbler_dns_search)
+        self.cobbler_ws_base_url = self.default_cobbler_ws_base_url
+        self.cobbler_ws_docroot = self.default_cobbler_ws_docroot
+        self.cobbler_ws_rel_filesdir = self.default_cobbler_ws_rel_filesdir
 
         self.excluded_datastores = []
 
@@ -466,6 +472,12 @@ class CrTplConfiguration(BaseConfiguration):
         re_pr_repos_key = re.compile(r'^\s*profile[-_]?repos?\s*$', re.IGNORECASE)
         re_nameserver_key = re.compile(r'^\s*nameservers?\s*$', re.IGNORECASE)
         re_dns_search_key = re.compile(r'^\s*dns[-_]?search\s*$', re.IGNORECASE)
+        re_ws_base_url_key = re.compile(
+            r'^\s*(?:ws|webserver)[-_]?base[-_]?url\s*$', re.IGNORECASE)
+        re_ws_docroot_key = re.compile(
+            r'^\s*(?:ws|webserver)[-_]?docroot\s*$', re.IGNORECASE)
+        re_ws_rel_filesdir_key = re.compile(
+            r'^\s*(?:ws|webserver)[-_]?rel(?:ative)?[-_]?filesdir\s*$', re.IGNORECASE)
 
         for (key, value) in config.items(section_name):
             if key.lower() == 'distro' and value.strip() != '':
@@ -488,8 +500,8 @@ class CrTplConfiguration(BaseConfiguration):
                 if dpath.is_absolute():
                     self.cobbler_rootdir = Path(value)
                 else:
-                    msg = _("Path for Cobbler root directory {!r} is not absolute.").format(
-                        str(dpath))
+                    msg = _("Path for {what} {path!r} is not absolute.").format(
+                        what=_("Cobbler root directory"), path=str(dpath))
                     LOG.error(msg)
                 continue
             if key.lower() == 'profile' and value.strip() != '':
@@ -505,7 +517,20 @@ class CrTplConfiguration(BaseConfiguration):
             if re_dns_search_key.match(key) and value.strip() != '':
                 self.cobbler_dns_search = re_split_values.split(value.strip().lower())
                 continue
-
+            if re_ws_base_url_key.match(key) and value.strip() != '':
+                self.cobbler_ws_base_url = value.strip().lower()
+                continue
+            if re_ws_docroot_key.match(key) and value.strip() != '':
+                dpath = Path(value.strip())
+                if dpath.is_absolute():
+                    self.cobbler_ws_docroot = dpath
+                else:
+                    msg = _("Path for {what} {path!r} is not absolute.").format(
+                        what=_("Webserver document root"), path=str(dpath))
+                    LOG.error(msg)
+                continue
+            if re_ws_rel_filesdir_key.match(key) and value.strip() != '':
+                self.cobbler_ws_rel_filesdir = Path(value.strip())
 
 # =============================================================================
 if __name__ == "__main__":
index 665f5eac004928d0daf76d06756ffc1a1a3b6935..015bdb2c1174c1faed5c220f71282ba26e5a07a8 100644 (file)
@@ -40,7 +40,7 @@ from .cobbler import CobblerError, Cobbler
 
 from .xlate import XLATOR
 
-__version__ = '1.4.5'
+__version__ = '1.4.6'
 
 LOG = logging.getLogger(__name__)
 TZ = pytz.timezone('Europe/Berlin')
@@ -175,6 +175,7 @@ class CrTplHandler(BaseHandler):
         self.cobbler.get_cobbler_version()
         self.check_for_cobbler_distro()
         self.cobbler.ensure_profile()
+        self.cobbler.ensure_root_authkeys()
 
         return 0