From: Frank Brehm Date: Tue, 21 Nov 2023 14:49:19 +0000 (+0100) Subject: Updating all packages also for non-Puppet hosts X-Git-Tag: 1.8.0^2~8 X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=c90bc871f1559e0f97335c26d4ce1bd4306d595e;p=pixelpark%2Fcreate-terraform.git Updating all packages also for non-Puppet hosts --- diff --git a/example/.gitignore b/example/.gitignore index 912ab0b..fd8e7bb 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -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 index 0000000..ea9f305 --- /dev/null +++ b/example/really-blank.yaml @@ -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 diff --git a/lib/cr_tf/handler/files.py b/lib/cr_tf/handler/files.py index 6a7549b..8832cf3 100644 --- a/lib/cr_tf/handler/files.py +++ b/lib/cr_tf/handler/files.py @@ -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 + # =============================================================================