def generate_pre_tasks(minimal_facts=True, box_basics=True,
    box_basics_non_sudo=False, freckles_facts=True):
    """Generates a list of tasks that will end up in a playbooks pre_tasks variable.

    Args:
        minimal_facts (bool): whether to run a basic shell script to gather some basic facts (this doesn't require Python on the target machine, but can find out whether Python is available.
        box_basics (bool): whether to install a minimal set to be able to run common Ansible modules on this machine
        box_basics_non_sudo (bool): whether to run the 'non-sudo' version of box basics (not implemented yet)
        freckles_facts (bool): whether to run the freckles facts module

    Returns:
        tuple: a tuple in the form: (task_list, gather_facts_included), gather_facts_included indicates whether the pre_tasks will run gather_facts at some stage (so it doesn't need to be executed twice.
    """
    gather_facts_included = False
    pre_tasks = []
    if minimal_facts or box_basics or freckles_facts:
        temp = [{'name': '[-1000][testing connectivity]', 'raw':
            'sh -c "true"', 'ignore_errors': False, 'changed_when': False},
            {'name': '[getting box basic facts]', 'include_tasks':
            '{{ playbook_dir }}/../task_lists/freckles_basic_facts.yml'}]
        pre_tasks.extend(temp)
    if box_basics or freckles_facts:
        gather_facts_included = True
        temp = [{'name': '[preparing box basics]', 'include_tasks':
            '{{ playbook_dir }}/../task_lists/box_basics.yml'}]
        pre_tasks.extend(temp)
    if freckles_facts:
        pre_tasks.append({'name': '[gathering freckles-specific facts]',
            'freckles_facts': {'executables': ['unzip']}})
    return {'pre_tasks': pre_tasks, 'gather_facts': not gather_facts_included}
