]> Frank Brehm's Git Trees - pixelpark/create-terraform.git/commitdiff
Adding switch --no-pdns
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 23 Nov 2022 09:43:04 +0000 (10:43 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 23 Nov 2022 09:43:04 +0000 (10:43 +0100)
lib/cr_tf/app.py
lib/cr_tf/config.py
lib/cr_tf/handler.py

index cccb6b0efe758d08fb2960a6254325516db91e42..7ddb4579d94c58abcdc15520a5e0ab79f5706c7a 100644 (file)
@@ -47,7 +47,7 @@ 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.2.1'
+__version__ = '1.3.1'
 LOG = logging.getLogger(__name__)
 
 SIGNAL_NAMES = {
@@ -411,6 +411,13 @@ class CrTfApplication(BaseApplication):
         # PowerDNS options
         pdns_group = self.arg_parser.add_argument_group(_('PowerDNS options'))
 
+        pdns_group.add_argument(
+            '--no-pdns', action="store_true", dest='no_pdns',
+            help=_(
+                "Don't execute any PowerDNS checks or actions. In this case it's on yours "
+                "to ensure existence of all necessary IP addresses.")
+        )
+
         pdns_group.add_argument(
             '-M', '--pdns-master', metavar=_("HOST"), dest='pdns_master',
             help=_(
@@ -470,6 +477,8 @@ class CrTfApplication(BaseApplication):
     # -------------------------------------------------------------------------
     def perform_arg_parser_pdns(self):
 
+        if self.args.no_pdns:
+            self.config.no_pdns = True
         if self.args.pdns_master:
             self.config.pdns_master_server = self.args.pdns_master
         if self.args.pdns_api_port:
index 67224588add00b0fe358be3be2ab70fbc54af18c..2a8702ab4932e7c026bbf46e3530064709fc0729 100644 (file)
@@ -32,7 +32,7 @@ from .errors import CrTfConfigError
 
 from .xlate import XLATOR
 
-__version__ = '1.5.3'
+__version__ = '1.6.1'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -505,6 +505,8 @@ class CrTfConfiguration(BaseConfiguration):
         self.puppetca = self.default_puppetca
         self.pdns_comment_account = self.default_pdns_comment_account
 
+        self._no_pdns = False
+
         self.puppet_envs_add = set()
         self.puppet_envs_delete = set()
 
@@ -545,6 +547,16 @@ class CrTfConfiguration(BaseConfiguration):
     def simulate(self, value):
         self._simulate = to_bool(value)
 
+    # -----------------------------------------------------------
+    @property
+    def no_pdns(self):
+        """Don't execute some PowerDNS actions or checks."""
+        return self._no_pdns
+
+    @no_pdns.setter
+    def no_pdns(self, value):
+        self._no_pdns = to_bool(value)
+
     # -----------------------------------------------------------
     @property
     def pdns_api_key(self):
@@ -737,6 +749,7 @@ class CrTfConfiguration(BaseConfiguration):
         res = super(CrTfConfiguration, self).as_dict(short=short)
 
         res['simulate'] = self.simulate
+        res['no_pdns'] = self.no_pdns
         res['pdns_api_use_https'] = self.pdns_api_use_https
         res['pdns_api_timeout'] = self.pdns_api_timeout
         res['vm_root_password'] = None
index f2e16f802017227421adab95611badb59632a774..6a36f72569c6a63695ce29bd56fa8e6528ed07e2 100644 (file)
@@ -64,7 +64,7 @@ from .terraform.disk import TerraformDisk
 
 from .xlate import XLATOR
 
-__version__ = '3.7.3'
+__version__ = '3.8.1'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -427,11 +427,12 @@ class CreateTerraformHandler(BaseHandler):
             simulate=self.simulate, force=self.force, initialized=True,
         )
 
-        try:
-            api_version = self.pdns.get_api_server_version()            # noqa
-        except (PowerDNSHandlerError, ConnectionError) as e:
-            msg = "{c}: {e}".format(c=e.__class__.__name__, e=str(e))
-            raise ExpectedHandlerError(msg)
+        if not self.config.no_pdns:
+            try:
+                api_version = self.pdns.get_api_server_version()            # noqa
+            except (PowerDNSHandlerError, ConnectionError) as e:
+                msg = "{c}: {e}".format(c=e.__class__.__name__, e=str(e))
+                raise ExpectedHandlerError(msg)
 
     # -------------------------------------------------------------------------
     def check_terraform_version(self):
@@ -703,6 +704,9 @@ class CreateTerraformHandler(BaseHandler):
     # -------------------------------------------------------------------------ยท
     def exec_pdns_zones(self):
 
+        if self.config.no_pdns:
+            return
+
         if self.stop_at_step == 'pdns-zones':
             self.incr_verbosity()
 
@@ -2015,6 +2019,10 @@ class CreateTerraformHandler(BaseHandler):
     # --------------------------------------------------------------------------
     def perform_dns(self):
 
+        if self.config.no_pdns:
+            LOG.debug(_("Power DNS actions are not eceuted."))
+            return
+
         print()
         LOG.info(_("Performing DNS actions ..."))
         print()