summaryrefslogtreecommitdiffstats
path: root/roles/openshift_facts/library
diff options
context:
space:
mode:
authorAndrew Butcher <abutcher@redhat.com>2017-11-27 13:48:24 -0500
committerAndrew Butcher <abutcher@redhat.com>2017-11-27 14:48:02 -0500
commit01bf8747778f3fed9554d864bc854df7b523b6bf (patch)
tree0f4d522ced18263d19db8603550b7ab801cacb90 /roles/openshift_facts/library
parent96bc873739197ea6aeb2712d6d26f6e3fd29e0d5 (diff)
downloadopenshift-01bf8747778f3fed9554d864bc854df7b523b6bf.tar.gz
openshift-01bf8747778f3fed9554d864bc854df7b523b6bf.tar.bz2
openshift-01bf8747778f3fed9554d864bc854df7b523b6bf.tar.xz
openshift-01bf8747778f3fed9554d864bc854df7b523b6bf.zip
Fix openshift_env fact creation within openshift_facts.
Diffstat (limited to 'roles/openshift_facts/library')
-rwxr-xr-xroles/openshift_facts/library/openshift_facts.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py
index f94e0e097..3c121877a 100755
--- a/roles/openshift_facts/library/openshift_facts.py
+++ b/roles/openshift_facts/library/openshift_facts.py
@@ -2253,14 +2253,27 @@ class OpenShiftFacts(object):
oo_env_facts = dict()
current_level = oo_env_facts
keys = self.split_openshift_env_fact_keys(fact, openshift_env_structures)[1:]
+
if len(keys) > 0 and keys[0] != self.role:
continue
- for key in keys:
- if key == keys[-1]:
- current_level[key] = value
- elif key not in current_level:
- current_level[key] = dict()
- current_level = current_level[key]
+
+ # Build a dictionary from the split fact keys.
+ # After this loop oo_env_facts is the resultant dictionary.
+ # For example:
+ # fact = "openshift_metrics_install_metrics"
+ # value = 'true'
+ # keys = ['metrics', 'install', 'metrics']
+ # result = {'metrics': {'install': {'metrics': 'true'}}}
+ for i, _ in enumerate(keys):
+ # This is the last key. Set the value.
+ if i == (len(keys) - 1):
+ current_level[keys[i]] = value
+ # This is a key other than the last key. Set as
+ # dictionary and continue.
+ else:
+ current_level[keys[i]] = dict()
+ current_level = current_level[keys[i]]
+
facts_to_set = merge_facts(orig=facts_to_set,
new=oo_env_facts,
additive_facts_to_overwrite=[],