summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorBrenton Leanhardt <bleanhar@redhat.com>2015-11-23 11:56:27 -0500
committerSamuel Munilla <smunilla@redhat.com>2015-11-23 18:05:27 -0500
commitc148283d1731d08fbfd4446af88450c5983c7b7a (patch)
tree9079cceb4c68d71f25ff95783e5674f3879bf0b0 /utils
parentac6bc198d469315e7fec2452211c13d37abca795 (diff)
downloadopenshift-c148283d1731d08fbfd4446af88450c5983c7b7a.tar.gz
openshift-c148283d1731d08fbfd4446af88450c5983c7b7a.tar.bz2
openshift-c148283d1731d08fbfd4446af88450c5983c7b7a.tar.xz
openshift-c148283d1731d08fbfd4446af88450c5983c7b7a.zip
Handling preconfigured load balancers
The preconfigured load balancers, previously denoted by having 'run_on' set to false, cannot have their facts gathered which results in a stack trace. Later when we write out the inventory we have to fake out the hostname and just use 'connect_to'. We're likely going to have the concept of other types of "plug-in" hosts where we don't run ansible. We should make sure we abstract this properly so it's easy to add additional types of hosts. Also in the commit: - Renamed 'run_on' to 'preconfigured' and inverted the logic as needed - Output tally of Masters and Nodes as well as remaining Masters required for HA - Minor rewording in a few places - Currently only prompting for the load balancer after all other hosts have been entered - Removed spurious echo
Diffstat (limited to 'utils')
-rw-r--r--utils/src/ooinstall/cli_installer.py34
-rw-r--r--utils/src/ooinstall/oo_config.py4
-rw-r--r--utils/src/ooinstall/openshift_ansible.py17
3 files changed, 40 insertions, 15 deletions
diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py
index ac9d884d9..9abea0683 100644
--- a/utils/src/ooinstall/cli_installer.py
+++ b/utils/src/ooinstall/cli_installer.py
@@ -79,6 +79,7 @@ def collect_hosts(version=None, masters_set=False):
Returns: a list of host information collected from the user
"""
+ min_masters_for_ha = 3
click.clear()
click.echo('***Host Configuration***')
message = """
@@ -114,10 +115,7 @@ http://docs.openshift.com/enterprise/latest/architecture/infrastructure_componen
host_props['master'] = True
num_masters += 1
- if num_masters > 1:
- hosts.append(collect_master_lb())
-
- if num_masters >= 3 or version == '3.0':
+ if num_masters >= min_masters_for_ha or version == '3.0':
masters_set = True
host_props['node'] = True
@@ -135,8 +133,18 @@ http://docs.openshift.com/enterprise/latest/architecture/infrastructure_componen
hosts.append(host)
- if num_masters <= 1 or num_masters >= 3:
+ click.echo('')
+ click.echo('Current Masters: {}'.format(num_masters))
+ click.echo('Current Nodes: {}'.format(len(hosts)))
+ click.echo('Additional Masters required for HA: {}'.format(max(min_masters_for_ha - num_masters, 0)))
+ click.echo('')
+
+ if num_masters <= 1 or num_masters >= min_masters_for_ha:
more_hosts = click.confirm('Do you want to add additional hosts?')
+
+ if num_masters > 1:
+ hosts.append(collect_master_lb())
+
return hosts
def collect_master_lb():
@@ -149,14 +157,19 @@ Please provide a host that will be configured as a proxy. This can either be
an existing load balancer configured to balance all masters on port 8443 or a
new host that will have HAProxy installed on it.
-This will also require you to set a third master.
+If the host provided does is not yet configured a reference haproxy load
+balancer will be installed. It's important to note that while the rest of the
+environment will be fault tolerant this reference load balancer will not be.
+It can be replaced post-installation with a load balancer with the same
+hostname.
"""
click.echo(message)
host_props = {}
host_props['connect_to'] = click.prompt('Enter hostname or IP address:',
default='',
value_proc=validate_prompt_hostname)
- host_props['run_on'] = click.confirm('Is this a clean host you want to install HAProxy on?')
+ install_haproxy = click.confirm('Should the reference haproxy load balancer be installed on this host?')
+ host_props['preconfigured'] = not install_haproxy
host_props['master'] = False
host_props['node'] = False
host_props['master_lb'] = True
@@ -201,6 +214,8 @@ Notes:
default_facts_lines = []
default_facts = {}
for h in hosts:
+ if h.preconfigured == True:
+ continue
default_facts[h.connect_to] = {}
h.ip = callback_facts[h.connect_to]["common"]["ip"]
h.public_ip = callback_facts[h.connect_to]["common"]["public_ip"]
@@ -238,13 +253,12 @@ def check_hosts_config(oo_cfg):
masters = [host for host in oo_cfg.hosts if host.master]
if len(masters) > 1:
master_lb = [host for host in oo_cfg.hosts if host.master_lb]
- click.echo(master_lb)
if len(master_lb) > 1:
- click.echo('More than one HAProxy specified. Only one proxy is allowed.')
+ click.echo('More than one Master load balancer specified. Only one is allowed.')
sys.exit(0)
elif len(master_lb) == 1:
if master_lb[0].master or master_lb[0].node:
- click.echo('HAProxy is configured as a master or node. Please correct this.')
+ click.echo('The Master load balancer is configured as a master or node. Please correct this.')
sys.exit(0)
else:
message = """
diff --git a/utils/src/ooinstall/oo_config.py b/utils/src/ooinstall/oo_config.py
index 243a75b09..b6f0cdce3 100644
--- a/utils/src/ooinstall/oo_config.py
+++ b/utils/src/ooinstall/oo_config.py
@@ -36,7 +36,7 @@ class Host(object):
self.public_ip = kwargs.get('public_ip', None)
self.public_hostname = kwargs.get('public_hostname', None)
self.connect_to = kwargs.get('connect_to', None)
- self.run_on = kwargs.get('run_on', None)
+ self.preconfigured = kwargs.get('preconfigured', None)
# Should this host run as an OpenShift master:
self.master = kwargs.get('master', False)
@@ -67,7 +67,7 @@ class Host(object):
""" Used when exporting to yaml. """
d = {}
for prop in ['ip', 'hostname', 'public_ip', 'public_hostname',
- 'master', 'node', 'master_lb', 'containerized', 'connect_to', 'run_on']:
+ 'master', 'node', 'master_lb', 'containerized', 'connect_to', 'preconfigured']:
# If the property is defined (not None or False), export it:
if getattr(self, prop):
d[prop] = getattr(self, prop)
diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py
index 86c707b17..ed1ba2c77 100644
--- a/utils/src/ooinstall/openshift_ansible.py
+++ b/utils/src/ooinstall/openshift_ansible.py
@@ -19,7 +19,7 @@ def generate_inventory(hosts):
global CFG
masters = [host for host in hosts if host.master]
nodes = [host for host in hosts if host.node]
- proxy = next((host for host in hosts if host.master_lb), None)
+ proxy = determine_proxy_configuration(hosts)
multiple_masters = len(masters) > 1
base_inventory_path = CFG.settings['ansible_inventory_path']
@@ -66,13 +66,24 @@ def generate_inventory(hosts):
scheduleable = False
write_host(node, base_inventory, scheduleable)
- if getattr(proxy, 'run_on', False):
+ if not getattr(proxy, 'preconfigured', True):
base_inventory.write('\n[lb]\n')
write_host(proxy, base_inventory)
base_inventory.close()
return base_inventory_path
+def determine_proxy_configuration(hosts):
+ proxy = next((host for host in hosts if host.master_lb), None)
+ if proxy:
+ if proxy.hostname == None:
+ proxy.hostname = proxy.connect_to
+ proxy.public_hostname = proxy.connect_to
+ print('asd09o')
+ return proxy
+
+ return None
+
def write_inventory_children(base_inventory, multiple_masters, proxy):
global CFG
@@ -81,7 +92,7 @@ def write_inventory_children(base_inventory, multiple_masters, proxy):
base_inventory.write('nodes\n')
if multiple_masters:
base_inventory.write('etcd\n')
- if getattr(proxy, 'run_on', False):
+ if not getattr(proxy, 'preconfigured', True):
base_inventory.write('lb\n')
def write_inventory_vars(base_inventory, multiple_masters, proxy):