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": [],
}
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)
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(
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 <veselin.bochev@pixelpark.com>'
__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