def testhostvars(server_states, extra={}):
    """Helper for tests. Creates a deep ansible hostvars stucture to use in
    the tests. Example usage:
    >>> testhostvars(['EMPTY_DATA_DIR', 'EMPTY_DATA_DIR'])
    {'server1': {'ansible_local': {'pg': {'state': 'EMPTY_DATA_DIR'}}}, 'server2': {'ansible_local': {'pg': {'state': 'EMPTY_DATA_DIR'}}}}
    >>> testhostvars(['EMPTY_DATA_DIR'], {'ENFORCE_SLAVE_UPSTREAM': True})
    {'server1': {'ENFORCE_SLAVE_UPSTREAM': True, 'ansible_local': {'pg': {'state': 'EMPTY_DATA_DIR'}}}}
    """
    res = {}
    for i, state in enumerate(server_states):
        var = {'ansible_local': {'pg': {'state': state} } }
        for k, v in extra.iteritems():
            var[k] = v
        res["server{}".format(i+1)] = var
    return res