]> Frank Brehm's Git Trees - pixelpark/create-terraform.git/commitdiff
Changing creation of terraform files
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 5 Nov 2019 16:57:42 +0000 (17:57 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 5 Nov 2019 16:57:42 +0000 (17:57 +0100)
lib/cr_tf/handler.py

index f42f8ed86b78808624a9b0fa79e9dfe4b8a015f2..8b71d189a804b22f32e83a99e914efb631c20dd1 100644 (file)
@@ -61,7 +61,7 @@ from .terraform.disk import TerraformDisk
 
 from .xlate import XLATOR
 
-__version__ = '3.1.0'
+__version__ = '3.1.1'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -2087,6 +2087,13 @@ class CreateTerraformHandler(BaseHandler):
     # --------------------------------------------------------------------------
     def create_varfiles(self):
 
+        vs_name = str(self.vsphere.keys()[0])
+        vs_host = self.config.vsphere[vs_name].host
+        vs_port = self.config.vsphere[vs_name].port
+        vs_user = self.config.vsphere[vs_name].user
+        vs_pwd = self.config.vsphere[vs_name].password
+        vs_dc = self.config.vsphere[vs_name].dc
+
         content = textwrap.dedent('''\
         ## filename: terraform.tfvars
         ## This file declares the values for the variables to be used in the instance.tf playbook
@@ -2124,9 +2131,7 @@ class CreateTerraformHandler(BaseHandler):
 
         ''')
 
-        content = tpl.format(
-            u=self.config.vsphere_user, p=self.config.vsphere_password,
-            a=self.config.pdns_api_key)
+        content = tpl.format(u=vs_user, p=vs_pwd, a=self.config.pdns_api_key)
 
         LOG.debug(_("Creating {!r} ...").format('private.auto.tfvars'))
         if self.simulate:
@@ -2152,7 +2157,7 @@ class CreateTerraformHandler(BaseHandler):
         }}
 
         ''')
-        content += tpl.format(self.config.vsphere_host)
+        content += tpl.format(vs_host)
 
         tpl = textwrap.dedent('''\
         variable "vsphere_user" {
@@ -2177,20 +2182,7 @@ class CreateTerraformHandler(BaseHandler):
         }}
 
         ''')
-        content += tpl.format(dc=self.config.vsphere_dc)
-
-#        i = 0
-#        for cluster in self.vsphere.clusters:
-#            i += 1
-#            tpl = textwrap.dedent('''\
-#            variable "{v}" {{
-#                default     = "{cl}"
-#                description = "Name of the vSphere host cluster {i} to use."
-#                type        = "string"
-#            }}
-#
-#            ''')
-#            content += tpl.format(v=cluster.var_name, cl=cluster.name, i=i)
+        content += tpl.format(dc=vs_dc)
 
         tpl = textwrap.dedent('''\
         variable "timezone" {{