]> Frank Brehm's Git Trees - pixelpark/create-terraform.git/commitdiff
Adding possibility to leave project empty
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 12 Dec 2019 12:37:05 +0000 (13:37 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 12 Dec 2019 12:37:05 +0000 (13:37 +0100)
lib/cr_tf/handler.py
lib/cr_tf/terraform/vm.py

index ce2cea28268ebe6204a5aaf2e05831809f6e251c..6ad9df0b523b92d23a6450f19a17703756932704 100644 (file)
@@ -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'
index d794751f9f2c3cb521e3180dd44e9e9e855e2fd4..083bb83191689af1d679bbaed416217f597f2b38 100644 (file)
@@ -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()