Browse Source

Fail when master.master_count descreases or master.ha changes.

Andrew Butcher 9 years ago
parent
commit
9f22f2654d
1 changed files with 9 additions and 5 deletions
  1. 9 5
      roles/openshift_facts/library/openshift_facts.py

+ 9 - 5
roles/openshift_facts/library/openshift_facts.py

@@ -972,14 +972,18 @@ def merge_facts(orig, new, additive_facts_to_overwrite, protected_facts_to_overw
             elif key in protected_facts and key not in [x.split('.')[-1] for x in protected_facts_to_overwrite]:
                 # The master count (int) can only increase unless it
                 # has been passed as a protected fact to overwrite.
-                if key == 'master_count' and int(value) <= int(new[key]):
-                    facts[key] = copy.deepcopy(new[key])
-                else:
-                    facts[key] = value
+                if key == 'master_count':
+                    if int(value) <= int(new[key]):
+                        facts[key] = copy.deepcopy(new[key])
+                    else:
+                        module.fail_json(msg='openshift_facts received a lower value for openshift.master.master_count')
                 # ha (bool) can not change unless it has been passed
                 # as a protected fact to overwrite.
                 if key == 'ha':
-                    facts[key] = value
+                    if bool(value) != bool(new[key]):
+                        module.fail_json(msg='openshift_facts received a different value for openshift.master.ha')
+                    else:
+                        facts[key] = value
             # No other condition has been met. Overwrite the old fact
             # with the new value.
             else: