From: Frank Brehm Date: Wed, 23 Nov 2022 09:43:04 +0000 (+0100) Subject: Adding switch --no-pdns X-Git-Tag: 1.6.12^2~1 X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=a8082b1c267cde14b1359d108b8b6d40be9be226;p=pixelpark%2Fcreate-terraform.git Adding switch --no-pdns --- diff --git a/lib/cr_tf/app.py b/lib/cr_tf/app.py index cccb6b0..7ddb457 100644 --- a/lib/cr_tf/app.py +++ b/lib/cr_tf/app.py @@ -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: diff --git a/lib/cr_tf/config.py b/lib/cr_tf/config.py index 6722458..2a8702a 100644 --- a/lib/cr_tf/config.py +++ b/lib/cr_tf/config.py @@ -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 diff --git a/lib/cr_tf/handler.py b/lib/cr_tf/handler.py index f2e16f8..6a36f72 100644 --- a/lib/cr_tf/handler.py +++ b/lib/cr_tf/handler.py @@ -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()