# Buggy code
def add(self, lines, parents=None):
    """Adds one or lines of configuration"""

    ancestors = list()
    offset = 0
    obj = None

    ## global config command
    if not parents:
        for line in to_list(lines):
            item = ConfigLine(line)
            item.raw = line
            if item not in self.items:
                self.items.append(item)

    else:
        for index, p in enumerate(parents):
            try:
                i = index + 1
                obj = self.get_section_objects(parents[:i])[0]
                ancestors.append(obj)

            except ValueError:
                # add parent to config
                offset = index * self.indent
                obj = ConfigLine(p)
                obj.raw = p.rjust(len(p) + offset)
                if ancestors:
                    obj.parents = list(ancestors)
                    ancestors[-1].children.append(obj)
                self.items.append(obj)
                ancestors.append(obj)

        # add child objects
        for line in to_list(lines):
            # check if child already exists
            for child in ancestors[-1].children:
                if child.text == line:
                    break
            else:
                offset = len(parents) * self.indent
                item = ConfigLine(line)
                item.raw = line.rjust(len(line) + offset)
                item.parents = ancestors
                ancestors[-1].children.append(item)
                self.items.append(item)


# Traceback (AttributeError)
ok: [s-srv1leaf2-2] => {
"purge_vnis": [
9999
]
}
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_yZvBEZ/ansible_module_nxos_vxlan_vtep_vni.py", line 589, in <module>
main()
File "/tmp/ansible_yZvBEZ/ansible_module_nxos_vxlan_vtep_vni.py", line 533, in main
existing, interface_exist = invoke('get_existing', module, args)
File "/tmp/ansible_yZvBEZ/ansible_module_nxos_vxlan_vtep_vni.py", line 316, in invoke
return func(*args, **kwargs)
File "/tmp/ansible_yZvBEZ/ansible_module_nxos_vxlan_vtep_vni.py", line 377, in get_existing
temp_config = netcfg.get_section(parents)
File "/tmp/ansible_yZvBEZ/ansible_module_nxos_vxlan_vtep_vni.py", line 192, in get_section
section = self.get_section_objects(path)
File "/tmp/ansible_yZvBEZ/ansible_module_nxos_vxlan_vtep_vni.py", line 203, in get_section_objects
return self.expand_section(obj)
File "/tmp/ansible_yZvBEZ/ansible_module_nxos_vxlan_vtep_vni.py", line 175, in expand_section
if child in S:
File "/tmp/ansible_yZvBEZ/ansible_modlib.zip/ansible/module_utils/netcfg.py", line 47, in __eq__
AttributeError: 'str' object has no attribute 'line'

failed: [s-srv1leaf2-2] (item=9999) => {
"failed": true,
"invocation": {
"module_name": "nxos_vxlan_vtep_vni"
},
"item": 9999,

# Fixed code
def add(self, lines, parents=None):
    ancestors = list()
    offset = 0
    obj = None

    ## global config command
    if not parents:
        for line in lines:
            item = ConfigLine(line)
            item.raw = line
            if item not in self.items:
                self.items.append(item)

    else:
        for index, p in enumerate(parents):
            try:
                i = index + 1
                obj = self.get_block(parents[:i])[0]
                ancestors.append(obj)

            except ValueError:
                # add parent to config
                offset = index * self._indent
                obj = ConfigLine(p)
                obj.raw = p.rjust(len(p) + offset)
                if ancestors:
                    obj._parents = list(ancestors)
                    ancestors[-1]._children.append(obj)
                self.items.append(obj)
                ancestors.append(obj)

        # add child objects
        for line in lines:
            # check if child already exists
            for child in ancestors[-1]._children:
                if child.text == line:
                    break
            else:
                offset = len(parents) * self._indent
                item = ConfigLine(line)
                item.raw = line.rjust(len(line) + offset)
                item._parents = ancestors
                ancestors[-1]._children.append(item)
                self.items.append(item)