summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/src/ooinstall/cli_installer.py67
-rw-r--r--utils/src/ooinstall/oo_config.py10
-rw-r--r--utils/src/ooinstall/openshift_ansible.py23
3 files changed, 74 insertions, 26 deletions
diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py
index 3046d4d58..ace834323 100644
--- a/utils/src/ooinstall/cli_installer.py
+++ b/utils/src/ooinstall/cli_installer.py
@@ -138,9 +138,10 @@ http://docs.openshift.com/enterprise/latest/architecture/infrastructure_componen
host_props['containerized'] = False
if oo_cfg.settings['variant_version'] != '3.0':
- rpm_or_container = click.prompt('Will this host be RPM or Container based (rpm/container)?',
- type=click.Choice(['rpm', 'container']),
- default='rpm')
+ rpm_or_container = \
+ click.prompt('Will this host be RPM or Container based (rpm/container)?',
+ type=click.Choice(['rpm', 'container']),
+ default='rpm')
if rpm_or_container == 'container':
host_props['containerized'] = True
@@ -281,7 +282,8 @@ hostname.
host_props['connect_to'] = click.prompt('Enter hostname or IP address',
value_proc=validate_prompt_lb)
- install_haproxy = click.confirm('Should the reference haproxy load balancer be installed on this host?')
+ 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
@@ -375,7 +377,8 @@ def check_hosts_config(oo_cfg, unattended):
sys.exit(1)
elif len(master_lb) == 1:
if master_lb[0].master or master_lb[0].node:
- click.echo('ERROR: The Master load balancer is configured as a master or node. Please correct this.')
+ click.echo('ERROR: The Master load balancer is configured as a master or node. ' \
+ 'Please correct this.')
sys.exit(1)
else:
message = """
@@ -525,14 +528,30 @@ Add new nodes here
def get_installed_hosts(hosts, callback_facts):
installed_hosts = []
+
+ # count nativeha lb as an installed host
+ try:
+ first_master = next(host for host in hosts if host.master)
+ lb_hostname = callback_facts[first_master.connect_to]['master'].get('cluster_hostname', '')
+ lb_host = \
+ next(host for host in hosts if host.ip == callback_facts[lb_hostname]['common']['ip'])
+
+ installed_hosts.append(lb_host)
+ except (KeyError, StopIteration):
+ pass
+
for host in hosts:
- if(host.connect_to in callback_facts.keys()
- and 'common' in callback_facts[host.connect_to].keys()
- and callback_facts[host.connect_to]['common'].get('version', '')
- and callback_facts[host.connect_to]['common'].get('version', '') != 'None'):
+ if host.connect_to in callback_facts.keys() and is_installed_host(host, callback_facts):
installed_hosts.append(host)
return installed_hosts
+def is_installed_host(host, callback_facts):
+ version_found = 'common' in callback_facts[host.connect_to].keys() and \
+ callback_facts[host.connect_to]['common'].get('version', '') and \
+ callback_facts[host.connect_to]['common'].get('version', '') != 'None'
+
+ return version_found or host.master_lb or host.preconfigured
+
# pylint: disable=too-many-branches
# This pylint error will be corrected shortly in separate PR.
def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force, verbose):
@@ -722,14 +741,30 @@ def upgrade(ctx):
click.echo("No hosts defined in: %s" % oo_cfg.config_path)
sys.exit(1)
- # Update config to reflect the version we're targetting, we'll write
- # to disk once ansible completes successfully, not before.
old_variant = oo_cfg.settings['variant']
old_version = oo_cfg.settings['variant_version']
- if oo_cfg.settings['variant'] == 'enterprise':
- oo_cfg.settings['variant'] = 'openshift-enterprise'
- version = find_variant(oo_cfg.settings['variant'])[1]
- oo_cfg.settings['variant_version'] = version.name
+
+
+ message = """
+ This tool will help you upgrade your existing OpenShift installation.
+"""
+ click.echo(message)
+ click.echo("Version {} found. Do you want to update to the latest version of {} " \
+ "or migrate to the next major release?".format(old_version, old_version))
+ resp = click.prompt("(1) Update to latest {} (2) Migrate to next relese".format(old_version))
+
+ if resp == "2":
+ # TODO: Make this a lot more flexible
+ new_version = "3.1"
+ # Update config to reflect the version we're targetting, we'll write
+ # to disk once ansible completes successfully, not before.
+ if oo_cfg.settings['variant'] == 'enterprise':
+ oo_cfg.settings['variant'] = 'openshift-enterprise'
+ version = find_variant(oo_cfg.settings['variant'])[1]
+ oo_cfg.settings['variant_version'] = version.name
+ else:
+ new_version = old_version
+
click.echo("Openshift will be upgraded from %s %s to %s %s on the following hosts:\n" % (
old_variant, old_version, oo_cfg.settings['variant'],
oo_cfg.settings['variant_version']))
@@ -743,7 +778,7 @@ def upgrade(ctx):
click.echo("Upgrade cancelled.")
sys.exit(0)
- retcode = openshift_ansible.run_upgrade_playbook(verbose)
+ retcode = openshift_ansible.run_upgrade_playbook(old_version, new_version, verbose)
if retcode > 0:
click.echo("Errors encountered during upgrade, please check %s." %
oo_cfg.settings['ansible_log_path'])
diff --git a/utils/src/ooinstall/oo_config.py b/utils/src/ooinstall/oo_config.py
index 33ab27567..b1af21773 100644
--- a/utils/src/ooinstall/oo_config.py
+++ b/utils/src/ooinstall/oo_config.py
@@ -10,6 +10,7 @@ PERSIST_SETTINGS = [
'ansible_ssh_user',
'ansible_config',
'ansible_log_path',
+ 'master_routingconfig_subdomain',
'variant',
'variant_version',
'version',
@@ -146,7 +147,8 @@ class OOConfig(object):
raise OOConfigFileError('Cannot open config file "{}": {}'.format(ferr.filename,
ferr.strerror))
except yaml.scanner.ScannerError:
- raise OOConfigFileError('Config file "{}" is not a valid YAML document'.format(self.config_path))
+ raise OOConfigFileError(
+ 'Config file "{}" is not a valid YAML document'.format(self.config_path))
def _upgrade_legacy_config(self):
new_hosts = []
@@ -179,7 +181,8 @@ class OOConfig(object):
if not os.path.exists(self.settings['ansible_inventory_directory']):
os.makedirs(self.settings['ansible_inventory_directory'])
if 'ansible_plugins_directory' not in self.settings:
- self.settings['ansible_plugins_directory'] = resource_filename(__name__, 'ansible_plugins')
+ self.settings['ansible_plugins_directory'] = \
+ resource_filename(__name__, 'ansible_plugins')
if 'version' not in self.settings:
self.settings['version'] = 'v1'
@@ -190,7 +193,8 @@ class OOConfig(object):
if 'ansible_ssh_user' not in self.settings:
self.settings['ansible_ssh_user'] = ''
- self.settings['ansible_inventory_path'] = '{}/hosts'.format(self.settings['ansible_inventory_directory'])
+ self.settings['ansible_inventory_path'] = \
+ '{}/hosts'.format(self.settings['ansible_inventory_directory'])
# clean up any empty sets
for setting in self.settings.keys():
diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py
index cbb6f33e1..f2c7289fa 100644
--- a/utils/src/ooinstall/openshift_ansible.py
+++ b/utils/src/ooinstall/openshift_ansible.py
@@ -113,9 +113,11 @@ def write_inventory_vars(base_inventory, multiple_masters, proxy):
if multiple_masters and proxy is not None:
base_inventory.write('openshift_master_cluster_method=native\n')
base_inventory.write("openshift_master_cluster_hostname={}\n".format(proxy.hostname))
- base_inventory.write("openshift_master_cluster_public_hostname={}\n".format(proxy.public_hostname))
- if CFG.settings['master_routingconfig_subdomain']:
- base_inventory.write("osm_default_subdomain={}\n".format(CFG.settings['master_routingconfig_subdomain']))
+ base_inventory.write(
+ "openshift_master_cluster_public_hostname={}\n".format(proxy.public_hostname))
+ if CFG.settings.get('master_routingconfig_subdomain', False):
+ base_inventory.write(
+ "osm_default_subdomain={}\n".format(CFG.settings['master_routingconfig_subdomain']))
@@ -204,7 +206,7 @@ def run_main_playbook(hosts, hosts_to_run_on, verbose=False):
inventory_file = generate_inventory(hosts_to_run_on)
if len(hosts_to_run_on) != len(hosts):
main_playbook_path = os.path.join(CFG.ansible_playbook_directory,
- 'playbooks/byo/openshift-cluster/scaleup.yml')
+ 'playbooks/byo/openshift-node/scaleup.yml')
else:
main_playbook_path = os.path.join(CFG.ansible_playbook_directory,
'playbooks/byo/openshift-cluster/config.yml')
@@ -237,11 +239,18 @@ def run_uninstall_playbook(verbose=False):
return run_ansible(playbook, inventory_file, facts_env, verbose)
-def run_upgrade_playbook(verbose=False):
+def run_upgrade_playbook(old_version, new_version, verbose=False):
# TODO: do not hardcode the upgrade playbook, add ability to select the
# right playbook depending on the type of upgrade.
- playbook = os.path.join(CFG.settings['ansible_playbook_directory'],
- 'playbooks/byo/openshift-cluster/upgrades/v3_0_to_v3_1/upgrade.yml')
+ old_version = old_version.replace('.', '_')
+ new_version = old_version.replace('.', '_')
+ if old_version == new_version:
+ playbook = os.path.join(CFG.settings['ansible_playbook_directory'],
+ 'playbooks/byo/openshift-cluster/upgrades/v{}_minor/upgrade.yml'.format(new_version))
+ else:
+ playbook = os.path.join(CFG.settings['ansible_playbook_directory'],
+ 'playbooks/byo/openshift-cluster/upgrades/v{}_to_v{}/upgrade.yml'.format(old_version,
+ new_version))
# TODO: Upgrade inventory for upgrade?
inventory_file = generate_inventory(CFG.hosts)
facts_env = os.environ.copy()