From: Veselin Bochev Date: Wed, 1 Jun 2022 13:51:56 +0000 (+0300) Subject: minor optimizations, included OS facts and dns_options (resolv.conf) X-Git-Tag: 1.6.1~1^2~15 X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=fb706065aed81e32e3f9bc82b96243bc0604fb0a;p=pixelpark%2Fcreate-terraform.git minor optimizations, included OS facts and dns_options (resolv.conf) --- diff --git a/bin/pre-terraform b/bin/pre-terraform index 71a5ac6..1f3aae3 100755 --- a/bin/pre-terraform +++ b/bin/pre-terraform @@ -92,15 +92,15 @@ for fact in facts: sample_pre_tf = { "defaults": { "vsphere": "live", - "cluster": "vmcc-l105-01", - "vm_folder": "Pixelpark/__", + "cluster": "vmcc-l105-01 <<< Check this", + "vm_folder": "Pixelpark/__ <<< Check this", "num_cpus": 0, "memory": "__", "boot_delay": 5, - "template": "__", + "template": "__ <<< Check this", "customer": "__", "purpose": "__", - "datastore_cluster": "ds-cluster-hdd-vmcc-l105-01", + "datastore_cluster": "ds-cluster-hdd-vmcc-l105-01 <<< Check this", "datastore_type": "sata", "root_disk": { "size": 0 }, "data_disks": [], @@ -124,6 +124,8 @@ sample_pre_tf = { } try: + print(f"OS according to facts: {data['os']['value']['name']} {data['os']['value']['release']['full']}\n") + # Nameservers resolv.conf for ns in data["resolv_conf"]["value"]["nameserver"]: sample_pre_tf["defaults"]["namservers"].append(ns) @@ -132,9 +134,20 @@ try: for sd in data["resolv_conf"]["value"]["search"]: sample_pre_tf["defaults"]["searchdomains"].append(sd) + # Options resolv.conf + try: + timeout = data["resolv_conf"]["value"]["timeout"] + attempts = data["resolv_conf"]["value"]["attempts"] + except: + timeout = 1 + attempts = 2 + + sample_pre_tf["defaults"]["dns_options"] = f"timeout: {timeout} attempts: {attempts}" + # Disks root sample_pre_tf["defaults"]["root_disk"]["size"] = int(data["disks"]["value"]["sda"]["size_bytes"]/int(1<<30)) - # additional disks + + # Disks additional for disk in data["disks"]["value"]: if disk.startswith("sd") and disk != "sda": sample_pre_tf["defaults"]["data_disks"].append( @@ -179,9 +192,16 @@ except: print("ERROR: Failed parsing required fields from output. Please check if hostname is in PuppetDB") _exit(1) -print(yaml.dump(sample_pre_tf)) +# Print the YAML configuration file +print(f"Template:\n---\n{yaml.dump(sample_pre_tf)}") __author__ = 'Veselin Bochev ' __copyright__ = '(C) 2022 by Veselin Bochev, Pixelpark GmbH, Berlin' -# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 +# These are the facts - Slim version +# print(data) + +# These are the facts - All +# print(facts) + +# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 \ No newline at end of file