From: Frank Brehm Date: Tue, 5 Nov 2019 16:57:42 +0000 (+0100) Subject: Changing creation of terraform files X-Git-Tag: 1.3.4~10 X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=7302a4215cfaeb13b053648fa65dd3c4183ab612;p=pixelpark%2Fcreate-terraform.git Changing creation of terraform files --- diff --git a/lib/cr_tf/handler.py b/lib/cr_tf/handler.py index f42f8ed..8b71d18 100644 --- a/lib/cr_tf/handler.py +++ b/lib/cr_tf/handler.py @@ -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" {{