def install(ctx, force):
    oo_cfg = ctx.obj['oo_cfg']

    if ctx.obj['unattended']:
        error_if_missing_info(oo_cfg)
    else:
        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)
    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)

    click.echo('Writing config to: %s' % oo_cfg.config_path)

    # We already verified this is not the case for unattended installs, so this can
    # only trigger for live CLI users:
    # TODO: if there are *new* nodes and this is a live install, we may need the  user
    # to confirm the settings for new nodes. Look into this once we're distinguishing
    # between new and pre-existing nodes.
    if len(oo_cfg.calc_missing_facts()) > 0:
        confirm_hosts_facts(oo_cfg, callback_facts)

    oo_cfg.save_to_disk()

    click.echo('Ready to run installation process.')
    message = """
If changes are needed to the values recorded by the installer please update {}.
""".format(oo_cfg.config_path)
    if not ctx.obj['unattended']:
        confirm_continue(message)

    error = openshift_ansible.run_main_playbook(oo_cfg.hosts,
                                                   hosts_to_run_on)
    if error:
        # The bootstrap script will print out the log location.
        message = """
An error was detected.  After resolving the problem please relaunch the
installation process.
"""
        click.echo(message)
        sys.exit(1)
    else:
        message = """
The installation was successful!

If this is your first time installing please take a look at the Administrator
Guide for advanced options related to routing, storage, authentication and much
more:

http://docs.openshift.com/enterprise/latest/admin_guide/overview.html
"""
        click.echo(message)
        click.pause()
def install(ctx, force, gen_inventory):
    oo_cfg = ctx.obj['oo_cfg']
    verbose = ctx.obj['verbose']
    unattended = ctx.obj['unattended']

    if unattended:
        error_if_missing_info(oo_cfg)
    else:
        oo_cfg = get_missing_info_from_user(oo_cfg)

    check_hosts_config(oo_cfg, unattended)

    print_installation_summary(oo_cfg.deployment.hosts,
                               oo_cfg.settings.get('variant_version', None))
    click.echo('Gathering information from hosts...')
    callback_facts, error = openshift_ansible.default_facts(oo_cfg.deployment.hosts,
                                                            verbose)

    if error or callback_facts is None:
        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,
                                                          unattended,
                                                          force)

    # We already verified this is not the case for unattended installs, so this can
    # only trigger for live CLI users:
    if not ctx.obj['unattended'] and len(oo_cfg.calc_missing_facts()) > 0:
        confirm_hosts_facts(oo_cfg, callback_facts)

    # Write quick installer config file to disk:
    oo_cfg.save_to_disk()

    run_config_playbook(oo_cfg, hosts_to_run_on, unattended, verbose, gen_inventory)
Esempio n. 3
0
def install(ctx, force, gen_inventory):
    oo_cfg = ctx.obj['oo_cfg']
    verbose = ctx.obj['verbose']
    unattended = ctx.obj['unattended']

    if unattended:
        error_if_missing_info(oo_cfg)
    else:
        oo_cfg = get_missing_info_from_user(oo_cfg)

    check_hosts_config(oo_cfg, unattended)

    print_installation_summary(oo_cfg.deployment.hosts,
                               oo_cfg.settings.get('variant_version', None))
    click.echo('Gathering information from hosts...')
    callback_facts, error = openshift_ansible.default_facts(
        oo_cfg.deployment.hosts, verbose)

    if error or callback_facts is None:
        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, unattended, force)

    # We already verified this is not the case for unattended installs, so this can
    # only trigger for live CLI users:
    if not ctx.obj['unattended'] and len(oo_cfg.calc_missing_facts()) > 0:
        confirm_hosts_facts(oo_cfg, callback_facts)

    # Write quick installer config file to disk:
    oo_cfg.save_to_disk()

    run_config_playbook(oo_cfg, hosts_to_run_on, unattended, verbose,
                        gen_inventory)
