def provision_server(server, provfile_path, password, prov):
    host_string = "%s@%s" % (server['user'], server['address'].strip())

    context = {
        'abspath': dirname(abspath(provfile_path)),
        'path': dirname(provfile_path),
        'owner': server['user'],
        'cleanup': [],
        'registered_loaders': []
    }

    aggregate_node_options(server, context)

    loader = ChoiceLoader([
        FileSystemLoader(join(context['abspath'], 'files'))
    ])
    context['loader'] = loader

    print_header("Provisioning %s..." % host_string)

    settings_dict = dict(host_string=host_string, password=password)
    if 'ssh_key' in server and server['ssh_key']:
        settings_dict['key_filename'] = server['ssh_key']

    with _settings(**settings_dict):
        context['host'] = server['address']
        context['user'] = server['user']
        role_instances = []

        try:
            for role in server['roles']:
                context['role'] = role
                instance = role(prov, context)
                role_instances.append(instance)
                instance.provision()
        finally:
            for role in role_instances:
                role.cleanup()

            for role in context['cleanup']:
                role.cleanup()

    print_header("%s provisioned!" % host_string)
dataset/ETHPy150Open python-provy/provy/provy/core/runner.py/provision_server/original