From 479a3600ea1888a97e0315edcedbd62a58851ae9 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Thu, 12 Dec 2019 13:37:05 +0100 Subject: [PATCH] Adding possibility to leave project empty --- lib/cr_tf/handler.py | 16 +++++++++------- lib/cr_tf/terraform/vm.py | 7 ++++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/cr_tf/handler.py b/lib/cr_tf/handler.py index ce2cea2..6ad9df0 100644 --- a/lib/cr_tf/handler.py +++ b/lib/cr_tf/handler.py @@ -60,7 +60,7 @@ from .terraform.disk import TerraformDisk from .xlate import XLATOR -__version__ = '3.2.1' +__version__ = '3.2.2' LOG = logging.getLogger(__name__) _ = XLATOR.gettext @@ -2646,12 +2646,14 @@ class CreateTerraformHandler(BaseHandler): # ## Configuring and starting puppet if vm.has_puppet: commands.append("chmod +x /tmp/init-puppet") - commands.append(( - "/tmp/init-puppet --environment '{e}' --customer '{c}' --project '{pr}' " - "--role '{r}' --owner '{o}' --tier '{t}' --purpose '{p} ({t})' " - "--email '{m}'").format( - p=purpose, t=vm.puppet_tier, o=vm.customer, c=vm.puppet_customer, - pr=vm.puppet_project, m=vm.puppet_contact, e=vm.puppet_env, r=vm.puppet_role)) + cmd = "/tmp/init-puppet --environment '{e}' --customer '{c}' " + if vm.puppet_project: + cmd += "--project '{pr}' " + cmd += "--role '{r}' --owner '{o}' --tier '{t}' --purpose '{p} ({t})' --email '{m}'" + cmd = cmd.format( + p=purpose, t=vm.puppet_tier, o=vm.customer, c=vm.puppet_customer, + pr=vm.puppet_project, m=vm.puppet_contact, e=vm.puppet_env, r=vm.puppet_role) + commands.append(cmd) commands.append("rm -f /tmp/init-puppet") content += ' provisioner "remote-exec" {\n' diff --git a/lib/cr_tf/terraform/vm.py b/lib/cr_tf/terraform/vm.py index d794751..083bb83 100644 --- a/lib/cr_tf/terraform/vm.py +++ b/lib/cr_tf/terraform/vm.py @@ -37,7 +37,7 @@ from .disk import TerraformDisk, TerraformDiskDict from .interface import TerraformInterface -__version__ = '1.4.4' +__version__ = '1.4.5' LOG = logging.getLogger(__name__) @@ -159,7 +159,7 @@ class TerraformVm(HandlingObject): self._purpose = self.default_purpose self._puppet_contact = self.default_puppet_contact self._puppet_customer = self.default_puppet_customer - self._puppet_project = self.default_puppet_customer + self._puppet_project = None self._puppet_tier = self.default_puppet_tier self._puppet_env = None self._puppet_role = self.default_puppet_role @@ -1005,7 +1005,8 @@ class TerraformVm(HandlingObject): @puppet_project.setter def puppet_project(self, value): if value is None: - LOG.warn(_("A puppet hiera project name may not be None.")) + LOG.warn(_("A puppet hiera project name should not be None.")) + self._puppet_project = None return val = str(value).strip().lower() -- 2.39.5