From 7197aba51d24ab2cf6cde77efa853903d7ddd5ba Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 28 Oct 2015 12:12:39 -0300 Subject: Block upgrade if targetting enterprise deployment type. enterprise is being phased out in favor of openshift-enterprise, you need to specify where you wish to go. --- utils/src/ooinstall/cli_installer.py | 21 +++++++++++++++++++++ utils/src/ooinstall/install_transactions.py | 12 ++++++++++++ 2 files changed, 33 insertions(+) (limited to 'utils/src') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index 03f86a166..e22217fdb 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -459,6 +459,26 @@ def uninstall(ctx): install_transactions.run_uninstall_playbook() +@click.command() +@click.pass_context +def upgrade(ctx): + oo_cfg = ctx.obj['oo_cfg'] + + if len(oo_cfg.hosts) == 0: + click.echo("No hosts defined in: %s" % oo_cfg['configuration']) + sys.exit(1) + + click.echo("OpenShift will be upgraded on the following hosts:\n") + if not ctx.obj['unattended']: + # Prompt interactively to confirm: + for host in oo_cfg.hosts: + click.echo(" * %s" % host.name) + proceed = click.confirm("\nDo you wish to proceed?") + if not proceed: + click.echo("Upgrade cancelled.") + sys.exit(0) + install_transactions.run_upgrade_playbook() + @click.command() @click.option('--force', '-f', is_flag=True, default=False) @@ -523,6 +543,7 @@ http://docs.openshift.com/enterprise/latest/admin_guide/overview.html click.pause() cli.add_command(install) +cli.add_command(upgrade) cli.add_command(uninstall) if __name__ == '__main__': diff --git a/utils/src/ooinstall/install_transactions.py b/utils/src/ooinstall/install_transactions.py index 3306271c8..60b0f3d9f 100644 --- a/utils/src/ooinstall/install_transactions.py +++ b/utils/src/ooinstall/install_transactions.py @@ -143,3 +143,15 @@ def run_uninstall_playbook(): if 'ansible_config' in CFG.settings: facts_env['ANSIBLE_CONFIG'] = CFG.settings['ansible_config'] return run_ansible(playbook, inventory_file, facts_env) + +def run_upgrade_playbook(): + playbook = os.path.join(CFG.settings['ansible_playbook_directory'], + 'playbooks/adhoc/upgrades/upgrade.yml') + # TODO: Upgrade inventory for upgrade? + inventory_file = generate_inventory(CFG.hosts) + facts_env = os.environ.copy() + if 'ansible_log_path' in CFG.settings: + facts_env['ANSIBLE_LOG_PATH'] = CFG.settings['ansible_log_path'] + if 'ansible_config' in CFG.settings: + facts_env['ANSIBLE_CONFIG'] = CFG.settings['ansible_config'] + return run_ansible(playbook, inventory_file, facts_env) -- cgit v1.2.3 From 3d7c5c6fd545112d87fa09e4a8c3f3cbc1cda1ee Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 28 Oct 2015 15:29:52 -0300 Subject: First cut at checking available disk space for etcd backup. --- utils/src/ooinstall/cli_installer.py | 15 ++++++++++++++- utils/src/ooinstall/install_transactions.py | 1 - utils/src/ooinstall/variants.py | 5 ++++- 3 files changed, 18 insertions(+), 3 deletions(-) (limited to 'utils/src') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index e22217fdb..daac5e388 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -191,7 +191,7 @@ Notes: facts_confirmed = click.confirm("Do the above facts look correct?") if not facts_confirmed: message = """ -Edit %s with the desired values and rerun oo-install with --unattended . +Edit %s with the desired values and re-run with --unattended . """ % oo_cfg.config_path click.echo(message) # Make sure we actually write out the config file. @@ -477,6 +477,19 @@ def upgrade(ctx): if not proceed: click.echo("Upgrade cancelled.") sys.exit(0) + + # 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' + variant, version = find_variant(oo_cfg.settings['variant']) + oo_cfg.settings['variant_version'] = version.name + click.echo("Upgrading from %s %s to %s %s" % ( + old_variant, old_version, oo_cfg.settings['variant'], + oo_cfg.settings['variant_version'])) + install_transactions.run_upgrade_playbook() diff --git a/utils/src/ooinstall/install_transactions.py b/utils/src/ooinstall/install_transactions.py index 60b0f3d9f..1d1dbe340 100644 --- a/utils/src/ooinstall/install_transactions.py +++ b/utils/src/ooinstall/install_transactions.py @@ -14,7 +14,6 @@ def set_config(cfg): CFG = cfg def generate_inventory(hosts): - print hosts global CFG base_inventory_path = CFG.settings['ansible_inventory_path'] base_inventory = open(base_inventory_path, 'w') diff --git a/utils/src/ooinstall/variants.py b/utils/src/ooinstall/variants.py index ed98429fc..219af6cd2 100644 --- a/utils/src/ooinstall/variants.py +++ b/utils/src/ooinstall/variants.py @@ -29,6 +29,9 @@ class Variant(object): self.versions = versions + def latest_version(self): + return self.versions[-1] + # WARNING: Keep the versions ordered, most recent last: OSE = Variant('openshift-enterprise', 'OpenShift Enterprise', @@ -58,7 +61,7 @@ def find_variant(name, version=None): for prod in SUPPORTED_VARIANTS: if prod.name == name: if version is None: - return (prod, prod.versions[-1]) + return (prod, prod.latest_version()) for v in prod.versions: if v.name == version: return (prod, v) -- cgit v1.2.3 From 7063a66354faebe143124ff275cbe04a56c03237 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 2 Nov 2015 09:27:06 -0400 Subject: Automatically upgrade legacy config files. --- utils/src/ooinstall/oo_config.py | 41 ++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) (limited to 'utils/src') diff --git a/utils/src/ooinstall/oo_config.py b/utils/src/ooinstall/oo_config.py index a2f53cf78..aa63180b5 100644 --- a/utils/src/ooinstall/oo_config.py +++ b/utils/src/ooinstall/oo_config.py @@ -73,7 +73,6 @@ class Host(object): class OOConfig(object): - new_config = True default_dir = os.path.normpath( os.environ.get('XDG_CONFIG_HOME', os.environ['HOME'] + '/.config/') + '/openshift/') @@ -86,19 +85,22 @@ class OOConfig(object): self.config_path = os.path.normpath(self.default_dir + self.default_file) self.settings = {} - self.read_config() - self.set_defaults() + self._read_config() + self._set_defaults() - def read_config(self, is_new=False): + def _read_config(self): self.hosts = [] try: - new_settings = None if os.path.exists(self.config_path): cfgfile = open(self.config_path, 'r') - new_settings = yaml.safe_load(cfgfile.read()) + self.settings = yaml.safe_load(cfgfile.read()) cfgfile.close() - if new_settings: - self.settings = new_settings + + # Use the presence of a Description as an indicator this is + # a legacy config file: + if 'Description' in self.settings: + self._upgrade_legacy_config() + # Parse the hosts into DTO objects: if 'hosts' in self.settings: for host in self.settings['hosts']: @@ -114,9 +116,28 @@ class OOConfig(object): ferr.strerror)) except yaml.scanner.ScannerError: raise OOConfigFileError('Config file "{}" is not a valid YAML document'.format(self.config_path)) - self.new_config = is_new - def set_defaults(self): + def _upgrade_legacy_config(self): + new_hosts = [] + if 'validated_facts' in self.settings: + for key, value in self.settings['validated_facts'].iteritems(): + if 'masters' in self.settings and key in self.settings['masters']: + value['master'] = True + if 'nodes' in self.settings and key in self.settings['nodes']: + value['node'] = True + new_hosts.append(value) + self.settings['hosts'] = new_hosts + + remove_settings = ['validated_facts', 'Description', 'Name', + 'Subscription', 'Vendor', 'Version', 'masters', 'nodes'] + for s in remove_settings: + del self.settings[s] + + # A legacy config implies openshift-enterprise 3.0: + self.settings['variant'] = 'openshift-enterprise' + self.settings['variant_version'] = '3.0' + + def _set_defaults(self): if 'ansible_inventory_directory' not in self.settings: self.settings['ansible_inventory_directory'] = \ -- cgit v1.2.3 From 1ddfdd136f4b22368c87ad7656faa0cccdfa4a25 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 2 Nov 2015 10:10:46 -0400 Subject: Print info after upgrade completes. --- utils/src/ooinstall/cli_installer.py | 7 ++++++- utils/src/ooinstall/install_transactions.py | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'utils/src') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index daac5e388..978259f79 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -490,7 +490,12 @@ def upgrade(ctx): old_variant, old_version, oo_cfg.settings['variant'], oo_cfg.settings['variant_version'])) - install_transactions.run_upgrade_playbook() + retcode = install_transactions.run_upgrade_playbook() + if retcode > 0: + click.echo("Errors encountered during upgrade, please check %s." % + oo_cfg.settings['ansible_log_path']) + else: + click.echo("Upgrade completed! Rebooting all hosts is recommended.") @click.command() diff --git a/utils/src/ooinstall/install_transactions.py b/utils/src/ooinstall/install_transactions.py index 1d1dbe340..0754b8ab6 100644 --- a/utils/src/ooinstall/install_transactions.py +++ b/utils/src/ooinstall/install_transactions.py @@ -143,6 +143,7 @@ def run_uninstall_playbook(): facts_env['ANSIBLE_CONFIG'] = CFG.settings['ansible_config'] return run_ansible(playbook, inventory_file, facts_env) + def run_upgrade_playbook(): playbook = os.path.join(CFG.settings['ansible_playbook_directory'], 'playbooks/adhoc/upgrades/upgrade.yml') @@ -154,3 +155,4 @@ def run_upgrade_playbook(): if 'ansible_config' in CFG.settings: facts_env['ANSIBLE_CONFIG'] = CFG.settings['ansible_config'] return run_ansible(playbook, inventory_file, facts_env) + -- cgit v1.2.3 From ef6b36d14a00757754aaf001a8acad8354cf62ff Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 2 Nov 2015 15:17:47 -0400 Subject: Better info prior to initiating upgrade. --- utils/src/ooinstall/cli_installer.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'utils/src') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index 978259f79..c39eb5cac 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -468,16 +468,6 @@ def upgrade(ctx): click.echo("No hosts defined in: %s" % oo_cfg['configuration']) sys.exit(1) - click.echo("OpenShift will be upgraded on the following hosts:\n") - if not ctx.obj['unattended']: - # Prompt interactively to confirm: - for host in oo_cfg.hosts: - click.echo(" * %s" % host.name) - proceed = click.confirm("\nDo you wish to proceed?") - if not proceed: - click.echo("Upgrade cancelled.") - sys.exit(0) - # 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'] @@ -486,9 +476,18 @@ def upgrade(ctx): oo_cfg.settings['variant'] = 'openshift-enterprise' variant, version = find_variant(oo_cfg.settings['variant']) oo_cfg.settings['variant_version'] = version.name - click.echo("Upgrading from %s %s to %s %s" % ( + 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'])) + for host in oo_cfg.hosts: + click.echo(" * %s" % host.name) + + if not ctx.obj['unattended']: + # Prompt interactively to confirm: + proceed = click.confirm("\nDo you wish to proceed?") + if not proceed: + click.echo("Upgrade cancelled.") + sys.exit(0) retcode = install_transactions.run_upgrade_playbook() if retcode > 0: -- cgit v1.2.3 From 39250a47afca63ef0b5a73158a2c9b15443a4235 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 3 Nov 2015 08:27:26 -0400 Subject: Pylint fix. --- utils/src/ooinstall/cli_installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/src') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index c39eb5cac..21e50de6d 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -474,7 +474,7 @@ def upgrade(ctx): old_version = oo_cfg.settings['variant_version'] if oo_cfg.settings['variant'] == 'enterprise': oo_cfg.settings['variant'] = 'openshift-enterprise' - variant, version = find_variant(oo_cfg.settings['variant']) + version = find_variant(oo_cfg.settings['variant'])[0] oo_cfg.settings['variant_version'] = version.name 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'], -- cgit v1.2.3 From f91c0cac0b6e671d5ad70543054a17178c5f0a46 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 3 Nov 2015 08:37:31 -0400 Subject: Add a simple version for the installer config file. --- utils/src/ooinstall/oo_config.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'utils/src') diff --git a/utils/src/ooinstall/oo_config.py b/utils/src/ooinstall/oo_config.py index aa63180b5..4281947f1 100644 --- a/utils/src/ooinstall/oo_config.py +++ b/utils/src/ooinstall/oo_config.py @@ -12,6 +12,7 @@ PERSIST_SETTINGS = [ 'ansible_log_path', 'variant', 'variant_version', + 'version', ] REQUIRED_FACTS = ['ip', 'public_ip', 'hostname', 'public_hostname'] @@ -146,6 +147,8 @@ class OOConfig(object): 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') + if 'version' not in self.settings: + self.settings['version'] = 'v1' if 'ansible_callback_facts_yaml' not in self.settings: self.settings['ansible_callback_facts_yaml'] = '%s/callback_facts.yaml' % \ -- cgit v1.2.3 From ab83e16dbed3eb5cf1dff96992509439d2739550 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 3 Nov 2015 09:51:10 -0400 Subject: Fix installer upgrade bug following pylint fix. --- utils/src/ooinstall/cli_installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/src') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index 21e50de6d..2fc7a872f 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -474,7 +474,7 @@ def upgrade(ctx): 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'])[0] + version = find_variant(oo_cfg.settings['variant'])[1] oo_cfg.settings['variant_version'] = version.name 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'], -- cgit v1.2.3 From 21f793b8aefcd680041150d0740eeed05d272c31 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 4 Nov 2015 09:13:39 -0400 Subject: Fix bug with default ansible playbook dir. --- utils/src/ooinstall/cli_installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/src') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index 25705ec7a..455f56a66 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -385,7 +385,7 @@ def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force): dir_okay=True, readable=True), # callback=validate_ansible_dir, - default='/usr/share/openshift-ansible/', + default=DEFAULT_PLAYBOOK_DIR, envvar='OO_ANSIBLE_PLAYBOOK_DIRECTORY') @click.option('--ansible-config', type=click.Path(file_okay=True, -- cgit v1.2.3 From 6b2644268ed1bbb1ff3f2fd85427aefef0e51e0f Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 4 Nov 2015 09:54:55 -0400 Subject: Fix bug from module rename. --- utils/src/ooinstall/cli_installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/src') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index 455f56a66..e4fda2813 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -489,7 +489,7 @@ def upgrade(ctx): click.echo("Upgrade cancelled.") sys.exit(0) - retcode = install_transactions.run_upgrade_playbook() + retcode = openshift_ansible.run_upgrade_playbook() if retcode > 0: click.echo("Errors encountered during upgrade, please check %s." % oo_cfg.settings['ansible_log_path']) -- cgit v1.2.3 From 215a7aacc2fc3df19a64a2a57910516533665423 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 4 Nov 2015 10:41:39 -0400 Subject: Fix bug with not upgrading openshift-master to atomic-openshift-master. Removing the full call to config resulted in rpms not getting upgraded. Config was doing a yum update of everything, which picks up the atomic-openshift-master obsoleting openshift-master. The actual yum call changed here would not. Instead we switch to a direct call to yum which correctly picks up the obsoletes and updates to atomic-openshift packages. --- utils/src/ooinstall/openshift_ansible.py | 1 + 1 file changed, 1 insertion(+) (limited to 'utils/src') diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py index 9d801cabe..e33330102 100644 --- a/utils/src/ooinstall/openshift_ansible.py +++ b/utils/src/ooinstall/openshift_ansible.py @@ -144,6 +144,7 @@ def run_ansible(playbook, inventory, env_vars): playbook], env=env_vars) + def run_uninstall_playbook(): playbook = os.path.join(CFG.settings['ansible_playbook_directory'], 'playbooks/adhoc/uninstall.yml') -- cgit v1.2.3 From 82b4209c02c27ab0e9a6d9c016ff06d12f42a9c1 Mon Sep 17 00:00:00 2001 From: Brenton Leanhardt Date: Thu, 5 Nov 2015 08:41:51 -0500 Subject: Bug 1274201 - Fixing sudo non-interactive test https://bugzilla.redhat.com/show_bug.cgi?id=1274201#c13 --- utils/src/ooinstall/openshift_ansible.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/src') diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py index e33330102..bdb9859a2 100644 --- a/utils/src/ooinstall/openshift_ansible.py +++ b/utils/src/ooinstall/openshift_ansible.py @@ -46,7 +46,7 @@ def generate_inventory(hosts): if any(host.hostname == installer_host or host.public_hostname == installer_host for host in hosts): - no_pwd_sudo = subprocess.call(['sudo', '-v', '--non-interactive']) + no_pwd_sudo = subprocess.call(['sudo', '-v', '-n']) if no_pwd_sudo == 1: print 'The atomic-openshift-installer requires sudo access without a password.' sys.exit(1) -- cgit v1.2.3 From cfca7b9f7894e2b427ae0753477cd13cc537e348 Mon Sep 17 00:00:00 2001 From: Brenton Leanhardt Date: Thu, 5 Nov 2015 09:14:33 -0500 Subject: Bug 1274201 - Fixing non-root installations if using a local connection Previously we were writing out a inventory like this: ~~~ [OSEv3:children] masters nodes [OSEv3:vars] ansible_ssh_user=root deployment_type=openshift-enterprise ansible_connection=local [masters] ose3-master.example.com openshift_hostname=ose3-master.example.com [nodes] ose3-master.example.com openshift_hostname=ose3-master.example.com ose3-node1.example.com openshift_hostname=ose3-node1.example.com ose3-node2.example.com openshift_hostname=ose3-node2.example.com ~~~ The problem with that is now all the hosts are consider local connections. In addition our sudo check wasn't working as expected. We would check that we have sudo, but the playbooks were not running with root privileges. When gathering facts you'd hit: ~~~ __main__.OpenShiftFactsFileWriteError: Could not create fact file: /etc/ansible/facts.d/openshift.fact, error: [Errno 13] Permission denied: '/etc/ansible/facts.d/openshift.fact' ~~~ Instead the test for locale connections needs to be per host. Anytime we're not running as root we need `ansible_become` set: ~~~ ose3-master.example.com openshift_hostname=ose3-master.example.com ansible_connection=local ansible_become=true ~~~ --- utils/src/ooinstall/openshift_ansible.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'utils/src') diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py index bdb9859a2..4b37be278 100644 --- a/utils/src/ooinstall/openshift_ansible.py +++ b/utils/src/ooinstall/openshift_ansible.py @@ -18,7 +18,6 @@ def set_config(cfg): def generate_inventory(hosts): global CFG - installer_host = socket.gethostname() base_inventory_path = CFG.settings['ansible_inventory_path'] base_inventory = open(base_inventory_path, 'w') base_inventory.write('\n[OSEv3:children]\nmasters\nnodes\n') @@ -44,14 +43,6 @@ def generate_inventory(hosts): if 'OO_INSTALL_STAGE_REGISTRY' in os.environ: base_inventory.write('oreg_url=registry.access.stage.redhat.com/openshift3/ose-${component}:${version}\n') - if any(host.hostname == installer_host or host.public_hostname == installer_host - for host in hosts): - no_pwd_sudo = subprocess.call(['sudo', '-v', '-n']) - if no_pwd_sudo == 1: - print 'The atomic-openshift-installer requires sudo access without a password.' - sys.exit(1) - base_inventory.write("ansible_connection=local\n") - base_inventory.write('\n[masters]\n') masters = (host for host in hosts if host.master) for master in masters: @@ -72,6 +63,7 @@ def generate_inventory(hosts): def write_host(host, inventory, scheduleable=True): global CFG + facts = '' if host.ip: facts += ' openshift_ip={}'.format(host.ip) @@ -85,6 +77,16 @@ def write_host(host, inventory, scheduleable=True): # Technically only nodes will ever need this. if not scheduleable: facts += ' openshift_scheduleable=False' + installer_host = socket.gethostname() + if host.hostname == installer_host or host.public_hostname == installer_host: + facts += ' ansible_connection=local' + if os.geteuid() != 0: + no_pwd_sudo = subprocess.call(['sudo', '-v', '-n']) + if no_pwd_sudo == 1: + print 'The atomic-openshift-installer requires sudo access without a password.' + sys.exit(1) + facts += ' ansible_become=true' + inventory.write('{} {}\n'.format(host, facts)) -- cgit v1.2.3 From dcd2fb0558c58fb79f9e3dd9ecd5f6687d8bed5d Mon Sep 17 00:00:00 2001 From: Brenton Leanhardt Date: Thu, 5 Nov 2015 09:47:50 -0500 Subject: Making it easier to use pre-release content --- utils/src/ooinstall/openshift_ansible.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'utils/src') diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py index 4b37be278..0648df0fa 100644 --- a/utils/src/ooinstall/openshift_ansible.py +++ b/utils/src/ooinstall/openshift_ansible.py @@ -31,17 +31,18 @@ def generate_inventory(hosts): version=CFG.settings.get('variant_version', None))[1] base_inventory.write('deployment_type={}\n'.format(ver.ansible_key)) - if 'OO_INSTALL_DEVEL_REGISTRY' in os.environ: - base_inventory.write('oreg_url=rcm-img-docker01.build.eng.bos.redhat.com:' - '5001/openshift3/ose-${component}:${version}\n') - if 'OO_INSTALL_PUDDLE_REPO_ENABLE' in os.environ: - base_inventory.write("openshift_additional_repos=[{'id': 'ose-devel', " + if 'OO_INSTALL_ADDITIONAL_REGISTRIES' in os.environ: + base_inventory.write('cli_docker_additional_registries={}\n' + .format(os.environ['OO_INSTALL_ADDITIONAL_REGISTRIES'])) + if 'OO_INSTALL_INSECURE_REGISTRIES' in os.environ: + base_inventory.write('cli_docker_insecure_registries={}\n' + .format(os.environ['OO_INSTALL_INSECURE_REGISTRIES'])) + if 'OO_INSTALL_PUDDLE_REPO' in os.environ: + # We have to double the '{' here for literals + base_inventory.write("openshift_additional_repos=[{{'id': 'ose-devel', " "'name': 'ose-devel', " - "'baseurl': 'http://buildvm-devops.usersys.redhat.com" - "/puddle/build/AtomicOpenShift/3.1/latest/RH7-RHAOS-3.1/$basearch/os', " - "'enabled': 1, 'gpgcheck': 0}]\n") - if 'OO_INSTALL_STAGE_REGISTRY' in os.environ: - base_inventory.write('oreg_url=registry.access.stage.redhat.com/openshift3/ose-${component}:${version}\n') + "'baseurl': '{}', " + "'enabled': 1, 'gpgcheck': 0}}]\n".format(os.environ['OO_INSTALL_PUDDLE_REPO'])) base_inventory.write('\n[masters]\n') masters = (host for host in hosts if host.master) -- cgit v1.2.3 From ae7757195a4230b561b14353a7024d964b5d9664 Mon Sep 17 00:00:00 2001 From: Brenton Leanhardt Date: Thu, 5 Nov 2015 12:49:42 -0500 Subject: atomic-openshift-installer's unattended mode wasn't work with --force for all cases --- utils/src/ooinstall/cli_installer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'utils/src') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index e4fda2813..f675efead 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -339,7 +339,10 @@ def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force): # new nodes. elif host.node: click.echo("{} is already an OpenShift Node".format(host)) - hosts_to_run_on.remove(host) + # force is only used for reinstalls so we don't want to remove + # anything. + if not force: + hosts_to_run_on.remove(host) # for unattended either continue if they force install or exit if they didn't if unattended: if not force: -- cgit v1.2.3 From a552645b05d4af2180596fb01837d0f1062b3ac5 Mon Sep 17 00:00:00 2001 From: Brenton Leanhardt Date: Thu, 5 Nov 2015 13:11:42 -0500 Subject: Bug 1278244 - Incorrect node information gathered by atomic-openshift-installer Previously the output was a little confusing. We didn't display anything about the uninstalled hosts. --- utils/src/ooinstall/cli_installer.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'utils/src') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index f675efead..ff740e426 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -343,6 +343,8 @@ def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force): # anything. if not force: hosts_to_run_on.remove(host) + for new_host in set(hosts_to_run_on) - set(installed_hosts): + click.echo("{} is currently uninstalled".format(new_host)) # for unattended either continue if they force install or exit if they didn't if unattended: if not force: -- cgit v1.2.3 From 837ea49bba342aa1fa87736947979ee5235da727 Mon Sep 17 00:00:00 2001 From: Brenton Leanhardt Date: Thu, 5 Nov 2015 13:37:51 -0500 Subject: Bug 1278244 - Previously there was no way to add a node in unattended mode TODO: We desparately need tests cases for: - interactive with no config file - interactive with config file and all installed hosts - interactive with config file and no installed hosts - interactive with config file and some installed some uninstalled hosts - unattended with config file and all installed hosts (with and without --force) - unattended with config file and no installed hosts (with and without --force) - unattended with config file and some installed some uninstalled hosts (with and without --force) --- utils/src/ooinstall/cli_installer.py | 69 +++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 25 deletions(-) (limited to 'utils/src') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index ff740e426..9bf3bc714 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -331,7 +331,22 @@ def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force): # Check if master or nodes already have something installed installed_hosts = get_installed_hosts(oo_cfg.hosts, callback_facts) if len(installed_hosts) > 0: - # present a message listing already installed hosts + click.echo('Installed environment detected.') + # This check has to happen before we start removing hosts later in this method + if not force: + if not unattended: + click.echo('By default the installer only adds new nodes to an installed environment.') + response = click.prompt('Do you want to (1) only add additional nodes or ' \ + '(2) perform a clean install?', type=int) + # TODO: this should be reworked with error handling. + # Click can certainly do this for us. + # This should be refactored as soon as we add a 3rd option. + if response == 1: + force = False + if response == 2: + force = True + + # present a message listing already installed hosts and remove hosts if needed for host in installed_hosts: if host.master: click.echo("{} is already an OpenShift Master".format(host)) @@ -343,33 +358,37 @@ def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force): # anything. if not force: hosts_to_run_on.remove(host) - for new_host in set(hosts_to_run_on) - set(installed_hosts): - click.echo("{} is currently uninstalled".format(new_host)) - # for unattended either continue if they force install or exit if they didn't - if unattended: - if not force: - click.echo('Installed environment detected and no additional nodes specified: ' \ - 'aborting. If you want a fresh install, use --force') - sys.exit(1) - # for attended ask the user what to do + + # Handle the cases where we know about uninstalled systems + new_hosts = set(hosts_to_run_on) - set(installed_hosts) + if len(new_hosts) > 0: + for new_host in new_hosts: + click.echo("{} is currently uninstalled".format(new_host)) + + # Fall through + click.echo('Adding additional nodes...') else: - click.echo('Installed environment detected and no additional nodes specified. ') - response = click.prompt('Do you want to (1) add more nodes or ' \ - '(2) perform a clean install?', type=int) - if response == 1: # add more nodes - new_nodes = collect_new_nodes() - - hosts_to_run_on.extend(new_nodes) - oo_cfg.hosts.extend(new_nodes) - - openshift_ansible.set_config(oo_cfg) - callback_facts, error = openshift_ansible.default_facts(oo_cfg.hosts) - if error: - click.echo("There was a problem fetching the required information. " \ - "See {} for details.".format(oo_cfg.settings['ansible_log_path'])) + if unattended: + if not force: + click.echo('Installed environment detected and no additional nodes specified: ' \ + 'aborting. If you want a fresh install, use --force') sys.exit(1) else: - pass # proceeding as normal should do a clean install + if not force: + new_nodes = collect_new_nodes() + + hosts_to_run_on.extend(new_nodes) + oo_cfg.hosts.extend(new_nodes) + + openshift_ansible.set_config(oo_cfg) + click.echo('Gathering information from hosts...') + callback_facts, error = openshift_ansible.default_facts(oo_cfg.hosts) + if error: + click.echo("There was a problem fetching the required information. " \ + "See {} for details.".format(oo_cfg.settings['ansible_log_path'])) + sys.exit(1) + else: + pass # proceeding as normal should do a clean install return hosts_to_run_on, callback_facts -- cgit v1.2.3 From a2d19f85a1e501cf7be64236b851eda898f3f51b Mon Sep 17 00:00:00 2001 From: Brenton Leanhardt Date: Thu, 5 Nov 2015 15:33:33 -0500 Subject: Bug 1278243 - Confusing prompt from atomic-openshift-installer --- utils/src/ooinstall/cli_installer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'utils/src') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index 9bf3bc714..8bee99f90 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -371,7 +371,8 @@ def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force): if unattended: if not force: click.echo('Installed environment detected and no additional nodes specified: ' \ - 'aborting. If you want a fresh install, use --force') + 'aborting. If you want a fresh install, use ' \ + '`atomic-openshift-installer install --force`') sys.exit(1) else: if not force: -- cgit v1.2.3 From fe4e9a4ca7028aa877fdd3895225a67b026aea11 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Thu, 5 Nov 2015 08:35:53 -0400 Subject: Upgrade improvements - Push config dir logic out of module and use host variables instead. - Backup master config with ansible utility. - Add error handling for the upgrade config module. - Add verbose option to installer. - Return details on what we changed when upgrading config. - Cleanup use of first master. - Don't install upgrade rpms to check what version we'll upgrade to. --- utils/src/ooinstall/cli_installer.py | 22 +++++++++++------ utils/src/ooinstall/openshift_ansible.py | 41 +++++++++++++++++--------------- 2 files changed, 37 insertions(+), 26 deletions(-) (limited to 'utils/src') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index 8bee99f90..9f0861b77 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -323,7 +323,7 @@ def get_installed_hosts(hosts, callback_facts): installed_hosts.append(host) return installed_hosts -def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force): +def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force, verbose): # Copy the list of existing hosts so we can remove any already installed nodes. hosts_to_run_on = list(oo_cfg.hosts) @@ -424,9 +424,11 @@ def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force): writable=True, readable=True), default="/tmp/ansible.log") +@click.option('-v', '--verbose', + is_flag=True, default=False) #pylint: disable=too-many-arguments # Main CLI entrypoint, not much we can do about too many arguments. -def cli(ctx, unattended, configuration, ansible_playbook_directory, ansible_config, ansible_log_path): +def cli(ctx, unattended, configuration, ansible_playbook_directory, ansible_config, ansible_log_path, verbose): """ The main click CLI module. Responsible for handling most common CLI options, assigning any defaults and adding to the context for the sub-commands. @@ -436,6 +438,7 @@ def cli(ctx, unattended, configuration, ansible_playbook_directory, ansible_conf ctx.obj['configuration'] = configuration ctx.obj['ansible_config'] = ansible_config ctx.obj['ansible_log_path'] = ansible_log_path + ctx.obj['verbose'] = verbose oo_cfg = OOConfig(ctx.obj['configuration']) @@ -466,6 +469,7 @@ def cli(ctx, unattended, configuration, ansible_playbook_directory, ansible_conf @click.pass_context def uninstall(ctx): oo_cfg = ctx.obj['oo_cfg'] + verbose = ctx.obj['verbose'] if len(oo_cfg.hosts) == 0: click.echo("No hosts defined in: %s" % oo_cfg['configuration']) @@ -481,13 +485,14 @@ def uninstall(ctx): click.echo("Uninstall cancelled.") sys.exit(0) - openshift_ansible.run_uninstall_playbook() + openshift_ansible.run_uninstall_playbook(verbose) @click.command() @click.pass_context def upgrade(ctx): oo_cfg = ctx.obj['oo_cfg'] + verbose = ctx.obj['verbose'] if len(oo_cfg.hosts) == 0: click.echo("No hosts defined in: %s" % oo_cfg['configuration']) @@ -514,7 +519,7 @@ def upgrade(ctx): click.echo("Upgrade cancelled.") sys.exit(0) - retcode = openshift_ansible.run_upgrade_playbook() + retcode = openshift_ansible.run_upgrade_playbook(verbose) if retcode > 0: click.echo("Errors encountered during upgrade, please check %s." % oo_cfg.settings['ansible_log_path']) @@ -527,6 +532,7 @@ def upgrade(ctx): @click.pass_context def install(ctx, force): oo_cfg = ctx.obj['oo_cfg'] + verbose = ctx.obj['verbose'] if ctx.obj['unattended']: error_if_missing_info(oo_cfg) @@ -534,13 +540,15 @@ def install(ctx, force): oo_cfg = get_missing_info_from_user(oo_cfg) click.echo('Gathering information from hosts...') - callback_facts, error = openshift_ansible.default_facts(oo_cfg.hosts) + callback_facts, error = openshift_ansible.default_facts(oo_cfg.hosts, + verbose) if error: click.echo("There was a problem fetching the required information. " \ "Please see {} for details.".format(oo_cfg.settings['ansible_log_path'])) sys.exit(1) - hosts_to_run_on, callback_facts = get_hosts_to_run_on(oo_cfg, callback_facts, ctx.obj['unattended'], force) + hosts_to_run_on, callback_facts = get_hosts_to_run_on( + oo_cfg, callback_facts, ctx.obj['unattended'], force, verbose) click.echo('Writing config to: %s' % oo_cfg.config_path) @@ -562,7 +570,7 @@ If changes are needed to the values recorded by the installer please update {}. confirm_continue(message) error = openshift_ansible.run_main_playbook(oo_cfg.hosts, - hosts_to_run_on) + hosts_to_run_on, verbose) if error: # The bootstrap script will print out the log location. message = """ diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py index 0648df0fa..153415e8c 100644 --- a/utils/src/ooinstall/openshift_ansible.py +++ b/utils/src/ooinstall/openshift_ansible.py @@ -91,16 +91,17 @@ def write_host(host, inventory, scheduleable=True): inventory.write('{} {}\n'.format(host, facts)) -def load_system_facts(inventory_file, os_facts_path, env_vars): +def load_system_facts(inventory_file, os_facts_path, env_vars, verbose=False): """ Retrieves system facts from the remote systems. """ FNULL = open(os.devnull, 'w') - status = subprocess.call(['ansible-playbook', - '--inventory-file={}'.format(inventory_file), - os_facts_path], - env=env_vars, - stdout=FNULL) + args = ['ansible-playbook', '-v'] if verbose \ + else ['ansible-playbook'] + args.extend([ + '--inventory-file={}'.format(inventory_file), + os_facts_path]) + status = subprocess.call(args, env=env_vars, stdout=FNULL) if not status == 0: return [], 1 callback_facts_file = open(CFG.settings['ansible_callback_facts_yaml'], 'r') @@ -109,7 +110,7 @@ def load_system_facts(inventory_file, os_facts_path, env_vars): return callback_facts, 0 -def default_facts(hosts): +def default_facts(hosts, verbose=False): global CFG inventory_file = generate_inventory(hosts) os_facts_path = '{}/playbooks/byo/openshift_facts.yml'.format(CFG.ansible_playbook_directory) @@ -121,10 +122,10 @@ def default_facts(hosts): facts_env["ANSIBLE_LOG_PATH"] = CFG.settings['ansible_log_path'] if 'ansible_config' in CFG.settings: facts_env['ANSIBLE_CONFIG'] = CFG.settings['ansible_config'] - return load_system_facts(inventory_file, os_facts_path, facts_env) + return load_system_facts(inventory_file, os_facts_path, facts_env, verbose) -def run_main_playbook(hosts, hosts_to_run_on): +def run_main_playbook(hosts, hosts_to_run_on, verbose=False): global CFG inventory_file = generate_inventory(hosts) if len(hosts_to_run_on) != len(hosts): @@ -138,17 +139,19 @@ def run_main_playbook(hosts, hosts_to_run_on): facts_env['ANSIBLE_LOG_PATH'] = CFG.settings['ansible_log_path'] if 'ansible_config' in CFG.settings: facts_env['ANSIBLE_CONFIG'] = CFG.settings['ansible_config'] - return run_ansible(main_playbook_path, inventory_file, facts_env) + return run_ansible(main_playbook_path, inventory_file, facts_env, verbose) -def run_ansible(playbook, inventory, env_vars): - return subprocess.call(['ansible-playbook', - '--inventory-file={}'.format(inventory), - playbook], - env=env_vars) +def run_ansible(playbook, inventory, env_vars, verbose=False): + args = ['ansible-playbook', '-v'] if verbose \ + else ['ansible-playbook'] + args.extend([ + '--inventory-file={}'.format(inventory), + playbook]) + return subprocess.call(args, env=env_vars) -def run_uninstall_playbook(): +def run_uninstall_playbook(verbose=False): playbook = os.path.join(CFG.settings['ansible_playbook_directory'], 'playbooks/adhoc/uninstall.yml') inventory_file = generate_inventory(CFG.hosts) @@ -157,10 +160,10 @@ def run_uninstall_playbook(): facts_env['ANSIBLE_LOG_PATH'] = CFG.settings['ansible_log_path'] if 'ansible_config' in CFG.settings: facts_env['ANSIBLE_CONFIG'] = CFG.settings['ansible_config'] - return run_ansible(playbook, inventory_file, facts_env) + return run_ansible(playbook, inventory_file, facts_env, verbose) -def run_upgrade_playbook(): +def run_upgrade_playbook(verbose=False): playbook = os.path.join(CFG.settings['ansible_playbook_directory'], 'playbooks/adhoc/upgrades/upgrade.yml') # TODO: Upgrade inventory for upgrade? @@ -170,5 +173,5 @@ def run_upgrade_playbook(): facts_env['ANSIBLE_LOG_PATH'] = CFG.settings['ansible_log_path'] if 'ansible_config' in CFG.settings: facts_env['ANSIBLE_CONFIG'] = CFG.settings['ansible_config'] - return run_ansible(playbook, inventory_file, facts_env) + return run_ansible(playbook, inventory_file, facts_env, verbose) -- cgit v1.2.3 From 98b69946496d0b214c5bd0d384e1cea0856c4cbb Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Fri, 6 Nov 2015 11:43:25 -0400 Subject: Fix pylint errors with getting hosts to run on. --- utils/src/ooinstall/cli_installer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'utils/src') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index 9f0861b77..e63f14816 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -323,6 +323,8 @@ def get_installed_hosts(hosts, callback_facts): installed_hosts.append(host) return installed_hosts +# 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): # Copy the list of existing hosts so we can remove any already installed nodes. @@ -383,7 +385,7 @@ def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force, verbose): openshift_ansible.set_config(oo_cfg) click.echo('Gathering information from hosts...') - callback_facts, error = openshift_ansible.default_facts(oo_cfg.hosts) + callback_facts, error = openshift_ansible.default_facts(oo_cfg.hosts, verbose) if error: click.echo("There was a problem fetching the required information. " \ "See {} for details.".format(oo_cfg.settings['ansible_log_path'])) -- cgit v1.2.3 From 6955b11fbed1f3d73d814d610b4a6905331406e8 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Fri, 6 Nov 2015 11:52:56 -0400 Subject: Write new config to disk after successful upgrade. --- utils/src/ooinstall/cli_installer.py | 1 + 1 file changed, 1 insertion(+) (limited to 'utils/src') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index e63f14816..0d65f2053 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -526,6 +526,7 @@ def upgrade(ctx): click.echo("Errors encountered during upgrade, please check %s." % oo_cfg.settings['ansible_log_path']) else: + oo_cfg.save_to_disk() click.echo("Upgrade completed! Rebooting all hosts is recommended.") -- cgit v1.2.3 From eb136c6d84c762a2692ef62f0e15d4b98c723edf Mon Sep 17 00:00:00 2001 From: Samuel Munilla Date: Thu, 5 Nov 2015 13:28:24 -0500 Subject: atomic-openshift-installer: Better specification of ansible connection point Changes to installer.cfg.yaml to allow for better defaults in unattended mode. Update example in the docs. --- utils/src/ooinstall/cli_installer.py | 38 ++++++++++++++------------------ utils/src/ooinstall/oo_config.py | 22 ++++++++---------- utils/src/ooinstall/openshift_ansible.py | 2 +- 3 files changed, 26 insertions(+), 36 deletions(-) (limited to 'utils/src') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index 8bee99f90..8c2421183 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -101,18 +101,13 @@ http://docs.openshift.com/enterprise/latest/architecture/infrastructure_componen hosts = [] more_hosts = True - ip_regex = re.compile(r'^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$') - while more_hosts: host_props = {} hostname_or_ip = click.prompt('Enter hostname or IP address:', default='', value_proc=validate_prompt_hostname) - if ip_regex.match(hostname_or_ip): - host_props['ip'] = hostname_or_ip - else: - host_props['hostname'] = hostname_or_ip + host_props['connect_to'] = hostname_or_ip host_props['master'] = click.confirm('Will this host be an OpenShift Master?') host_props['node'] = True @@ -150,7 +145,7 @@ Plese confirm that they are correct before moving forward. notes = """ Format: -IP,public IP,hostname,public hostname +connect_to,IP,public IP,hostname,public hostname Notes: * The installation host is the hostname from the installer's perspective. @@ -168,16 +163,15 @@ Notes: default_facts_lines = [] default_facts = {} - validated_facts = {} for h in hosts: - default_facts[h] = {} - h.ip = callback_facts[str(h)]["common"]["ip"] - h.public_ip = callback_facts[str(h)]["common"]["public_ip"] - h.hostname = callback_facts[str(h)]["common"]["hostname"] - h.public_hostname = callback_facts[str(h)]["common"]["public_hostname"] - - validated_facts[h] = {} - default_facts_lines.append(",".join([h.ip, + 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"] + h.hostname = callback_facts[h.connect_to]["common"]["hostname"] + h.public_hostname = callback_facts[h.connect_to]["common"]["public_hostname"] + + default_facts_lines.append(",".join([h.connect_to, + h.ip, h.public_ip, h.hostname, h.public_hostname])) @@ -316,10 +310,10 @@ Add new nodes here def get_installed_hosts(hosts, callback_facts): installed_hosts = [] for host in hosts: - if(host.name in callback_facts.keys() - and 'common' in callback_facts[host.name].keys() - and callback_facts[host.name]['common'].get('version', '') - and callback_facts[host.name]['common'].get('version', '') != 'None'): + 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'): installed_hosts.append(host) return installed_hosts @@ -475,7 +469,7 @@ def uninstall(ctx): if not ctx.obj['unattended']: # Prompt interactively to confirm: for host in oo_cfg.hosts: - click.echo(" * %s" % host.name) + click.echo(" * %s" % host.connect_to) proceed = click.confirm("\nDo you wish to proceed?") if not proceed: click.echo("Uninstall cancelled.") @@ -505,7 +499,7 @@ def upgrade(ctx): old_variant, old_version, oo_cfg.settings['variant'], oo_cfg.settings['variant_version'])) for host in oo_cfg.hosts: - click.echo(" * %s" % host.name) + click.echo(" * %s" % host.connect_to) if not ctx.obj['unattended']: # Prompt interactively to confirm: diff --git a/utils/src/ooinstall/oo_config.py b/utils/src/ooinstall/oo_config.py index 4281947f1..f35a8f51b 100644 --- a/utils/src/ooinstall/oo_config.py +++ b/utils/src/ooinstall/oo_config.py @@ -35,6 +35,7 @@ class Host(object): self.hostname = kwargs.get('hostname', None) self.public_ip = kwargs.get('public_ip', None) self.public_hostname = kwargs.get('public_hostname', None) + self.connect_to = kwargs.get('connect_to', None) # Should this host run as an OpenShift master: self.master = kwargs.get('master', False) @@ -43,30 +44,25 @@ class Host(object): self.node = kwargs.get('node', False) self.containerized = kwargs.get('containerized', False) - if self.ip is None and self.hostname is None: - raise OOConfigInvalidHostError("You must specify either 'ip' or 'hostname'") + if self.connect_to is None: + raise OOConfigInvalidHostError("You must specify either and 'ip' " \ + "or 'hostname' to connect to.") if self.master is False and self.node is False: raise OOConfigInvalidHostError( "You must specify each host as either a master or a node.") - # Hosts can be specified with an ip, hostname, or both. However we need - # something authoritative we can connect to and refer to the host by. - # Preference given to the IP if specified as this is more specific. - # We know one must be set by this point. - self.name = self.ip if self.ip is not None else self.hostname - def __str__(self): - return self.name + return self.connect_to def __repr__(self): - return self.name + return self.connect_to def to_dict(self): """ Used when exporting to yaml. """ d = {} for prop in ['ip', 'hostname', 'public_ip', 'public_hostname', - 'master', 'node', 'containerized']: + 'master', 'node', 'containerized', 'connect_to']: # If the property is defined (not None or False), export it: if getattr(self, prop): d[prop] = getattr(self, prop) @@ -182,7 +178,7 @@ class OOConfig(object): if not getattr(host, required_fact): missing_facts.append(required_fact) if len(missing_facts) > 0: - result[host.name] = missing_facts + result[host.connect_to] = missing_facts return result def save_to_disk(self): @@ -214,6 +210,6 @@ class OOConfig(object): def get_host(self, name): for host in self.hosts: - if host.name == name: + if host.connect_to == name: return host return None diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py index 0648df0fa..d2399df5c 100644 --- a/utils/src/ooinstall/openshift_ansible.py +++ b/utils/src/ooinstall/openshift_ansible.py @@ -88,7 +88,7 @@ def write_host(host, inventory, scheduleable=True): sys.exit(1) facts += ' ansible_become=true' - inventory.write('{} {}\n'.format(host, facts)) + inventory.write('{} {}\n'.format(host.connect_to, facts)) def load_system_facts(inventory_file, os_facts_path, env_vars): -- cgit v1.2.3 From 0ab85bfb33a141d5b23ae85fd495cf7b487f99d4 Mon Sep 17 00:00:00 2001 From: Brenton Leanhardt Date: Fri, 6 Nov 2015 15:47:46 -0500 Subject: Updating the atomic-openshift-isntaller local connection logic for the connect_to addition. --- utils/src/ooinstall/openshift_ansible.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/src') diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py index d2399df5c..0b2000a0a 100644 --- a/utils/src/ooinstall/openshift_ansible.py +++ b/utils/src/ooinstall/openshift_ansible.py @@ -79,7 +79,7 @@ def write_host(host, inventory, scheduleable=True): if not scheduleable: facts += ' openshift_scheduleable=False' installer_host = socket.gethostname() - if host.hostname == installer_host or host.public_hostname == installer_host: + 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', '-v', '-n']) -- cgit v1.2.3 From 96464d04a5b88e7fb090b286b10838a183a2758a Mon Sep 17 00:00:00 2001 From: Brenton Leanhardt Date: Mon, 9 Nov 2015 10:38:07 -0500 Subject: Various fixes related to connect_to There the tests didn't know anything about connect_to and we had a case where we weren't handling the migration from the 3.0 installer config format to 3.1 --- utils/src/ooinstall/oo_config.py | 1 + 1 file changed, 1 insertion(+) (limited to 'utils/src') diff --git a/utils/src/ooinstall/oo_config.py b/utils/src/ooinstall/oo_config.py index f35a8f51b..cf51bb404 100644 --- a/utils/src/ooinstall/oo_config.py +++ b/utils/src/ooinstall/oo_config.py @@ -118,6 +118,7 @@ class OOConfig(object): new_hosts = [] if 'validated_facts' in self.settings: for key, value in self.settings['validated_facts'].iteritems(): + value['connect_to'] = key if 'masters' in self.settings and key in self.settings['masters']: value['master'] = True if 'nodes' in self.settings and key in self.settings['nodes']: -- cgit v1.2.3 From e109335a205a31a96611a5206947aa090a963241 Mon Sep 17 00:00:00 2001 From: Samuel Munilla Date: Mon, 9 Nov 2015 10:25:12 -0500 Subject: atomic-openshift-installer: Generate inventory off hosts_to_run_on This generates the ansible inventory based on the pruned list of non-installed hosts we've created rather than the full host list provided in installer.cfg.yaml --- utils/src/ooinstall/openshift_ansible.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/src') diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py index bac4951d5..489a0f7c1 100644 --- a/utils/src/ooinstall/openshift_ansible.py +++ b/utils/src/ooinstall/openshift_ansible.py @@ -127,7 +127,7 @@ def default_facts(hosts, verbose=False): def run_main_playbook(hosts, hosts_to_run_on, verbose=False): global CFG - inventory_file = generate_inventory(hosts) + 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/common/openshift-cluster/scaleup.yml') -- cgit v1.2.3 From c2f3f81d926aacbd1fe973c36931dc5ad2ebe7c5 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 10 Nov 2015 08:20:24 -0400 Subject: Package the default ansible.cfg with atomic-openshift-utils. If this file exists on disk, the installer will use it if the user didn't specify an ansible config file on the CLI. Rename share directory to match the rpm name. (utils vs util) --- utils/src/ooinstall/cli_installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/src') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index a40ff5cfc..08c2439f7 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -11,7 +11,7 @@ from ooinstall import OOConfig from ooinstall.oo_config import Host from ooinstall.variants import find_variant, get_variant_version_combos -DEFAULT_ANSIBLE_CONFIG = '/usr/share/atomic-openshift-util/ansible.cfg' +DEFAULT_ANSIBLE_CONFIG = '/usr/share/atomic-openshift-utils/ansible.cfg' DEFAULT_PLAYBOOK_DIR = '/usr/share/ansible/openshift-ansible/' def validate_ansible_dir(path): -- cgit v1.2.3 From 1e28190e374aac4677394bc9b8f3e8428b15dc5a Mon Sep 17 00:00:00 2001 From: Samuel Munilla Date: Tue, 10 Nov 2015 13:35:13 -0500 Subject: atomic-openshift-installer: Remove question for container install Removing the option for a container-based install from the quick installer with it is in tech preview. --- utils/src/ooinstall/cli_installer.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'utils/src') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index a40ff5cfc..3322a1e62 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -112,13 +112,15 @@ http://docs.openshift.com/enterprise/latest/architecture/infrastructure_componen host_props['master'] = click.confirm('Will this host be an OpenShift Master?') host_props['node'] = True - 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 - else: - host_props['containerized'] = False + #TODO: Reenable this option once container installs are out of tech preview + #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 + #else: + # host_props['containerized'] = False + host_props['containerized'] = False host = Host(**host_props) -- cgit v1.2.3 From 4c1b0dd4ab8f3a5d4fcfa4ba1501ed374793e77a Mon Sep 17 00:00:00 2001 From: Jason DeTiberus Date: Fri, 6 Nov 2015 16:56:37 -0500 Subject: Refactor upgrade playbook(s) - Split playbooks into two, one for 3.0 minor upgrades and one for 3.0 to 3.1 upgrades - Move upgrade playbooks to common/openshift/cluster/upgrades from adhoc - Added a byo wrapper playbooks to set the groups based on the byo conventions, other providers will need similar playbooks added eventually - installer wrapper updates for refactored upgrade playbooks - call new 3.0 to 3.1 upgrade playbook - various fixes for edge cases I hit with a really old config laying around. - fix output of host facts to show connect_to value. --- utils/src/ooinstall/cli_installer.py | 5 +++-- utils/src/ooinstall/oo_config.py | 8 +++++--- utils/src/ooinstall/openshift_ansible.py | 4 +++- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'utils/src') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index 4c55002fb..6cdc19f20 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -177,7 +177,8 @@ Notes: h.public_ip, h.hostname, h.public_hostname])) - output = "%s\n%s" % (output, ",".join([h.ip, + output = "%s\n%s" % (output, ",".join([h.connect_to, + h.ip, h.public_ip, h.hostname, h.public_hostname])) @@ -493,7 +494,7 @@ def upgrade(ctx): verbose = ctx.obj['verbose'] if len(oo_cfg.hosts) == 0: - click.echo("No hosts defined in: %s" % oo_cfg['configuration']) + 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 diff --git a/utils/src/ooinstall/oo_config.py b/utils/src/ooinstall/oo_config.py index cf51bb404..9c97e6e93 100644 --- a/utils/src/ooinstall/oo_config.py +++ b/utils/src/ooinstall/oo_config.py @@ -116,6 +116,9 @@ class OOConfig(object): def _upgrade_legacy_config(self): new_hosts = [] + remove_settings = ['validated_facts', 'Description', 'Name', + 'Subscription', 'Vendor', 'Version', 'masters', 'nodes'] + if 'validated_facts' in self.settings: for key, value in self.settings['validated_facts'].iteritems(): value['connect_to'] = key @@ -126,10 +129,9 @@ class OOConfig(object): new_hosts.append(value) self.settings['hosts'] = new_hosts - remove_settings = ['validated_facts', 'Description', 'Name', - 'Subscription', 'Vendor', 'Version', 'masters', 'nodes'] for s in remove_settings: - del self.settings[s] + if s in self.settings: + del self.settings[s] # A legacy config implies openshift-enterprise 3.0: self.settings['variant'] = 'openshift-enterprise' diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py index 489a0f7c1..e4c808e85 100644 --- a/utils/src/ooinstall/openshift_ansible.py +++ b/utils/src/ooinstall/openshift_ansible.py @@ -164,8 +164,10 @@ def run_uninstall_playbook(verbose=False): def run_upgrade_playbook(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/adhoc/upgrades/upgrade.yml') + 'playbooks/byo/openshift-cluster/upgrades/v3_0_to_v3_1/upgrade.yml') # TODO: Upgrade inventory for upgrade? inventory_file = generate_inventory(CFG.hosts) facts_env = os.environ.copy() -- cgit v1.2.3