def set_defaults(): if 'app_name' not in env.keys(): env.app_name = 'traugott' if 'app_path' not in env.keys(): env.app_path = '/home/%s/www/%s/src/app' % (env.user, env.app_name) if 'root_path' not in env.keys(): env.root_path = '/home/%s/www/%s/src' % (env.user, env.app_name)
def get_library_dir(): """Get global library path Library store roles and cookbooks """ key = COOKBOOKS_LIBRARY_NAME if key in env.keys() and os.path.exists(env[key]): return env[key] return _rel(os.path.dirname(env.real_fabfile), COOKBOOKS_LIBRARY_NAME)
def get_info_skip_list(): """Get recipe params skip list :return: list of param names :rtype: list """ if "info_skip_list" in env.keys() and isinstance(env['info_skip_list'], (tuple, list)): return env['info_skip_list'] else: return DEFAULT_INFO_SKIP_LIST
def get_template(name='cookbook'): """Get recipe template :param path: recipe template path """ if "cookbook_template" in env.keys() and os.path.exists(env['cookbook_path']): return env['cookbook_template'] elif os.path.exists(_rel(fabmagic.__path__[0], TEMPLATES_DIR_NAME, name)): return _rel(fabmagic.__path__[0], TEMPLATES_DIR_NAME, name) abort(colors.red("You need specify recipes_path"))
def required_envs(env_list): missing = [] for var in env_list: if var not in env.keys(): missing.append(var) if missing: message = "\nYou forgot to set some variables to deploy:\n" for var in missing: message += " - {0}\n".format(var) error(red(message))
def get_template(name='cookbook'): """Get recipe template :param path: recipe template path """ if "cookbook_template" in env.keys() and os.path.exists( env['cookbook_path']): return env['cookbook_template'] elif os.path.exists(_rel(fabmagic.__path__[0], TEMPLATES_DIR_NAME, name)): return _rel(fabmagic.__path__[0], TEMPLATES_DIR_NAME, name) abort(colors.red("You need specify recipes_path"))
def get_component_directory(name): """Get directory for given component Components: - roles - cookbooks :param name: component name :return: path to component directory """ key = '_'.join([name, 'path']) if key in env.keys(): return env[key] return _rel(get_library_dir(), name)