Browse Source

Merge pull request #1818 from dgoodwin/safe-yaml-3

Fix inventory properties with raw booleans, again...
Jason DeTiberus 9 years ago
parent
commit
f1fc354da2
1 changed files with 6 additions and 1 deletions
  1. 6 1
      roles/openshift_facts/library/openshift_facts.py

+ 6 - 1
roles/openshift_facts/library/openshift_facts.py

@@ -1276,7 +1276,12 @@ def merge_facts(orig, new, additive_facts_to_overwrite, protected_facts_to_overw
             facts[key] = copy.deepcopy(value)
     new_keys = set(new.keys()) - set(orig.keys())
     for key in new_keys:
-        facts[key] = copy.deepcopy(new[key])
+        # Watchout for JSON facts that sometimes load as strings.
+        # (can happen if the JSON contains a boolean)
+        if key in inventory_json_facts and isinstance(new[key], basestring):
+            facts[key] = yaml.safe_load(new[key])
+        else:
+            facts[key] = copy.deepcopy(new[key])
     return facts
 
 def save_local_facts(filename, facts):