From: Frank Brehm Date: Tue, 19 Jul 2022 11:52:50 +0000 (+0200) Subject: Defining VM property puppet_initial_install X-Git-Tag: 1.6.8~2^2~4 X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=0100cda484497ea3b36d03d251f63f306c38e6ab;p=pixelpark%2Fcreate-terraform.git Defining VM property puppet_initial_install --- diff --git a/lib/cr_tf/terraform/vm.py b/lib/cr_tf/terraform/vm.py index d204155..efb831a 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.5.8' +__version__ = '1.6.0' LOG = logging.getLogger(__name__) @@ -119,7 +119,10 @@ class TerraformVm(HandlingObject): re_key_puppet_tier = re.compile(r'^\s*puppet[_-]?tier\s*$', re.IGNORECASE) re_key_puppet_env = re.compile(r'^\s*puppet[_-]?env(?:ironment)?\s*$', re.IGNORECASE) re_key_puppet_role = re.compile(r'^\s*puppet[_-]?role\s*$', re.IGNORECASE) + re_key_puppet_initial_install = re.compile( + r'^\s*puppet[_-]?initial[_-]?install\s*$', re.IGNORECASE) re_key_env = re.compile(r'^\s*env(?:ironment)?\s*$', re.IGNORECASE) + re_key_initial_install = re.compile(r'^\s*initial[_-]?install\s*$', re.IGNORECASE) re_key_ns = re.compile(r'^\s*nameservers?\s*$', re.IGNORECASE) re_key_searchdomain = re.compile(r'^\s*search[_-]*domains?\s*$', re.IGNORECASE) re_key_dnsoptions = re.compile(r'^\s*(dns|resolv)[_-]*options?\s*$', re.IGNORECASE) @@ -151,8 +154,9 @@ class TerraformVm(HandlingObject): cluster=None, boot_delay=None, ds_cluster=None, datastore=None, ds_type=None, customer=None, rootdisk_size=None, purpose=None, puppet_contact=None, puppet_role=None, puppet_customer=None, puppet_project=None, puppet_tier=None, puppet_env=None, - vm_template=None, nameservers=None, searchdomains=None, dns_options=None, - has_backup=True, has_puppet=True, already_existing=None, vsphere=None): + puppet_initial_install=False, vm_template=None, nameservers=None, searchdomains=None, + dns_options=None, has_backup=True, has_puppet=True, already_existing=None, + vsphere=None): self._vsphere = self.default_vsphere self._is_template = bool(is_template) @@ -175,6 +179,7 @@ class TerraformVm(HandlingObject): self._puppet_tier = self.default_puppet_tier self._puppet_env = None self._puppet_role = self.default_puppet_role + self._puppet_initial_install = bool(puppet_initial_install) self._vm_template = None self._has_backup = bool(has_backup) self._has_puppet = bool(has_puppet) @@ -197,6 +202,7 @@ class TerraformVm(HandlingObject): name=name, fqdn=fqdn, num_cpus=num_cpus, memory=memory, folder=folder, boot_delay=boot_delay, vm_template=vm_template, puppet_contact=puppet_contact, puppet_customer=puppet_customer, puppet_tier=puppet_tier, puppet_env=puppet_env, + puppet_initial_install=puppet_initial_install, cluster=cluster, rootdisk_size=rootdisk_size, nameservers=nameservers, searchdomains=searchdomains, dns_options=dns_options, purpose=purpose, customer=customer, ds_cluster=ds_cluster, datastore=datastore, ds_type=ds_type, @@ -516,6 +522,10 @@ class TerraformVm(HandlingObject): vm.puppet_role = val_stripped return True + if cls.re_key_puppet_initial_install.search(key) and val_stripped: + vm.puppet_initial_install = val_stripped + return True + if cls.re_key_puppet_tier.search(key) and val_stripped: if cls.re_invalid_chars.search(val_stripped): LOG.error(_("Invalid puppet tier {!r}.").format(value)) @@ -571,6 +581,10 @@ class TerraformVm(HandlingObject): vm.puppet_role = p_value_stripped return + if cls.re_key_initial_install.search(key) and val_stripped: + vm.puppet_initial_install = val_stripped + return True + if p_key.lower() == 'tier' and p_value_stripped: if cls.re_invalid_chars.search(p_value_stripped): LOG.error(_("Invalid puppet tier {!r}.").format(p_value)) @@ -617,7 +631,7 @@ class TerraformVm(HandlingObject): searchdomains=self.searchdomains, dns_options=self.dns_options, rootdisk_size=self.rootdisk_size, has_backup=self.has_backup, has_puppet=self.has_puppet, puppet_project=self.puppet_project, - vsphere=self.vsphere, + puppet_initial_install=self.puppet_initial_install, vsphere=self.vsphere, ) vm.disks = copy.copy(self.disks) @@ -687,6 +701,16 @@ class TerraformVm(HandlingObject): def is_template(self, value): self._is_template = bool(value) + # ----------------------------------------------------------- + @property + def puppet_initial_install(self): + """Set the initial_install flag for Puppet.""" + return self._puppet_initial_install + + @puppet_initial_install.setter + def puppet_initial_install(self, value): + self._puppet_initial_install = to_bool(value) + # ----------------------------------------------------------- @property def has_backup(self): @@ -1251,6 +1275,7 @@ class TerraformVm(HandlingObject): res['puppet_environment'] = self.puppet_environment res['puppet_role'] = self.puppet_role res['puppet_tier'] = self.puppet_tier + res['puppet_initial_install'] = self.puppet_initial_install res['purpose'] = self.purpose res['rootdisk_size'] = self.rootdisk_size res['tf_name'] = self.tf_name