Пример #1
0
def generate_run_list(enviro, args):
    '''
    Get the lists of computers, recipes, cookbooks, and run list to run
    against.  A run list is a dictionary containing a list of recipes
    and cookbooks to run against each specified computer.  Typically the
    run list will just specify the same recipes and cookbooks for each
    computer, unless a list of computers was given and the apply (-a)
    command-line argument was specified.  In that case each computer
    could have different things run against them.

    :type enviro: dictionary
    :param enviro: environment to read group lists and computer components from
    :type args: args object
    :param args: object containing attributes for all possible command-line parameters

    :rtype: tuple of (dictionary, list, list, list)
    :return: (run list, host list, recipe list, cookbook list)
    '''
    host_list = generate_target_list(enviro, args)
    run_list = {}
    cookbooks = set()
    recipes = set()
    if args.apply:
        for host in host_list:
            run_list[host] = []
            for comp in enviro['computers'][host]["components"]:
                if comp["type"] == 'cookbook':
                    run_list[host].append(comp)
                    cookbooks.add(comp["name"])
                elif comp["type"] == 'recipe':
                    run_list[host].append(comp)
                    recipes.add(comp["name"])
    else:
        for host in host_list:
            run_list[host] = []
            if args.cookbooks:
                run_list[host].extend([{
                    "type": "cookbook",
                    "name": c
                } for c in args.cookbooks])
            if args.recipes:
                run_list[host].extend([{
                    "type": "recipe",
                    "name": r
                } for r in args.recipes])
        if args.cookbooks:
            cookbooks.update(args.cookbooks)
        if args.recipes:
            recipes.update(args.recipes)
    return run_list, host_list, recipes, cookbooks
Пример #2
0
def generate_run_list(enviro, args):
    '''
    Get the lists of computers, recipes, cookbooks, and run list to run
    against.  A run list is a dictionary containing a list of recipes
    and cookbooks to run against each specified computer.  Typically the
    run list will just specify the same recipes and cookbooks for each
    computer, unless a list of computers was given and the apply (-a)
    command-line argument was specified.  In that case each computer
    could have different things run against them.

    :type enviro: dictionary
    :param enviro: environment to read group lists and computer components from
    :type args: args object
    :param args: object containing attributes for all possible command-line parameters

    :rtype: tuple of (dictionary, list, list, list)
    :return: (run list, host list, recipe list, cookbook list)
    '''
    host_list = generate_target_list(enviro, args)
    run_list = {}
    cookbooks = set()
    recipes = set()
    if args.apply:
        for host in host_list:
            run_list[host] = []
            for comp in enviro['computers'][host]["components"]:
                if comp["type"] == 'cookbook':
                    run_list[host].append(comp)
                    cookbooks.add(comp["name"])
                elif comp["type"] == 'recipe':
                    run_list[host].append(comp)
                    recipes.add(comp["name"])
    else:
        for host in host_list:
            run_list[host] = []
            if args.cookbooks:
                run_list[host].extend([{"type": "cookbook", "name": c} for c in args.cookbooks])
            if args.recipes:
                run_list[host].extend([{"type": "recipe", "name": r} for r in args.recipes])
        if args.cookbooks:
            cookbooks.update(args.cookbooks)
        if args.recipes:
            recipes.update(args.recipes)
    return run_list, host_list, recipes, cookbooks
Пример #3
0
def get_all_recipes():
    "Retrieve all recipes"
    recipes = set()
    for x in _recipes_db:
        recipes.add(_recipes_db[x])
    return recipes