summaryrefslogtreecommitdiffstats
path: root/utils/src/ooinstall
diff options
context:
space:
mode:
authorSamuel Munilla <smunilla@redhat.com>2016-08-25 11:12:22 -0400
committerSamuel Munilla <smunilla@redhat.com>2016-09-29 15:43:34 -0400
commit92a9e5547af1c77751fe04ef9f3b849d0885ed03 (patch)
tree4c443fd2abb4e8bebe3bdaa5f1cb6d1440ad8328 /utils/src/ooinstall
parentcd922e0f4a1370118c0e2fd60230a68d74b47095 (diff)
downloadopenshift-92a9e5547af1c77751fe04ef9f3b849d0885ed03.tar.gz
openshift-92a9e5547af1c77751fe04ef9f3b849d0885ed03.tar.bz2
openshift-92a9e5547af1c77751fe04ef9f3b849d0885ed03.tar.xz
openshift-92a9e5547af1c77751fe04ef9f3b849d0885ed03.zip
a-o-i: Allow better setting of host level variables
Allow the user to set arbitrary variables directly under the host item instead of in under an 'other_variables' item.
Diffstat (limited to 'utils/src/ooinstall')
-rw-r--r--utils/src/ooinstall/oo_config.py26
-rw-r--r--utils/src/ooinstall/openshift_ansible.py27
2 files changed, 35 insertions, 18 deletions
diff --git a/utils/src/ooinstall/oo_config.py b/utils/src/ooinstall/oo_config.py
index 8c5f3396b..697ac9c08 100644
--- a/utils/src/ooinstall/oo_config.py
+++ b/utils/src/ooinstall/oo_config.py
@@ -26,6 +26,19 @@ DEPLOYMENT_VARIABLES_BLACKLIST = [
'roles',
]
+HOST_VARIABLES_BLACKLIST = [
+ 'ip',
+ 'public_ip',
+ 'hostname',
+ 'public_hostname',
+ 'node_labels',
+ 'containerized',
+ 'preconfigured',
+ 'schedulable',
+ 'other_variables',
+ 'roles',
+]
+
DEFAULT_REQUIRED_FACTS = ['ip', 'public_ip', 'hostname', 'public_hostname']
PRECONFIGURED_REQUIRED_FACTS = ['hostname', 'public_hostname']
@@ -66,7 +79,7 @@ class Host(object):
self.containerized = kwargs.get('containerized', False)
self.node_labels = kwargs.get('node_labels', '')
- # allowable roles: master, node, etcd, storage, master_lb, new
+ # allowable roles: master, node, etcd, storage, master_lb
self.roles = kwargs.get('roles', [])
self.other_variables = kwargs.get('other_variables', {})
@@ -86,11 +99,13 @@ class Host(object):
d = {}
for prop in ['ip', 'hostname', 'public_ip', 'public_hostname', 'connect_to',
- 'preconfigured', 'containerized', 'schedulable', 'roles', 'node_labels',
- 'other_variables']:
+ 'preconfigured', 'containerized', 'schedulable', 'roles', 'node_labels', ]:
# If the property is defined (not None or False), export it:
if getattr(self, prop):
d[prop] = getattr(self, prop)
+ for variable, value in self.other_variables.iteritems():
+ d[variable] = value
+
return d
def is_master(self):
@@ -202,7 +217,6 @@ class OOConfig(object):
role_list = loaded_config['deployment']['roles']
except KeyError as e:
print_read_config_error("No such key: {}".format(e), self.config_path)
- print "Error loading config, required key missing: {}".format(e)
sys.exit(0)
for setting in CONFIG_PERSIST_SETTINGS:
@@ -237,6 +251,10 @@ class OOConfig(object):
# Parse the hosts into DTO objects:
for host in host_list:
+ host['other_variables'] = {}
+ for variable, value in host.iteritems():
+ if variable not in HOST_VARIABLES_BLACKLIST:
+ host['other_variables'][variable] = value
self.deployment.hosts.append(Host(**host))
# Parse the roles into Objects
diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py
index eb1e61a60..bd0d96d09 100644
--- a/utils/src/ooinstall/openshift_ansible.py
+++ b/utils/src/ooinstall/openshift_ansible.py
@@ -31,6 +31,15 @@ VARIABLES_MAP = {
'proxy_exclude_hosts': 'openshift_no_proxy',
}
+HOST_VARIABLES_MAP = {
+ 'ip': 'openshift_ip',
+ 'public_ip': 'openshift_public_ip',
+ 'hostname': 'openshift_hostname',
+ 'public_hostname': 'openshift_public_hostname',
+ 'node_labels': 'openshift_node_labels',
+ 'containerized': 'containerized',
+}
+
def set_config(cfg):
global CFG
@@ -176,7 +185,6 @@ def write_proxy_settings(base_inventory):
pass
-# pylint: disable=too-many-branches
def write_host(host, role, inventory, schedulable=None):
global CFG
@@ -184,22 +192,13 @@ def write_host(host, role, inventory, schedulable=None):
return
facts = ''
- if host.ip:
- facts += ' openshift_ip={}'.format(host.ip)
- if host.public_ip:
- facts += ' openshift_public_ip={}'.format(host.public_ip)
- if host.hostname:
- facts += ' openshift_hostname={}'.format(host.hostname)
- if host.public_hostname:
- facts += ' openshift_public_hostname={}'.format(host.public_hostname)
- if host.containerized:
- facts += ' containerized={}'.format(host.containerized)
+ for prop in HOST_VARIABLES_MAP:
+ if getattr(host, prop):
+ facts += ' {}={}'.format(HOST_VARIABLES_MAP.get(prop), getattr(host, prop))
+
if host.other_variables:
for variable, value in host.other_variables.iteritems():
facts += " {}={}".format(variable, value)
- if host.node_labels:
- if role == 'node':
- facts += ' openshift_node_labels="{}"'.format(host.node_labels)
# Distinguish between three states, no schedulability specified (use default),
# explicitly set to True, or explicitly set to False: