From 8f3170f00bdd85698cd41baef6a7a521f809fad2 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 25 Sep 2019 16:02:44 +0200 Subject: [PATCH] Checking for existence of directory of postinstall scripts. --- etc/create-terraform.ini.default | 2 +- lib/cr_tf/__init__.py | 2 +- lib/cr_tf/app.py | 2 +- lib/cr_tf/handler.py | 11 ++++++++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/etc/create-terraform.ini.default b/etc/create-terraform.ini.default index 6bf4f38..755c7e9 100644 --- a/etc/create-terraform.ini.default +++ b/etc/create-terraform.ini.default @@ -12,7 +12,7 @@ ;time_zone = Europe/Berlin ; Puppetmaster - wird bei 'terraform destroy' verwendet -;puppet_master = puppetmaster01.pixelpark.com +;puppet_master = puppetmaster04.pixelpark.com ; Puppetca-Host wird für die Registrierung neu installierter Maschinen bei Puppet ; während 'terraform apply' verwendet diff --git a/lib/cr_tf/__init__.py b/lib/cr_tf/__init__.py index 5906457..3c038de 100644 --- a/lib/cr_tf/__init__.py +++ b/lib/cr_tf/__init__.py @@ -1,7 +1,7 @@ #!/bin/env python3 # -*- coding: utf-8 -*- -__version__ = '1.3.2' +__version__ = '1.3.3' MIN_VERSION_TERRAFORM = '0.12.0' MAX_VERSION_TERRAFORM = '0.12.99' diff --git a/lib/cr_tf/app.py b/lib/cr_tf/app.py index eccc00f..2425e17 100644 --- a/lib/cr_tf/app.py +++ b/lib/cr_tf/app.py @@ -221,7 +221,7 @@ class CrTfApplication(BaseApplication): cfg_file_rel = os.path.relpath(str(self.cfg_file), str(cur_dir)) default_cfg_file_rel = os.path.relpath(str(default_conf_file), str(cur_dir)) msg = (_( - "Configuration file {f!r} does not exists. Please copy {d!r} to {f!r} and " + "Configuration file {f!r} does not exists.\nPlease copy {d!r} to {f!r} and " "fill out all necessary entries, e.g. the passwords and API keys.").format( f=cfg_file_rel, d=default_cfg_file_rel)) LOG.error(msg) diff --git a/lib/cr_tf/handler.py b/lib/cr_tf/handler.py index 11bdd3f..e378993 100644 --- a/lib/cr_tf/handler.py +++ b/lib/cr_tf/handler.py @@ -59,7 +59,7 @@ from .terraform.disk import TerraformDisk from .xlate import XLATOR -__version__ = '2.8.8' +__version__ = '2.8.9' LOG = logging.getLogger(__name__) _ = XLATOR.gettext @@ -216,6 +216,15 @@ class CreateTerraformHandler(BaseHandler): self.config = config self.script_dir = self.base_dir.joinpath('postinstall-scripts') + LOG.debug(_("Directory for postinstall scripts: {!r}").format(str(self.script_dir))) + if not self.script_dir.exists(): + msg = _("Directory for postinstall scripts {!r} does not exists.").format( + str(self.script_dir)) + raise ExpectedHandlerError(msg) + if not self.script_dir.is_dir(): + msg = _("Path {!r} for postinstall scripts exists, but is not a directory.").format( + str(self.script_dir)) + raise ExpectedHandlerError(msg) if initialized: self.initialized = True -- 2.39.5