]> Frank Brehm's Git Trees - pixelpark/create-terraform.git/commitdiff
minor fixes and defaults
authorVeselin Bochev <veselin.bochev@WKMZT0869FF7.global.publicisgroupe.net>
Thu, 2 Jun 2022 09:51:51 +0000 (12:51 +0300)
committerVeselin Bochev <veselin.bochev@WKMZT0869FF7.global.publicisgroupe.net>
Thu, 2 Jun 2022 09:51:51 +0000 (12:51 +0300)
bin/pre-terraform

index 691cc48d5e486eae6708e7a7231fc0114aeba0be..9a6e2e819ed7264ffb537efbc93f765deb79e994 100755 (executable)
@@ -134,21 +134,23 @@ 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)
-
-    # Searchdomains resolv.conf
-    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"]
+
+        # Nameservers resolv.conf
+        for ns in data["resolv_conf"]["value"]["nameserver"]:
+            sample_pre_tf["defaults"]["namservers"].append(ns)
+
+        # Searchdomains resolv.conf
+        for sd in data["resolv_conf"]["value"]["search"]:
+            sample_pre_tf["defaults"]["searchdomains"].append(sd)
     except:
         timeout = 1
         attempts = 2
+        sample_pre_tf["defaults"]["namservers"] = []
+        sample_pre_tf["defaults"]["searchdomains"] = []
 
     sample_pre_tf["defaults"]["dns_options"] = f"timeout: {timeout} attempts: {attempts}"
 
@@ -203,8 +205,8 @@ try:
     # Project
     sample_pre_tf["defaults"]["puppet"]["project"] = data["pp_owner"]["value"]
 
-    # Project
-    sample_pre_tf["defaults"]["purpose"] = data["pp_purpose"]["value"]
+    # Purpose
+    sample_pre_tf["defaults"]["purpose"] = data["pp_purpose"]["value"].split(' ')[0]
 
     # Environment
     sample_pre_tf["defaults"]["puppet"]["tier"] = data["tier"]["value"]