How to use the execo.log.style.emph function in execo

To help you get started, we’ve selected a few execo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BeyondTheClouds / enos / kolla-g5k.py View on Github external
def run_ansible(playbooks, inventory_path, extra_vars={}, tags=None):
    inventory = Inventory(inventory_path)

    for path in playbooks:
        logger.info("Running playbook %s with vars:\n%s" % (style.emph(path), extra_vars))
        stats = ansible.callbacks.AggregateStats()
        playbook_cb = ansible.callbacks.PlaybookCallbacks(verbose=1)

        pb = ansible.playbook.PlayBook(
            playbook=path,
            inventory=inventory,
            extra_vars=extra_vars,
            stats=stats,
            callbacks=playbook_cb,
            only_tags=tags,
            runner_callbacks=
              ansible.callbacks.PlaybookRunnerCallbacks(stats, verbose=1)
        )

        pb.run()
github BeyondTheClouds / enos / 01_deploy_nodes.py View on Github external
def generate_inventory(roles, base_inventory, dest):
    """
    Generate the inventory.
    It will generate a group for each role in roles and
    concatenate them with the base_inventory file.
    The generated inventory is written in dest
    """
    with open(dest, 'w') as f:
        f.write(to_ansible_group_string(roles))
        with open(base_inventory, 'r') as a:
            for line in a:
                f.write(line)

    logger.info("Inventory file written to " + style.emph(dest))
github BeyondTheClouds / enos / 01_deploy_nodes.py View on Github external
def run_ansible(playbooks, inventory_path, extra_vars):
    inventory = Inventory(inventory_path)

    for path in playbooks:
        logger.info("Running playbook %s with vars:\n%s" % (style.emph(path), extra_vars))
        stats = ansible.callbacks.AggregateStats()
        playbook_cb = ansible.callbacks.PlaybookCallbacks(verbose=1)

        pb = ansible.playbook.PlayBook(
            playbook=path,
            inventory=inventory,
            extra_vars=extra_vars,
            stats=stats,
            callbacks=playbook_cb,
            runner_callbacks=ansible.callbacks.PlaybookRunnerCallbacks(stats, verbose=1),
            forks=10
        )

        pb.run()

        hosts = pb.stats.processed.keys()
github BeyondTheClouds / enos / kolla-g5k.py View on Github external
def generate_kolla_files(config_vars, kolla_vars, directory):
    # get the static parameters from the config file
    kolla_globals = config_vars
    # add the generated parameters
    kolla_globals.update(kolla_vars)
    # write to file in the result dir
    globals_path = os.path.join(directory, 'globals.yml')
    with open(globals_path, 'w') as f:
        yaml.dump(kolla_globals, f, default_flow_style=False)

    logger.info("Wrote " + style.emph(globals_path))

    # copy the passwords file
    passwords_path = os.path.join(directory, "passwords.yml")
    call("cp %s/passwords.yml %s" % (TEMPLATE_DIR, passwords_path), shell=True)
    logger.info("Password file is copied to  %s" % (passwords_path))

    # admin openrc
    admin_openrc_path = os.path.join(directory, 'admin-openrc')
    admin_openrc_vars = {
        'keystone_address': kolla_vars['kolla_internal_vip_address']
    }
    render_template('templates/admin-openrc.jinja2', admin_openrc_vars, admin_openrc_path)
    logger.info("admin-openrc generated in %s" % (admin_openrc_path))