From 9f22f2654dac464ab419867e27d0ed6155a2a356 Mon Sep 17 00:00:00 2001 From: Andrew Butcher Date: Mon, 15 Feb 2016 14:52:45 -0500 Subject: Fail when master.master_count descreases or master.ha changes. --- roles/openshift_facts/library/openshift_facts.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 360033c32..b6edd8e2f 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/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: -- cgit v1.2.3