# Buggy code
def render_config(self, spec, conf, vlan_info):
    """
    Render config as dictionary structure and delete keys
      from spec for null values

    :param spec: The facts tree, generated from the argspec
    :param conf: The configuration
    :rtype: dictionary
    :returns: The generated config
    """
    config = deepcopy(spec)

    if vlan_info == "Name" and "Name" not in conf:
        conf = filter(None, conf.split(" "))
        config["vlan_id"] = int(conf[0])
        config["name"] = conf[1]
        if len(conf[2].split("/")) > 1:
            if conf[2].split("/")[0] == "sus":
                config["state"] = "suspend"
            elif conf[2].split("/")[0] == "act":
                config["state"] = "active"
            config["shutdown"] = "enabled"
        else:
            if conf[2] == "suspended":
                config["state"] = "suspend"
            elif conf[2] == "active":
                config["state"] = "active"
            config["shutdown"] = "disabled"
    elif vlan_info == "Type" and "Type" not in conf:
        conf = filter(None, conf.split(" "))
        config["mtu"] = int(conf[3])
    elif vlan_info == "Remote":
        if len(conf.split(",")) > 1 or conf.isdigit():
            remote_span_vlan = []
            if len(conf.split(",")) > 1:
                remote_span_vlan = conf.split(",")
            else:
                remote_span_vlan.append(conf)
            remote_span = []
            for each in remote_span_vlan:
                remote_span.append(int(each))
            config["remote_span"] = remote_span

    return utils.remove_empties(config)


# Traceback (TypeError)
$ ansible-playbook ios_vlans.yml

PLAY [sccs-2ug-07] ******************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************
[WARNING]: Ignoring timeout(10) for ios_facts

ok: [sccs-2ug-07]

TASK [Delete all VLANs] *************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: 'filter' object is not subscriptable
fatal: [sccs-2ug-07]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/home/misch/.ansible/tmp/ansible-local-112400ljdojbw/ansible-tmp-1573048754.5352461-196207205443014/AnsiballZ_ios_vlans.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/home/misch/.ansible/tmp/ansible-local-112400ljdojbw/ansible-tmp-1573048754.5352461-196207205443014/AnsiballZ_ios_vlans.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/misch/.ansible/tmp/ansible-local-112400ljdojbw/ansible-tmp-1573048754.5352461-196207205443014/AnsiballZ_ios_vlans.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible.modules.network.ios.ios_vlans', init_globals=None, run_name='__main__', alter_sys=False)\n  File \"/usr/lib64/python3.6/runpy.py\", line 208, in run_module\n    return _run_code(code, {}, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_ios_vlans_payload_8jji30h2/ansible_ios_vlans_payload.zip/ansible/modules/network/ios/ios_vlans.py\", line 464, in <module>\n  File \"/tmp/ansible_ios_vlans_payload_8jji30h2/ansible_ios_vlans_payload.zip/ansible/modules/network/ios/ios_vlans.py\", line 459, in main\n  File \"/tmp/ansible_ios_vlans_payload_8jji30h2/ansible_ios_vlans_payload.zip/ansible/module_utils/network/ios/config/vlans/vlans.py\", line 63, in execute_module\n  File \"/tmp/ansible_ios_vlans_payload_8jji30h2/ansible_ios_vlans_payload.zip/ansible/module_utils/network/ios/config/vlans/vlans.py\", line 47, in get_interfaces_facts\n  File \"/tmp/ansible_ios_vlans_payload_8jji30h2/ansible_ios_vlans_payload.zip/ansible/module_utils/network/ios/facts/facts.py\", line 68, in get_facts\n  File \"/tmp/ansible_ios_vlans_payload_8jji30h2/ansible_ios_vlans_payload.zip/ansible/module_utils/network/common/facts/facts.py\", line 105, in get_network_resources_facts\n  File \"/tmp/ansible_ios_vlans_payload_8jji30h2/ansible_ios_vlans_payload.zip/ansible/module_utils/network/ios/facts/vlans/vlans.py\", line 69, in populate_facts\n  File \"/tmp/ansible_ios_vlans_payload_8jji30h2/ansible_ios_vlans_payload.zip/ansible/module_utils/network/ios/facts/vlans/vlans.py\", line 115, in render_config\nTypeError: 'filter' object is not subscriptable\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

PLAY RECAP **************************************************************************************************************
sccs-2ug-07                : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

# Fixed code
def render_config(self, spec, conf, vlan_info):
    """
    Render config as dictionary structure and delete keys
      from spec for null values

    :param spec: The facts tree, generated from the argspec
    :param conf: The configuration
    :rtype: dictionary
    :returns: The generated config
    """
    config = deepcopy(spec)

    if vlan_info == "Name" and "Name" not in conf:
        conf = list(filter(None, conf.split(" ")))
        config["vlan_id"] = int(conf[0])
        config["name"] = conf[1]
        if len(conf[2].split("/")) > 1:
            if conf[2].split("/")[0] == "sus":
                config["state"] = "suspend"
            elif conf[2].split("/")[0] == "act":
                config["state"] = "active"
            config["shutdown"] = "enabled"
        else:
            if conf[2] == "suspended":
                config["state"] = "suspend"
            elif conf[2] == "active":
                config["state"] = "active"
            config["shutdown"] = "disabled"
    elif vlan_info == "Type" and "Type" not in conf:
        conf = list(filter(None, conf.split(" ")))
        config["mtu"] = int(conf[3])
    elif vlan_info == "Remote":
        if len(conf.split(",")) > 1 or conf.isdigit():
            remote_span_vlan = []
            if len(conf.split(",")) > 1:
                remote_span_vlan = conf.split(",")
            else:
                remote_span_vlan.append(conf)
            remote_span = []
            for each in remote_span_vlan:
                remote_span.append(int(each))
            config["remote_span"] = remote_span

    return utils.remove_empties(config)