Пример #1
0
def get_role_config(env=None):
    """ returns rendered config for this env, if none, renders with default.yaml
    """
    if len(env.roles) != 1:
        raise Exception("must invoke with one role: fab -R xxx, roles in env: {}".format(env.roles))
    role = env.roles[0]
    yaml_dir = os.path.join('app', 'envs')
    yaml_file = os.path.join(yaml_dir, '{}.yaml'.format(role))
    default_yaml_file = os.path.join(yaml_dir, 'default.yaml')
    return _get_config(yaml_file, default_yaml_file,
                       context={'USER_HOME': get_home_dir(env.user),
                                'USER_GROUP': env.group,
                                'USER': env.user})
Пример #2
0
def user_create(admin, password="******"):
    """ create a user

    """
    execute(group_create, env.group)
    if not contains("/etc/passwd", "^%s:" % admin, use_sudo=True, escape=False):
        with settings(admin=admin):
            sudo("useradd -g %(group)s %(admin)s -M -g %(group)s" % env)
    else:
        out = sudo("groups %s" % admin)
        assert re.search(": (.+)", out).group(1) == env.group
    sudo("mkdir -p %(PREFIX)s" % env)
    sudo("chown %(user)s:%(group)s %(PREFIX)s" % env)
    setup_env_for_user(admin)
    admin_home_dir = get_home_dir(admin)
    user_setup(admin, password, admin_home_dir)
Пример #3
0
def get_config(env, yaml_file, default_yaml_file=None):
    return _get_config(yaml_file, default_yaml_file,
                       context={'USER_HOME': get_home_dir(env.user),
                                'USER_GROUP': env.group,
                                'USER': env.user})