summaryrefslogtreecommitdiffstats
path: root/utils/src/ooinstall
diff options
context:
space:
mode:
Diffstat (limited to 'utils/src/ooinstall')
-rw-r--r--utils/src/ooinstall/cli_installer.py20
-rw-r--r--utils/src/ooinstall/oo_config.py27
-rw-r--r--utils/src/ooinstall/openshift_ansible.py30
-rw-r--r--utils/src/ooinstall/utils.py3
-rw-r--r--utils/src/ooinstall/variants.py44
5 files changed, 73 insertions, 51 deletions
diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py
index 8470fb527..0bc9aa45e 100644
--- a/utils/src/ooinstall/cli_installer.py
+++ b/utils/src/ooinstall/cli_installer.py
@@ -318,6 +318,7 @@ hostname.
def set_cluster_hostname(oo_cfg):
+ first_master = next((host for host in oo_cfg.deployment.hosts if host.is_master()), None)
message = """
You have chosen to install a single master cluster (non-HA).
@@ -329,8 +330,9 @@ If you want to override the cluster host name now to something other than the de
"""
click.echo(message)
cluster_hostname = click.prompt('Enter hostname or IP address',
- default='')
+ default=str(first_master))
oo_cfg.deployment.variables['openshift_master_cluster_hostname'] = cluster_hostname
+ oo_cfg.deployment.variables['openshift_master_cluster_public_hostname'] = cluster_hostname
def collect_storage_host(hosts):
@@ -499,7 +501,7 @@ def get_variant_and_version(multi_master=False):
i = 1
combos = get_variant_version_combos()
- for (variant, version) in combos:
+ for (variant, _) in combos:
message = "%s\n(%s) %s" % (message, i, variant.description)
i = i + 1
message = "%s\n" % message
@@ -1122,6 +1124,20 @@ def scaleup(ctx, gen_inventory):
click.echo('Welcome to the OpenShift Enterprise 3 Scaleup utility.')
+ # Scaleup requires manual data entry. Therefore, we do not support
+ # unattended operations.
+ if unattended:
+ msg = """
+---
+
+The 'scaleup' operation does not support unattended
+functionality. Re-run the installer without the '-u' or '--unattended'
+option to continue.
+"""
+ click.echo(msg)
+ sys.exit(1)
+
+ # Resume normal scaleup workflow
print_installation_summary(installed_hosts,
oo_cfg.settings['variant_version'],
verbose=False,)
diff --git a/utils/src/ooinstall/oo_config.py b/utils/src/ooinstall/oo_config.py
index 64eb340f3..cf14105af 100644
--- a/utils/src/ooinstall/oo_config.py
+++ b/utils/src/ooinstall/oo_config.py
@@ -1,5 +1,7 @@
# pylint: disable=bad-continuation,missing-docstring,no-self-use,invalid-name,too-many-instance-attributes,too-few-public-methods
+from __future__ import (absolute_import, print_function)
+
import os
import sys
import logging
@@ -50,7 +52,7 @@ Error loading config. {}.
See https://docs.openshift.com/enterprise/latest/install_config/install/quick_install.html#defining-an-installation-configuration-file
for information on creating a configuration file or delete {} and re-run the installer.
"""
- print message.format(error, path)
+ print(message.format(error, path))
class OOConfigFileError(Exception):
@@ -103,7 +105,7 @@ class Host(object):
# 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():
+ for variable, value in self.other_variables.items():
d[variable] = value
return d
@@ -256,16 +258,16 @@ class OOConfig(object):
# Parse the hosts into DTO objects:
for host in host_list:
host['other_variables'] = {}
- for variable, value in host.iteritems():
+ for variable, value in host.items():
if variable not in HOST_VARIABLES_BLACKLIST:
host['other_variables'][variable] = value
self.deployment.hosts.append(Host(**host))
# Parse the roles into Objects
- for name, variables in role_list.iteritems():
+ for name, variables in role_list.items():
self.deployment.roles.update({name: Role(name, variables)})
- except IOError, ferr:
+ except IOError as ferr:
raise OOConfigFileError('Cannot open config file "{}": {}'.format(ferr.filename,
ferr.strerror))
except yaml.scanner.ScannerError:
@@ -354,14 +356,13 @@ class OOConfig(object):
self.settings['ansible_inventory_path'] = \
'{}/hosts'.format(os.path.dirname(self.config_path))
- # pylint: disable=consider-iterating-dictionary
- # Disabled because we shouldn't alter the container we're
- # iterating over
- #
# clean up any empty sets
- for setting in self.settings.keys():
+ empty_keys = []
+ for setting in self.settings:
if not self.settings[setting]:
- self.settings.pop(setting)
+ empty_keys.append(setting)
+ for key in empty_keys:
+ self.settings.pop(key)
installer_log.debug("Updated OOConfig settings: %s", self.settings)
@@ -410,7 +411,7 @@ class OOConfig(object):
for host in self.deployment.hosts:
p_settings['deployment']['hosts'].append(host.to_dict())
- for name, role in self.deployment.roles.iteritems():
+ for name, role in self.deployment.roles.items():
p_settings['deployment']['roles'][name] = role.variables
for setting in self.deployment.variables:
@@ -424,7 +425,7 @@ class OOConfig(object):
if self.settings['ansible_inventory_directory'] != self._default_ansible_inv_dir():
p_settings['ansible_inventory_directory'] = self.settings['ansible_inventory_directory']
except KeyError as e:
- print "Error persisting settings: {}".format(e)
+ print("Error persisting settings: {}".format(e))
sys.exit(0)
return p_settings
diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py
index 764cc1e56..ce6e54664 100644
--- a/utils/src/ooinstall/openshift_ansible.py
+++ b/utils/src/ooinstall/openshift_ansible.py
@@ -1,5 +1,7 @@
# pylint: disable=bad-continuation,missing-docstring,no-self-use,invalid-name,global-statement,global-variable-not-assigned
+from __future__ import (absolute_import, print_function)
+
import socket
import subprocess
import sys
@@ -107,12 +109,12 @@ def write_inventory_vars(base_inventory, lb):
global CFG
base_inventory.write('\n[OSEv3:vars]\n')
- for variable, value in CFG.settings.iteritems():
+ for variable, value in CFG.settings.items():
inventory_var = VARIABLES_MAP.get(variable, None)
if inventory_var and value:
base_inventory.write('{}={}\n'.format(inventory_var, value))
- for variable, value in CFG.deployment.variables.iteritems():
+ for variable, value in CFG.deployment.variables.items():
inventory_var = VARIABLES_MAP.get(variable, variable)
if value:
base_inventory.write('{}={}\n'.format(inventory_var, value))
@@ -152,11 +154,11 @@ def write_inventory_vars(base_inventory, lb):
"'baseurl': '{}', "
"'enabled': 1, 'gpgcheck': 0}}]\n".format(os.environ['OO_INSTALL_PUDDLE_REPO']))
- for name, role_obj in CFG.deployment.roles.iteritems():
+ for name, role_obj in CFG.deployment.roles.items():
if role_obj.variables:
group_name = ROLES_TO_GROUPS_MAP.get(name, name)
base_inventory.write("\n[{}:vars]\n".format(group_name))
- for variable, value in role_obj.variables.iteritems():
+ for variable, value in role_obj.variables.items():
inventory_var = VARIABLES_MAP.get(variable, variable)
if value:
base_inventory.write('{}={}\n'.format(inventory_var, value))
@@ -193,7 +195,7 @@ def write_host(host, role, inventory, schedulable=None):
facts += ' {}={}'.format(HOST_VARIABLES_MAP.get(prop), getattr(host, prop))
if host.other_variables:
- for variable, value in host.other_variables.iteritems():
+ for variable, value in host.other_variables.items():
facts += " {}={}".format(variable, value)
if host.node_labels and role == 'node':
@@ -210,9 +212,9 @@ def write_host(host, role, inventory, schedulable=None):
if installer_host in [host.connect_to, host.hostname, host.public_hostname]:
facts += ' ansible_connection=local'
if os.geteuid() != 0:
- no_pwd_sudo = subprocess.call(['sudo', '-n', 'echo', 'openshift'])
+ no_pwd_sudo = subprocess.call(['sudo', '-n', 'echo', '-n'])
if no_pwd_sudo == 1:
- print 'The atomic-openshift-installer requires sudo access without a password.'
+ print('The atomic-openshift-installer requires sudo access without a password.')
sys.exit(1)
facts += ' ansible_become=yes'
@@ -245,9 +247,9 @@ def load_system_facts(inventory_file, os_facts_path, env_vars, verbose=False):
installer_log.debug("Going to try to read this file: %s", CFG.settings['ansible_callback_facts_yaml'])
try:
callback_facts = yaml.safe_load(callback_facts_file)
- except yaml.YAMLError, exc:
- print "Error in {}".format(CFG.settings['ansible_callback_facts_yaml']), exc
- print "Try deleting and rerunning the atomic-openshift-installer"
+ except yaml.YAMLError as exc:
+ print("Error in {}".format(CFG.settings['ansible_callback_facts_yaml']), exc)
+ print("Try deleting and rerunning the atomic-openshift-installer")
sys.exit(1)
return callback_facts, 0
@@ -314,6 +316,10 @@ def run_uninstall_playbook(hosts, verbose=False):
facts_env['ANSIBLE_LOG_PATH'] = CFG.settings['ansible_log_path']
if 'ansible_config' in CFG.settings:
facts_env['ANSIBLE_CONFIG'] = CFG.settings['ansible_config']
+ # override the ansible config for our main playbook run
+ if 'ansible_quiet_config' in CFG.settings:
+ facts_env['ANSIBLE_CONFIG'] = CFG.settings['ansible_quiet_config']
+
return run_ansible(playbook, inventory_file, facts_env, verbose)
@@ -328,4 +334,8 @@ def run_upgrade_playbook(hosts, playbook, verbose=False):
facts_env['ANSIBLE_LOG_PATH'] = CFG.settings['ansible_log_path']
if 'ansible_config' in CFG.settings:
facts_env['ANSIBLE_CONFIG'] = CFG.settings['ansible_config']
+ # override the ansible config for our main playbook run
+ if 'ansible_quiet_config' in CFG.settings:
+ facts_env['ANSIBLE_CONFIG'] = CFG.settings['ansible_quiet_config']
+
return run_ansible(playbook, inventory_file, facts_env, verbose)
diff --git a/utils/src/ooinstall/utils.py b/utils/src/ooinstall/utils.py
index 85a77c75e..c9e3e25e5 100644
--- a/utils/src/ooinstall/utils.py
+++ b/utils/src/ooinstall/utils.py
@@ -1,3 +1,5 @@
+# pylint: disable=missing-docstring,invalid-name
+
import logging
import re
@@ -8,6 +10,7 @@ installer_log = logging.getLogger('installer')
def debug_env(env):
for k in sorted(env.keys()):
if k.startswith("OPENSHIFT") or k.startswith("ANSIBLE") or k.startswith("OO"):
+ # pylint: disable=logging-format-interpolation
installer_log.debug("{key}: {value}".format(
key=k, value=env[k]))
diff --git a/utils/src/ooinstall/variants.py b/utils/src/ooinstall/variants.py
index 39772bb2e..a45be98bf 100644
--- a/utils/src/ooinstall/variants.py
+++ b/utils/src/ooinstall/variants.py
@@ -38,32 +38,24 @@ class Variant(object):
# WARNING: Keep the versions ordered, most recent first:
-OSE = Variant('openshift-enterprise', 'OpenShift Container Platform',
- [
- Version('3.4', 'openshift-enterprise'),
- ]
-)
-
-REG = Variant('openshift-enterprise', 'Registry',
- [
- Version('3.4', 'openshift-enterprise', 'registry'),
- ]
-)
-
-origin = Variant('origin', 'OpenShift Origin',
- [
- Version('1.4', 'origin'),
- ]
-)
-
-LEGACY = Variant('openshift-enterprise', 'OpenShift Container Platform',
- [
- Version('3.3', 'openshift-enterprise'),
- Version('3.2', 'openshift-enterprise'),
- Version('3.1', 'openshift-enterprise'),
- Version('3.0', 'openshift-enterprise'),
- ]
-)
+OSE = Variant('openshift-enterprise', 'OpenShift Container Platform', [
+ Version('3.4', 'openshift-enterprise'),
+])
+
+REG = Variant('openshift-enterprise', 'Registry', [
+ Version('3.4', 'openshift-enterprise', 'registry'),
+])
+
+origin = Variant('origin', 'OpenShift Origin', [
+ Version('1.4', 'origin'),
+])
+
+LEGACY = Variant('openshift-enterprise', 'OpenShift Container Platform', [
+ Version('3.3', 'openshift-enterprise'),
+ Version('3.2', 'openshift-enterprise'),
+ Version('3.1', 'openshift-enterprise'),
+ Version('3.0', 'openshift-enterprise'),
+])
# Ordered list of variants we can install, first is the default.
SUPPORTED_VARIANTS = (OSE, REG, origin, LEGACY)