]> Frank Brehm's Git Trees - pixelpark/create-terraform.git/commitdiff
Defining VM property puppet_initial_install
authorFrank Brehm <frank@brehm-online.com>
Tue, 19 Jul 2022 11:52:50 +0000 (13:52 +0200)
committerFrank Brehm <frank@brehm-online.com>
Tue, 19 Jul 2022 11:52:50 +0000 (13:52 +0200)
lib/cr_tf/terraform/vm.py

index d2041554673aa88b8ca17331e77aa2a4c5a108ba..efb831ad69e6b87d388435aa5482578bd0aeb4d1 100644 (file)
@@ -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