From: Frank Brehm Date: Mon, 23 Jan 2023 17:41:07 +0000 (+0100) Subject: Minor changes on generating and ensuring authorized keys for root X-Git-Tag: 2.7.3~1^2~1 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=cdba9c432d65dc089e9da769f3bc1eee2a1d6d8d;p=pixelpark%2Fcreate-vmware-tpl.git Minor changes on generating and ensuring authorized keys for root --- diff --git a/lib/cr_vmware_tpl/cobbler.py b/lib/cr_vmware_tpl/cobbler.py index be91bf7..38c64c4 100644 --- a/lib/cr_vmware_tpl/cobbler.py +++ b/lib/cr_vmware_tpl/cobbler.py @@ -45,7 +45,7 @@ from .config import CrTplConfiguration from .xlate import XLATOR -__version__ = '0.9.1' +__version__ = '0.9.2' LOG = logging.getLogger(__name__) @@ -436,10 +436,9 @@ class Cobbler(BaseHandler): if check_parent: self.check_remote_directory(remote_file.parent) - if self.verbose > 1: - msg = _("Checking remote file {rfile!r} based on local {lfile!r} ...").format( - rfile=str(remote_file), lfile=str(local_file)) - LOG.debug(msg) + msg = _("Checking remote file {rfile!r} based on local {lfile!r} ...").format( + rfile=str(remote_file), lfile=str(local_file)) + LOG.debug(msg) if not local_file.exists() or not local_file.is_file(): msg = _("Local file {!r} either not exists or is not a regular file.").format( diff --git a/lib/cr_vmware_tpl/handler.py b/lib/cr_vmware_tpl/handler.py index c819486..2b38635 100644 --- a/lib/cr_vmware_tpl/handler.py +++ b/lib/cr_vmware_tpl/handler.py @@ -54,7 +54,7 @@ from .cobbler import Cobbler from .xlate import XLATOR -__version__ = '2.3.1' +__version__ = '2.3.2' LOG = logging.getLogger(__name__) TZ = pytz.timezone('Europe/Berlin') @@ -354,7 +354,7 @@ class CrTplHandler(BaseHandler): self.create_root_authkeys() self.cobbler.ensure_profile() self.cobbler.ensure_webroot() - self.cobbler.ensure_root_authkeys(self.auth_keys_file) + # self.cobbler.ensure_root_authkeys(self.auth_keys_file) self.cobbler.ensure_rsyslog_cfg_files() self.cobbler.ensure_snippets() @@ -1307,6 +1307,8 @@ class CrTplHandler(BaseHandler): LOG.info(_("Creating authorized keys of root from LDAP ...")) + print_section_start( + 'create_root_authkeys', "Generating authorized_keys of root.", collapsed=True) prefix = 'tmp.authorized_keys.root.' (fh, tmp_keys_file) = tempfile.mkstemp(prefix=prefix, text=True) self.auth_keys_file = Path(tmp_keys_file) @@ -1334,14 +1336,14 @@ class CrTplHandler(BaseHandler): auth_keys += used_key + '\n' auth_keys += line - if self.verbose > 2: - msg = _("Generated authorized keys for root:") + '\n' + auth_keys - LOG.debug(msg) + msg = _("Generated authorized keys for root:") + '\n' + auth_keys + LOG.debug(msg) finally: self.disconnect_ldap() self.auth_keys_file.write_text(auth_keys) + print_section_end('create_root_authkeys') # ------------------------------------------------------------------------- def get_ldap_admins(self): @@ -1359,10 +1361,9 @@ class CrTplHandler(BaseHandler): msg = _("Trying to get a list of all DPX admins with their public SSH keys ...") LOG.debug(msg) - if self.verbose > 1: - msg = _("LDAP search starting in {!r} with filter:").format(ldap_config.base_dn) - msg += '\n' + fltr - LOG.debug(msg) + msg = _("LDAP search starting in {!r} with filter:").format(ldap_config.base_dn) + msg += '\n' + fltr + LOG.debug(msg) status, result, response, request = self.ldap.search( search_base=ldap_config.base_dn, search_scope=ldap3.SUBTREE, search_filter=fltr,