How to use jumbo - 10 common examples

To help you get started, we’ve selected a few jumbo 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 adaltas / jumbo / jumbo / core / bundles.py View on Github external
raise RuntimeError('addbundle: bundle `%s` does not exist.' % name)

    if position == 'last':
        ss.svars['bundles'].append(name)
    elif position == 'first':
        ss.svars['bundles'].insert(0, name)
    else:
        if not position.isdigit():
            raise RuntimeError(
                'addbundle: invalid value for position. '
                'Can be `last` (default), `first`, or a number.')

        ss.svars['bundles'].insert(int(position), name)

    services.config = services.load_services_conf(cluster=cluster)
    ss.dump_config(services.get_services_components_hosts(),
                   services.config)
github adaltas / jumbo / jumbo / cli / main.py View on Github external
def exit(ctx):
    """Reset current context.

    :param ctx: Click context
    """

    if ss.svars.get('cluster'):
        ss.svars['cluster'] = None
        ctx.meta['jumbo_shell'].prompt = click.style('jumbo > ', fg='green')
    else:
        click.echo('Use "quit" to quit the shell. Exit only removes context.')
github adaltas / jumbo / jumbo / core / vault.py View on Github external
def create_keys(d, str_keys, value):
    """Create keys in the dictionnary d from dotted notation string in str_key.
    eg. str_keys = "AMBARI.pwd" creates d['AMBARI']['pwd'] = value 
    """

    keys = str_keys.split(".")
    for k in keys[:-1]:
        if not k in d:
            d[k] = {}
        d = d[k]
    if keys[-1] in d:
        raise ex.CreationError("vault entry", str_keys,
                               "key", str_keys, 'Exists')
    d[keys[-1]] = value
github adaltas / jumbo / jumbo / core / bundles.py View on Github external
def list_bundles():
    """List bundles of the current cluster and available bundles"""

    path_list = [f.path.split('/')[-1]
                 for f in os.scandir(JUMBODIR+'bundles') if f.is_dir()]
    return (ss.svars.get('bundles', []), path_list)
github adaltas / jumbo / jumbo / core / bundles.py View on Github external
raise RuntimeError(
            'addbundle: invalid arguments. Name required.')

    (active, available) = list_bundles()

    if name in active:
        raise Warning('addbundle: bundle `% s` already active. '
                      'Nothing to be done.' % name)
        # IDEA: --force option (case of bundle called multiple time)
    if name not in available:
        raise RuntimeError('addbundle: bundle `%s` does not exist.' % name)

    if position == 'last':
        ss.svars['bundles'].append(name)
    elif position == 'first':
        ss.svars['bundles'].insert(0, name)
    else:
        if not position.isdigit():
            raise RuntimeError(
                'addbundle: invalid value for position. '
                'Can be `last` (default), `first`, or a number.')

        ss.svars['bundles'].insert(int(position), name)

    services.config = services.load_services_conf(cluster=cluster)
    ss.dump_config(services.get_services_components_hosts(),
                   services.config)
github adaltas / jumbo / jumbo / core / bundles.py View on Github external
def list_bundles():
    """List bundles of the current cluster and available bundles"""

    path_list = [f.path.split('/')[-1]
                 for f in os.scandir(JUMBODIR+'bundles') if f.is_dir()]
    return (ss.svars.get('bundles', []), path_list)
github adaltas / jumbo / jumbo / core / bundles.py View on Github external
if name not in available:
        raise RuntimeError('addbundle: bundle `%s` does not exist.' % name)

    if position == 'last':
        ss.svars['bundles'].append(name)
    elif position == 'first':
        ss.svars['bundles'].insert(0, name)
    else:
        if not position.isdigit():
            raise RuntimeError(
                'addbundle: invalid value for position. '
                'Can be `last` (default), `first`, or a number.')

        ss.svars['bundles'].insert(int(position), name)

    services.config = services.load_services_conf(cluster=cluster)
    ss.dump_config(services.get_services_components_hosts(),
                   services.config)
github adaltas / jumbo / jumbo / core / vault.py View on Github external
def rm_pass(vault_key, password, *, cluster):
    """Remove entry from cluster vault"""
    vault_file = JUMBODIR + 'clusters/' + cluster + '/inventory/group_vars/all/vault'

    vault = Vault(password)
    data = {}

    if os.path.isfile(vault_file):
        data = vault.load(open(vault_file).read())
        try:
            delete_key(data, vault_key)
        except KeyError:
            raise ex.LoadError('key', vault_key, 'NotExist')
    else:
        raise ex.LoadError('vault for cluster', cluster, 'NotExist')

    print(yaml.dump(data, default_flow_style=False))
    vault.dump(data, open(vault_file, 'wb'))
github adaltas / jumbo / jumbo / utils / versions.py View on Github external
def get_yaml_config(cluster=None):
    """Get the versions to use for each service/platform/ressource

    :raises ex.LoadError: If the file versions.json doesn't exist
    :return: The versions to use
    :rtype: dict
    """

    yaml_versions = {
        'services': {},
        'platform': {}
    }

    if not os.path.isfile(JUMBODIR + 'versions.json'):
        raise ex.LoadError('file', JUMBODIR + 'versions.json', 'NotExist')

    # Global versions settings
    with open(JUMBODIR + 'versions.json', 'r') as vs:
        jumbo_versions = json.load(vs)

    yaml_versions = update_yaml_versions(yaml_versions, jumbo_versions)

    if not cluster:
        return yaml_versions

    # Cluster versions settings
    if os.path.isfile(JUMBODIR + cluster + '/versions.json'):
        with open(
                JUMBODIR + cluster + '/versions.json', 'r') as vs:
            cluster_versions = json.load(vs)
github adaltas / jumbo / jumbo / utils / session.py View on Github external
def load_config(cluster):
    """Load a cluster in the session.

    :param cluster: Cluster name
    :type cluster: str
    :return: True on success
    """
    global svars

    if not checks.check_cluster(cluster):
        raise ex.LoadError('cluster', cluster, 'NotExist')

    if not clusters.check_config(cluster):
        raise ex.LoadError('cluster', cluster, 'NoConfFile')
    else:
        try:
            with open(JUMBODIR + cluster + '/jumbo_config', 'r') as jc:
                svars = json.load(jc)
        except IOError as e:
            raise ex.LoadError('cluster', cluster, e.strerror)

    vs.update_versions_file()

    return True