]> Frank Brehm's Git Trees - pixelpark/create-terraform.git/commitdiff
Changing list of allowed puppet environments based on configuration
authorFrank Brehm <frank.brehm@pixelpark.com>
Fri, 3 Sep 2021 09:58:06 +0000 (11:58 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Fri, 3 Sep 2021 09:58:06 +0000 (11:58 +0200)
lib/cr_tf/app.py

index 132cfc18afdb7f3be3ec6ef89247cf79e5655c3b..5ffa6be15205d6eaa66c26b9539f5c1416dd0128 100644 (file)
@@ -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: