From 4f7cd6110a4ec398740a74071ab53358d1222b96 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Fri, 19 Jun 2020 16:14:55 +0200 Subject: [PATCH] Ensuring existence of logrotate files on the webserver. --- lib/cr_vmware_tpl/cobbler.py | 17 ++++++++++++++++- lib/cr_vmware_tpl/handler.py | 3 ++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/cr_vmware_tpl/cobbler.py b/lib/cr_vmware_tpl/cobbler.py index 2349dcc..21e2c14 100644 --- a/lib/cr_vmware_tpl/cobbler.py +++ b/lib/cr_vmware_tpl/cobbler.py @@ -40,7 +40,7 @@ from .config import CrTplConfiguration from .xlate import XLATOR -__version__ = '0.5.10' +__version__ = '0.5.11' LOG = logging.getLogger(__name__) @@ -641,6 +641,21 @@ class Cobbler(BaseHandler): loc=str(local_rc_file), rem=str(remote_rc_file))) self.ensure_remote_file(local_rc_file, remote_rc_file, check_parent=False) + # ------------------------------------------------------------------------- + def ensure_logrotate_files(self): + + files_dir = self.base_dir / 'files' + docroot = self.config.cobbler_ws_docroot / self.config.cobbler_ws_rel_filesdir + remote_dir = docroot / self.config.system_status + + LOG.info(_("Ensuring currentness of logrotate files.")) + + for local_file in files_dir.glob('logrotate*'): + remote_file = remote_dir / local_file.name + LOG.debug(_("Ensuring {loc!r} => {rem!r}.").format( + loc=str(local_file), rem=str(remote_file))) + self.ensure_remote_file(local_file, remote_file, check_parent=False) + # ------------------------------------------------------------------------- def ensure_create_motd(self): diff --git a/lib/cr_vmware_tpl/handler.py b/lib/cr_vmware_tpl/handler.py index 98113ac..3758f94 100644 --- a/lib/cr_vmware_tpl/handler.py +++ b/lib/cr_vmware_tpl/handler.py @@ -42,7 +42,7 @@ from .cobbler import CobblerError, Cobbler from .xlate import XLATOR -__version__ = '1.6.5' +__version__ = '1.6.6' LOG = logging.getLogger(__name__) TZ = pytz.timezone('Europe/Berlin') @@ -236,6 +236,7 @@ class CrTplHandler(BaseHandler): self.cobbler.ensure_bashrc() self.cobbler.ensure_create_motd() self.cobbler.ensure_postfix_files() + self.cobbler.ensure_logrotate_files() self.vsphere.get_about() self.vsphere.get_clusters() -- 2.39.5