# Buggy code
def record_absent(name, zone, type, data, profile):
    """
    Ensures a record is absent.

    :param name: Record name without the domain name (e.g. www).
                 Note: If you want to create a record for a base domain
                 name, you should specify empty string ('') for this
                 argument.
    :type  name: ``str``

    :param zone: Zone where the requested record is created, the domain name
    :type  zone: ``str``

    :param type: DNS record type (A, AAAA, ...).
    :type  type: ``str``

    :param data: Data for the record (depends on the record type).
    :type  data: ``str``

    :param profile: The profile key
    :type  profile: ``str``
    """
    zones = libcloud_dns_module.list_zones(profile)
    try:
        matching_zone = [z for z in zones if z.domain == zone][0]
    except IndexError:
        return state_result(False, "Zone could not be found")
    records = libcloud_dns_module.list_records(matching_zone.id, profile)
    matching_records = [
        record
        for record in records
        if record.name == name and record.type == type and record.data == data
    ]
    if len(matching_records) > 0:
        result = []
        for record in matching_records:
            result.append(
                libcloud_dns_module.delete_record(matching_zone.id, record.id, profile)
            )
        return state_result(all(result), "Removed {0} records".format(len(result)))
    else:
        return state_result(True, "Records already absent")


# Traceback (NameError)
An exception occurred in this state: Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/salt/state.py", line 1746, in call
**cdata['kwargs'])
File "/usr/local/lib/python2.7/dist-packages/salt/loader.py", line 1704, in wrapper
return f(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/salt/states/libcloud_dns.py", line 169, in record_present
zones = libcloud_dns_module.list_zones(profile)
File "/usr/local/lib/python2.7/dist-packages/salt/modules/libcloud_dns.py", line 109, in list_zones
conn = _get_driver(profile=profile)
File "/usr/local/lib/python2.7/dist-packages/salt/modules/libcloud_dns.py", line 69, in _get_driver
config = __salt__['config.option']('libcloud_dns')[profile]
NameError: global name '__salt__' is not defined

# Fixed code
def record_absent(name, zone, type, data, profile):
    """
    Ensures a record is absent.

    :param name: Record name without the domain name (e.g. www).
                 Note: If you want to create a record for a base domain
                 name, you should specify empty string ('') for this
                 argument.
    :type  name: ``str``

    :param zone: Zone where the requested record is created, the domain name
    :type  zone: ``str``

    :param type: DNS record type (A, AAAA, ...).
    :type  type: ``str``

    :param data: Data for the record (depends on the record type).
    :type  data: ``str``

    :param profile: The profile key
    :type  profile: ``str``
    """
    zones = __salt__["libcloud_dns.list_zones"](profile)
    try:
        matching_zone = [z for z in zones if z.domain == zone][0]
    except IndexError:
        return state_result(False, "Zone could not be found")
    records = __salt__["libcloud_dns.list_records"](matching_zone.id, profile)
    matching_records = [
        record
        for record in records
        if record.name == name and record.type == type and record.data == data
    ]
    if len(matching_records) > 0:
        result = []
        for record in matching_records:
            result.append(
                __salt__["libcloud_dns.delete_record"](
                    matching_zone.id, record.id, profile
                )
            )
        return state_result(all(result), "Removed {0} records".format(len(result)))
    else:
        return state_result(True, "Records already absent")