From: Frank Brehm Date: Fri, 3 Sep 2021 09:58:06 +0000 (+0200) Subject: Changing list of allowed puppet environments based on configuration X-Git-Tag: 1.5.2^2~40 X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=8f8c4139f54e842eff81471371f0f09d6d09aba2;p=pixelpark%2Fcreate-terraform.git Changing list of allowed puppet environments based on configuration --- diff --git a/lib/cr_tf/app.py b/lib/cr_tf/app.py index 132cfc1..5ffa6be 100644 --- a/lib/cr_tf/app.py +++ b/lib/cr_tf/app.py @@ -38,12 +38,14 @@ from .config import CrTfConfiguration from .handler import CreateTerraformHandler +from .terraform.vm import TerraformVm + from .xlate import __module_dir__ as __xlate_module_dir__ from .xlate import __base_dir__ as __xlate_base_dir__ from .xlate import __mo_file__ as __xlate_mo_file__ from .xlate import XLATOR, LOCALE_DIR, DOMAIN -__version__ = '1.1.0' +__version__ = '1.1.1' LOG = logging.getLogger(__name__) SIGNAL_NAMES = { @@ -245,6 +247,26 @@ class CrTfApplication(BaseApplication): if self.verbose > 3: LOG.debug(_("Read configuration:") + '\n' + pp(self.config.as_dict())) + if self.config.puppet_envs_delete: + LOG.debug(_("Removing allowed puppet environments ...")) + for env in self.puppet_envs_delete.puppet_envs_add: + if env in TerraformVm.valid_puppet_environments: + if self.verbose > 1: + LOG.debug(_("Removing puppet environment {!r} ...").format(env)) + TerraformVm.valid_puppet_environments.remove(env) + + TerraformVm.valid_puppet_environments.sort() + LOG.debug( + _("Allowed puppet environments:") + ' ' + pp(TerraformVm.valid_puppet_environments)) + + if self.config.puppet_envs_add: + LOG.debug(_("Adding allowed puppet environments ...")) + for env in self.config.puppet_envs_add: + if env not in TerraformVm.valid_puppet_environments: + if self.verbose > 1: + LOG.debug(_("Adding puppet environment {!r} ...").format(env)) + TerraformVm.valid_puppet_environments.append(env) + self.perform_arg_parser_rest() if not self.config.pdns_api_key: