]> Frank Brehm's Git Trees - pixelpark/create-terraform.git/commitdiff
Updating all packages also for non-Puppet hosts
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 21 Nov 2023 14:49:19 +0000 (15:49 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 21 Nov 2023 14:49:19 +0000 (15:49 +0100)
example/.gitignore
example/really-blank.yaml [new file with mode: 0644]
lib/cr_tf/handler/files.py

index 912ab0b472bf41228255a3fc8d60e85a2817bfa7..fd8e7bb29833f4b82da28c9da2a48c4e5fa57e26 100644 (file)
@@ -1,3 +1,4 @@
 *repo03*
 *repo01*
 dev-deploy*
+really-blank*
diff --git a/example/really-blank.yaml b/example/really-blank.yaml
new file mode 100644 (file)
index 0000000..ea9f305
--- /dev/null
@@ -0,0 +1,38 @@
+---
+defaults:
+  vsphere: test
+  cluster: test-vmcc-l105-01
+  vm_folder: pp-user/frank.brehm
+  num_cpus: 2
+  memory: 4GB
+  boot_delay: 5
+  datastore_cluster: Daten-Cluster-Gold_01
+  datastore_type: ssd
+  template: rhel9-dev-template
+  root_disk:
+    size: 20
+  customer: Digitas Pixelpark GmbH
+  purpose: Test VM w/o Puppet with Terraform
+  has_puppet: false
+  puppet:
+    customer: pixelpark
+    project: test
+    tier: development
+    environment: dev_fbrehm
+    contact: solution@pixelpark.com
+    role: dpx_infra::test_deploy
+    initial-install: false
+  nameservers:
+    - 93.188.109.13
+    - 77.74.232.25
+    - 217.66.52.10
+  searchdomains:
+    - pixelpark.com
+    - pixelpark.net
+    - pixelpark.de
+  dns_options: 'timeout:1 attempts:2 use-vc'
+
+vms:
+  - name: dev-really-blank-rhel9.pixelpark.com
+    interfaces:
+      - address_v4: 192.168.145.53
index 6a7549bd928ad057e8e3aadf695896e7a236c7d2..8832cf362186c840d5736acedb027621e2a8a678 100644 (file)
@@ -28,7 +28,7 @@ from ..errors import AbortExecution
 
 from ..xlate import XLATOR
 
-__version__ = '0.4.1'
+__version__ = '0.4.2'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -751,7 +751,7 @@ class CrTfHandlerFilesMixin():
             files.append('register-rhel')
         if vm.has_puppet:
             files.append('init-puppet')
-            files.append('update-all-packages')
+        files.append('update-all-packages')
 
         for sname in files:
 
@@ -869,6 +869,8 @@ class CrTfHandlerFilesMixin():
         # ## postconfigure actions with puppet
         if vm.has_puppet:
             content += self._create_instfile_puppet(vm)
+        else:
+            content += self._only_update_packages(vm)
 
         # ## Unregistring from RedHat Subscription Management
         cmd = ('if [ -x /sbin/subscription-manager ] ; then '
@@ -1007,6 +1009,29 @@ class CrTfHandlerFilesMixin():
 
         return content
 
+    # -------------------------------------------------------------------------ยท
+    def _only_update_packages(self, vm):
+
+        content = textwrap.indent(textwrap.dedent('''\
+        provisioner "remote-exec" {{
+          inline = [
+            "chmod +x /tmp/update-all-packages",
+            "/tmp/update-all-packages",
+            "rm -fv /tmp/update-all-packages /tmp/functions.rc",
+          ]
+          connection {{
+            type        = "ssh"
+            host        = "{h}"
+            user        = "root"
+            private_key = file("{k}")
+            agent       = "false"
+          }}
+        }}
+
+        '''), '  ').format(h=vm.fqdn, k=self.private_key_rel)
+
+        return content
+
 
 # =============================================================================