Esempio n. 4
0
def install(ctx, force):
    oo_cfg = ctx.obj['oo_cfg']
    verbose = ctx.obj['verbose']

    if ctx.obj['unattended']:
        error_if_missing_info(oo_cfg)
    else:
        oo_cfg = get_missing_info_from_user(oo_cfg)

    check_hosts_config(oo_cfg, ctx.obj['unattended'])

    print_installation_summary(oo_cfg.hosts,
                               oo_cfg.settings.get('variant_version', None))
    click.echo('Gathering information from 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, verbose)

    click.echo('Writing config to: %s' % oo_cfg.config_path)

    # We already verified this is not the case for unattended installs, so this can
    # only trigger for live CLI users:
    # TODO: if there are *new* nodes and this is a live install, we may need the  user
    # to confirm the settings for new nodes. Look into this once we're distinguishing
    # between new and pre-existing nodes.
    if len(oo_cfg.calc_missing_facts()) > 0:
        confirm_hosts_facts(oo_cfg, callback_facts)

    oo_cfg.save_to_disk()

    click.echo('Ready to run installation process.')
    message = """
If changes are needed please edit the config file above and re-run.
"""
    if not ctx.obj['unattended']:
        confirm_continue(message)

    error = openshift_ansible.run_main_playbook(oo_cfg.hosts, hosts_to_run_on,
                                                verbose)
    if error:
        # The bootstrap script will print out the log location.
        message = """
An error was detected.  After resolving the problem please relaunch the
installation process.
"""
        click.echo(message)
        sys.exit(1)
    else:
        message = """
The installation was successful!

If this is your first time installing please take a look at the Administrator
Guide for advanced options related to routing, storage, authentication and much
more:

http://docs.openshift.com/enterprise/latest/admin_guide/overview.html
"""
        click.echo(message)
        click.pause()
Esempio n. 5
0
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)

    # Check if master or nodes already have something installed
    installed_hosts = get_installed_hosts(oo_cfg.hosts, callback_facts)
    if len(installed_hosts) > 0:
        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) reinstall the existing hosts ' \
                                        'potentially erasing any custom changes?',
                                        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))
                # Masters stay in the list, we need to run against them when adding
                # new nodes.
            elif host.node:
                click.echo("{} is already an OpenShift Node".format(host))
                # force is only used for reinstalls so we don't want to remove
                # anything.
                if not force:
                    hosts_to_run_on.remove(host)

        # 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:
            if unattended:
                if not force:
                    click.echo('Installed environment detected and no additional ' \
                               'nodes specified: aborting. If you want a fresh install, use ' \
                               '`atomic-openshift-installer install --force`')
                    sys.exit(1)
            else:
                if not force:
                    new_nodes = collect_new_nodes(oo_cfg)

                    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, verbose)
                    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
def scaleup(ctx, gen_inventory):
    oo_cfg = ctx.obj['oo_cfg']
    verbose = ctx.obj['verbose']
    unattended = ctx.obj['unattended']

    installed_hosts = list(oo_cfg.deployment.hosts)

    if len(installed_hosts) == 0:
        click.echo('No hosts specified.')
        sys.exit(1)

    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,)
    message = """
---

We have detected this previously installed OpenShift environment.

This tool will guide you through the process of adding additional
nodes to your cluster.
"""
    confirm_continue(message)

    error_if_missing_info(oo_cfg)
    check_hosts_config(oo_cfg, True)

    installed_masters = [host for host in installed_hosts if host.is_master()]
    new_nodes = collect_new_nodes(oo_cfg)

    oo_cfg.deployment.hosts.extend(new_nodes)
    hosts_to_run_on = installed_masters + new_nodes

    openshift_ansible.set_config(oo_cfg)
    click.echo('Gathering information from hosts...')
    callback_facts, error = openshift_ansible.default_facts(oo_cfg.deployment.hosts, verbose)
    if error or callback_facts is None:
        click.echo("There was a problem fetching the required information. See "
                   "{} for details.".format(oo_cfg.settings['ansible_log_path']))
        sys.exit(1)

    print_installation_summary(oo_cfg.deployment.hosts,
                               oo_cfg.settings.get('variant_version', None))
    click.echo('Gathering information from hosts...')
    callback_facts, error = openshift_ansible.default_facts(oo_cfg.deployment.hosts,
                                                            verbose)

    if error or callback_facts is None:
        click.echo("There was a problem fetching the required information. "
                   "Please see {} for details.".format(oo_cfg.settings['ansible_log_path']))
        sys.exit(1)

    # We already verified this is not the case for unattended installs, so this can
    # only trigger for live CLI users:
    if not ctx.obj['unattended'] and len(oo_cfg.calc_missing_facts()) > 0:
        confirm_hosts_facts(oo_cfg, callback_facts)

    # Write quick installer config file to disk:
    oo_cfg.save_to_disk()
    run_config_playbook(oo_cfg, hosts_to_run_on, unattended, verbose, gen_inventory)
