# Buggy code
def ip6_interfaces():
    """
    Provide a dict of the connected interfaces and their ip6 addresses
    The addresses will be passed as a list for each interface
    """
    # Provides:
    #   ip_interfaces

    if salt.utils.is_proxy() or not __opts__.get("ipv6", True):
        return {}

    ret = {}
    ifaces = _get_interfaces()
    for face in ifaces:
        iface_ips = []
        for inet in ifaces[face].get("inet6", []):
            if "address" in inet:
                iface_ips.append(inet["address"])
        for secondary in ifaces[face].get("secondary", []):
            if "address" in secondary:
                iface_ips.append(secondary["address"])
        ret[face] = iface_ips
    return {"ip6_interfaces": ret}


# Traceback (TypeError)
[ERROR   ] An un-handled exception was caught by salt's global exception handler:
TypeError: can't serialize IPv6Address('fd00::ca0e:14ff:fea8:2344')
Traceback (most recent call last):
File "/usr/lib/python-exec/python2.7/salt-call", line 11, in <module>
salt_call()
File "/usr/lib64/python2.7/site-packages/salt/scripts.py", line 379, in salt_call
client.run()
File "/usr/lib64/python2.7/site-packages/salt/cli/call.py", line 48, in run
caller = salt.cli.caller.Caller.factory(self.config)
File "/usr/lib64/python2.7/site-packages/salt/cli/caller.py", line 79, in factory
return ZeroMQCaller(opts, **kwargs)
File "/usr/lib64/python2.7/site-packages/salt/cli/caller.py", line 274, in __init__
super(ZeroMQCaller, self).__init__(opts)
File "/usr/lib64/python2.7/site-packages/salt/cli/caller.py", line 102, in __init__
self.minion = salt.minion.SMinion(opts)
File "/usr/lib64/python2.7/site-packages/salt/minion.py", line 669, in __init__
self.gen_modules(initial_load=True)
File "/usr/lib64/python2.7/site-packages/salt/minion.py", line 717, in gen_modules
pillarenv=self.opts.get('pillarenv'),
File "/usr/lib64/python2.7/site-packages/salt/pillar/__init__.py", line 162, in compile_pillar
dictkey='pillar',
File "/usr/lib64/python2.7/site-packages/salt/utils/async.py", line 75, in wrap
ret = self._block_future(ret)
File "/usr/lib64/python2.7/site-packages/salt/utils/async.py", line 85, in _block_future
return future.result()
File "/usr/lib64/python2.7/site-packages/tornado/concurrent.py", line 237, in result
raise_exc_info(self._exc_info)
File "/usr/lib64/python2.7/site-packages/tornado/gen.py", line 285, in wrapper
yielded = next(result)
File "/usr/lib64/python2.7/site-packages/salt/transport/zeromq.py", line 190, in crypted_transfer_decode_dictentry
self._package_load(self.auth.crypticle.dumps(load)),
File "/usr/lib64/python2.7/site-packages/salt/crypt.py", line 1267, in dumps
return self.encrypt(self.PICKLE_PAD + self.serial.dumps(obj))
File "/usr/lib64/python2.7/site-packages/salt/payload.py", line 181, in dumps
return msgpack.dumps(msg, use_bin_type=use_bin_type)
File "/usr/lib64/python2.7/site-packages/msgpack/__init__.py", line 47, in packb
return Packer(**kwargs).pack(o)
File "msgpack/_packer.pyx", line 231, in msgpack._packer.Packer.pack (msgpack/_packer.cpp:3661)
File "msgpack/_packer.pyx", line 233, in msgpack._packer.Packer.pack (msgpack/_packer.cpp:3503)
File "msgpack/_packer.pyx", line 192, in msgpack._packer.Packer._pack (msgpack/_packer.cpp:2657)
File "msgpack/_packer.pyx", line 192, in msgpack._packer.Packer._pack (msgpack/_packer.cpp:2657)
File "msgpack/_packer.pyx", line 192, in msgpack._packer.Packer._pack (msgpack/_packer.cpp:2657)
File "msgpack/_packer.pyx", line 221, in msgpack._packer.Packer._pack (msgpack/_packer.cpp:3230)
File "msgpack/_packer.pyx", line 228, in msgpack._packer.Packer._pack (msgpack/_packer.cpp:3382)
TypeError: can't serialize IPv6Address('fd00::ca0e:14ff:fea8:2344')

# Fixed code
def ip6_interfaces():
    """
    Provide a dict of the connected interfaces and their ip6 addresses
    The addresses will be passed as a list for each interface
    """
    # Provides:
    #   ip_interfaces

    if salt.utils.is_proxy():
        return {}

    ret = {}
    ifaces = _get_interfaces()
    for face in ifaces:
        iface_ips = []
        for inet in ifaces[face].get("inet6", []):
            if "address" in inet:
                iface_ips.append(inet["address"])
        for secondary in ifaces[face].get("secondary", []):
            if "address" in secondary:
                iface_ips.append(secondary["address"])
        ret[face] = iface_ips
    return {"ip6_interfaces": ret}