def test_generate_inventory_new_nodes(self):
     hosts = self.generate_hosts(1, 'master', roles=(['master', 'etcd']))
     hosts.extend(self.generate_hosts(1, 'node', roles=['node']))
     hosts.extend(self.generate_hosts(1, 'new_node', roles=['node'], new_host=True))
     openshift_ansible.generate_inventory(hosts)
     inventory = configparser.ConfigParser(allow_no_value=True)
     inventory.read(self.inventory)
     self.assertTrue(inventory.has_section('new_nodes'))
     self.assertTrue(inventory.has_option('new_nodes', 'new_node1'))
Example #2
0
 def test_generate_inventory_new_nodes(self):
     hosts = self.generate_hosts(1, 'master', roles=(['master', 'etcd']))
     hosts.extend(self.generate_hosts(1, 'node', roles=['node']))
     hosts.extend(
         self.generate_hosts(1, 'new_node', roles=['node'], new_host=True))
     openshift_ansible.generate_inventory(hosts)
     inventory = configparser.ConfigParser(allow_no_value=True)
     inventory.read(self.inventory)
     self.assertTrue(inventory.has_section('new_nodes'))
     self.assertTrue(inventory.has_option('new_nodes', 'new_node1'))
Example #3
0
def run_config_playbook(oo_cfg, hosts_to_run_on, unattended, verbose,
                        gen_inventory):
    # 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 installer.cfg.yml config file above and re-run.
"""
    if not unattended:
        confirm_continue(message)

    error = openshift_ansible.run_prerequisites(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)

    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
more:

http://docs.openshift.com/enterprise/latest/admin_guide/overview.html
"""
        click.echo(message)
def run_config_playbook(oo_cfg, hosts_to_run_on, unattended, verbose, gen_inventory):
    # 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 installer.cfg.yml config file above and re-run.
"""
    if not 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
more:

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