Esempio n. 7
0
def install(ctx, force, gen_inventory):
    oo_cfg = ctx.obj['oo_cfg']
    verbose = ctx.obj['verbose']

    if ctx.obj['unattended']:
        error_if_missing_info(oo_cfg)
    else:
        oo_cfg = get_missing_info_from_user(oo_cfg)

    check_hosts_config(oo_cfg, ctx.obj['unattended'])

    print_installation_summary(oo_cfg.deployment.hosts, oo_cfg.settings.get('variant_version', None))
    click.echo('Gathering information from hosts...')
    callback_facts, error = openshift_ansible.default_facts(oo_cfg.deployment.hosts,
        verbose)

    if error or callback_facts is None:
        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, verbose)


    # We already verified this is not the case for unattended installs, so this can
    # only trigger for live CLI users:
    # TODO: if there are *new* nodes and this is a live install, we may need the  user
    # to confirm the settings for new nodes. Look into this once we're distinguishing
    # between new and pre-existing nodes.
    if not ctx.obj['unattended'] and len(oo_cfg.calc_missing_facts()) > 0:
        confirm_hosts_facts(oo_cfg, callback_facts)

    # Write quick installer config file to disk:
    oo_cfg.save_to_disk()

    # Write ansible inventory file to disk:
    inventory_file = openshift_ansible.generate_inventory(hosts_to_run_on)

    click.echo()
    click.echo('Wrote atomic-openshift-installer config: %s' % oo_cfg.config_path)
    click.echo("Wrote ansible inventory: %s" % inventory_file)
    click.echo()

    if gen_inventory:
        sys.exit(0)

    click.echo('Ready to run installation process.')
    message = """
If changes are needed please edit the config file above and re-run.
"""
    if not ctx.obj['unattended']:
        confirm_continue(message)

    error = openshift_ansible.run_main_playbook(inventory_file, oo_cfg.deployment.hosts,
                                                hosts_to_run_on, verbose)

    if error:
        # The bootstrap script will print out the log location.
        message = """
An error was detected.  After resolving the problem please relaunch the
installation process.
"""
        click.echo(message)
        sys.exit(1)
    else:
        message = """
The installation was successful!

If this is your first time installing please take a look at the Administrator
Guide for advanced options related to routing, storage, authentication and much
more:

http://docs.openshift.com/enterprise/latest/admin_guide/overview.html
"""
        click.echo(message)
        click.pause()
Esempio n. 8
0
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.deployment.hosts)

    # Check if master or nodes already have something installed
    installed_hosts = get_installed_hosts(oo_cfg.deployment.hosts, callback_facts)
    if len(installed_hosts) > 0:
        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) reinstall the existing hosts ' \
                                        'potentially erasing any custom changes?',
                                        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.is_master():
                click.echo("{} is already an OpenShift Master".format(host))
                # Masters stay in the list, we need to run against them when adding
                # new nodes.
            elif host.is_node():
                click.echo("{} is already an OpenShift Node".format(host))
                # force is only used for reinstalls so we don't want to remove
                # anything.
                if not force:
                    hosts_to_run_on.remove(host)

        # 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:
            if unattended:
                if not force:
                    click.echo('Installed environment detected and no additional ' \
                               'nodes specified: aborting. If you want a fresh install, use ' \
                               '`atomic-openshift-installer install --force`')
                    sys.exit(1)
            else:
                if not force:
                    new_nodes = collect_new_nodes(oo_cfg)

                    hosts_to_run_on.extend(new_nodes)
                    oo_cfg.deployment.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.deployment.hosts, verbose)
                    if error or callback_facts is None:
                        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
Esempio n. 9
0
def scaleup(ctx, gen_inventory):
    oo_cfg = ctx.obj['oo_cfg']
    verbose = ctx.obj['verbose']
    unattended = ctx.obj['unattended']

    installed_hosts = list(oo_cfg.deployment.hosts)

    if len(installed_hosts) == 0:
        click.echo('No hosts specified.')
        sys.exit(1)

    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,
    )
    message = """
---

We have detected this previously installed OpenShift environment.

This tool will guide you through the process of adding additional
nodes to your cluster.
"""
    confirm_continue(message)

    error_if_missing_info(oo_cfg)
    check_hosts_config(oo_cfg, True)

    installed_masters = [host for host in installed_hosts if host.is_master()]
    new_nodes = collect_new_nodes(oo_cfg)

    oo_cfg.deployment.hosts.extend(new_nodes)
    hosts_to_run_on = installed_masters + new_nodes

    openshift_ansible.set_config(oo_cfg)
    click.echo('Gathering information from hosts...')
    callback_facts, error = openshift_ansible.default_facts(
        oo_cfg.deployment.hosts, verbose)
    if error or callback_facts is None:
        click.echo(
            "There was a problem fetching the required information. See "
            "{} for details.".format(oo_cfg.settings['ansible_log_path']))
        sys.exit(1)

    print_installation_summary(oo_cfg.deployment.hosts,
                               oo_cfg.settings.get('variant_version', None))
    click.echo('Gathering information from hosts...')
    callback_facts, error = openshift_ansible.default_facts(
        oo_cfg.deployment.hosts, verbose)

    if error or callback_facts is None:
        click.echo("There was a problem fetching the required information. "
                   "Please see {} for details.".format(
                       oo_cfg.settings['ansible_log_path']))
        sys.exit(1)

    # We already verified this is not the case for unattended installs, so this can
    # only trigger for live CLI users:
    if not ctx.obj['unattended'] and len(oo_cfg.calc_missing_facts()) > 0:
        confirm_hosts_facts(oo_cfg, callback_facts)

    # Write quick installer config file to disk:
    oo_cfg.save_to_disk()
    run_config_playbook(oo_cfg, hosts_to_run_on, unattended, verbose,
                        gen_inventory)