# Buggy code
def sections_absent(name, sections=None, separator="="):
    """
    .. code-block:: yaml

        /home/saltminion/api-paste.ini:
          ini.sections_absent:
            - separator: '='
            - sections:
                - test
                - test1

    options present in file and not specified in sections will be deleted
    changes dict will contain the sections that changed
    """
    ret = {
        "name": name,
        "changes": {},
        "result": True,
        "comment": "No anomaly detected",
    }
    if __opts__["test"]:
        ret["result"] = True
        ret["comment"] = ""
        for section in sections or []:
            try:
                cur_section = __salt__["ini.get_section"](name, section, separator)
            except IOError as err:
                ret["result"] = False
                ret["comment"] = "{0}".format(err)
                return ret
            if not cur_section:
                ret["comment"] += "Section {0} does not exist.\n".format(section)
                continue
            ret["comment"] += "Deleted section {0}.\n".format(section)
            ret["result"] = None
        if ret["comment"] == "":
            ret["comment"] = "No changes detected."
        return ret
    for section in sections or []:
        try:
            cur_section = __salt__["ini.remove_section"](name, section, separator)
        except IOError as err:
            ret["result"] = False
            ret["comment"] = "{0}".format(err)
            return ret
        if not cur_section:
            continue
        ret["changes"][section] = cur_section
        ret["comment"] = "Changes take effect"
    return ret


# Traceback (TypeError)
local:
----------
ID: ini-present
Function: ini.options_present
Name: /tmp/test.ini
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/home/js/work/git/salt/salt/state.py", line 1918, in call
**cdata['kwargs'])
File "/home/js/work/git/salt/salt/loader.py", line 1830, in wrapper
return f(*args, **kwargs)
File "/home/js/work/git/salt/salt/states/ini_manage.py", line 68, in options_present
if cur_value == six.text_type(sections[section][key]):
TypeError: string indices must be integers
Started: 11:44:26.917548
Duration: 2.082 ms
Changes:
----------
ID: ini-absent
Function: ini.options_absent
Name: /tmp/test.ini
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/home/js/work/git/salt/salt/state.py", line 1918, in call
**cdata['kwargs'])
File "/home/js/work/git/salt/salt/loader.py", line 1830, in wrapper
return f(*args, **kwargs)
File "/home/js/work/git/salt/salt/states/ini_manage.py", line 142, in options_absent
cur_section = __salt__['ini.get_section'](name, section, separator)
File "/home/js/work/git/salt/salt/modules/ini_manage.py", line 159, in get_section
for key, value in six.iteritems(inifile.get(section, {})):
File "/home/js/work/git/salt/salt/ext/six.py", line 606, in iteritems
return d.iteritems(**kw)
AttributeError: 'unicode' object has no attribute 'iteritems'
Started: 11:44:26.921172
Duration: 1.063 ms
Changes:
----------
ID: ini-sect-present
Function: ini.sections_present
Name: /tmp/test.ini
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/home/js/work/git/salt/salt/state.py", line 1918, in call
**cdata['kwargs'])
File "/home/js/work/git/salt/salt/loader.py", line 1830, in wrapper
return f(*args, **kwargs)
File "/home/js/work/git/salt/salt/states/ini_manage.py", line 207, in sections_present
if dict(sections[section]) == cur_section:
TypeError: list indices must be integers, not unicode
Started: 11:44:26.923578
Duration: 0.851 ms
Changes:

# Fixed code
def sections_absent(name, sections=None, separator="="):
    """
    .. code-block:: yaml

        /home/saltminion/api-paste.ini:
          ini.sections_absent:
            - separator: '='
            - sections:
                - test
                - test1

    options present in file and not specified in sections will be deleted
    changes dict will contain the sections that changed
    """
    ret = {
        "name": name,
        "changes": {},
        "result": True,
        "comment": "No anomaly detected",
    }
    if __opts__["test"]:
        ret["result"] = True
        ret["comment"] = ""
        try:
            cur_ini = __salt__["ini.get_ini"](name, separator)
        except IOError as err:
            ret["result"] = False
            ret["comment"] = "{0}".format(err)
            return ret
        for section in sections or []:
            if section not in cur_ini:
                ret["comment"] += "Section {0} does not exist.\n".format(section)
                continue
            ret["comment"] += "Deleted section {0}.\n".format(section)
            ret["result"] = None
        if ret["comment"] == "":
            ret["comment"] = "No changes detected."
        return ret
    for section in sections or []:
        try:
            cur_section = __salt__["ini.remove_section"](name, section, separator)
        except IOError as err:
            ret["result"] = False
            ret["comment"] = "{0}".format(err)
            return ret
        if not cur_section:
            continue
        ret["changes"][section] = cur_section
        ret["comment"] = "Changes take effect"
    return ret