summaryrefslogtreecommitdiffstats
path: root/roles/openshift_facts/library
diff options
context:
space:
mode:
authorJason DeTiberus <jdetiber@redhat.com>2015-11-13 14:55:01 -0500
committerJason DeTiberus <jdetiber@redhat.com>2015-11-13 14:55:01 -0500
commit133bea98b62718fbc23d3c1f74e22665b5293603 (patch)
tree1ea996e876146bb81d1d41482cb83a207aebf480 /roles/openshift_facts/library
parent204089c95b8fb784f7d936ed98ed73011da4b6b3 (diff)
downloadopenshift-133bea98b62718fbc23d3c1f74e22665b5293603.tar.gz
openshift-133bea98b62718fbc23d3c1f74e22665b5293603.tar.bz2
openshift-133bea98b62718fbc23d3c1f74e22665b5293603.tar.xz
openshift-133bea98b62718fbc23d3c1f74e22665b5293603.zip
Update etcd default facts setting
Diffstat (limited to 'roles/openshift_facts/library')
-rwxr-xr-xroles/openshift_facts/library/openshift_facts.py49
1 files changed, 30 insertions, 19 deletions
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py
index ae530eadd..192c3c4bc 100755
--- a/roles/openshift_facts/library/openshift_facts.py
+++ b/roles/openshift_facts/library/openshift_facts.py
@@ -560,8 +560,10 @@ def set_etcd_facts_if_unset(facts):
If anything goes wrong parsing these, the fact will not be set.
"""
- if 'etcd' in facts:
- if 'master' in facts and facts['master']['embedded_etcd']:
+ if 'master' in facts and facts['master']['embedded_etcd']:
+ etcd_facts = facts['etcd'] if 'etcd' in facts else dict()
+
+ if 'etcd_data_dir' not in etcd_facts:
try:
# Parse master config to find actual etcd data dir:
master_cfg_path = os.path.join(facts['common']['config_base'],
@@ -570,28 +572,37 @@ def set_etcd_facts_if_unset(facts):
config = yaml.safe_load(master_cfg_f.read())
master_cfg_f.close()
- facts['etcd']['etcd_data_dir'] = \
+ etcd_facts['etcd_data_dir'] = \
config['etcdConfig']['storageDirectory']
+
+ facts['etcd'] = etcd_facts
+
# We don't want exceptions bubbling up here:
# pylint: disable=broad-except
except Exception:
pass
- else:
- # Read ETCD_DATA_DIR from /etc/etcd/etcd.conf:
- try:
- # Add a fake section for parsing:
- ini_str = '[root]\n' + open('/etc/etcd/etcd.conf', 'r').read()
- ini_fp = StringIO.StringIO(ini_str)
- config = ConfigParser.RawConfigParser()
- config.readfp(ini_fp)
- etcd_data_dir = config.get('root', 'ETCD_DATA_DIR')
- if etcd_data_dir.startswith('"') and etcd_data_dir.endswith('"'):
- etcd_data_dir = etcd_data_dir[1:-1]
- facts['etcd']['etcd_data_dir'] = etcd_data_dir
- # We don't want exceptions bubbling up here:
- # pylint: disable=broad-except
- except Exception:
- pass
+ else:
+ etcd_facts = facts['etcd'] if 'etcd' in facts else dict()
+
+ # Read ETCD_DATA_DIR from /etc/etcd/etcd.conf:
+ try:
+ # Add a fake section for parsing:
+ ini_str = '[root]\n' + open('/etc/etcd/etcd.conf', 'r').read()
+ ini_fp = StringIO.StringIO(ini_str)
+ config = ConfigParser.RawConfigParser()
+ config.readfp(ini_fp)
+ etcd_data_dir = config.get('root', 'ETCD_DATA_DIR')
+ if etcd_data_dir.startswith('"') and etcd_data_dir.endswith('"'):
+ etcd_data_dir = etcd_data_dir[1:-1]
+
+ etcd_facts['etcd_data_dir'] = etcd_data_dir
+ facts['etcd'] = etcd_facts
+
+ # We don't want exceptions bubbling up here:
+ # pylint: disable=broad-except
+ except Exception:
+ pass
+
return facts
def set_deployment_facts_if_unset(facts):