# Buggy code
def create_connection_vlan(self):
    cmd = [self.nmcli_bin]
    cmd.append("con")
    cmd.append("add")
    cmd.append("type")
    cmd.append("vlan")
    cmd.append("con-name")

    if self.conn_name is not None:
        cmd.append(self.conn_name)
    elif self.ifname is not None:
        cmd.append(self.ifname)
    else:
        cmd.append("vlan%s" % self.vlanid)

    cmd.append("ifname")
    if self.ifname is not None:
        cmd.append(self.ifname)
    elif self.conn_name is not None:
        cmd.append(self.conn_name)
    else:
        cmd.append("vlan%s" % self.vlanid)

    params = {
        "dev": self.vlandev,
        "id": self.vlanid,
        "ip4": self.ip4 or "",
        "gw4": self.gw4 or "",
        "ip6": self.ip6 or "",
        "gw6": self.gw6 or "",
        "autoconnect": self.bool_to_string(self.autoconnect),
    }
    for k, v in params.items():
        cmd.extend([k, v])

    return cmd


# Traceback (nTypeError)
TASK [Add Vlan 120] ************************************************************
task path: /root/ansible/vlan.yaml:5
fatal: [192.168.122.144]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "module_stderr": "Shared connection to 192.168.122.144 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n  File \"/root/.ansible/tmp/ansible-tmp-1562811604.6034448-71465935769547/AnsiballZ_nmcli.py\", line 114, in <module>\r\n    _ansiballz_main()\r\n  File \"/root/.ansible/tmp/ansible-tmp-1562811604.6034448-71465935769547/AnsiballZ_nmcli.py\", line 106, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/root/.ansible/tmp/ansible-tmp-1562811604.6034448-71465935769547/AnsiballZ_nmcli.py\", line 49, in invoke_module\r\n    imp.load_module('__main__', mod, module, MOD_DESC)\r\n  File \"/tmp/ansible_nmcli_payload_divn_m/__main__.py\", line 1549, in <module>\r\n  File \"/tmp/ansible_nmcli_payload_divn_m/__main__.py\", line 1532, in main\r\n  File \"/tmp/ansible_nmcli_payload_divn_m/__main__.py\", line 1388, in create_connection\r\n  File \"/tmp/ansible_nmcli_payload_divn_m/__main__.py\", line 682, in execute_command\r\n  File \"/tmp/ansible_nmcli_payload_divn_m/ansible_nmcli_payload.zip/ansible/module_utils/basic.py\", line 2477, in run_command\r\n  File \"/usr/lib64/python2.7/posixpath.py\", line 293, in expandvars\r\n    if '$' not in path:\r\nTypeError: argument of type 'int' is not iterable\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

# Fixed code
def create_connection_vlan(self):
    cmd = [self.nmcli_bin]
    cmd.append("con")
    cmd.append("add")
    cmd.append("type")
    cmd.append("vlan")
    cmd.append("con-name")

    if self.conn_name is not None:
        cmd.append(self.conn_name)
    elif self.ifname is not None:
        cmd.append(self.ifname)
    else:
        cmd.append("vlan%s" % self.vlanid)

    cmd.append("ifname")
    if self.ifname is not None:
        cmd.append(self.ifname)
    elif self.conn_name is not None:
        cmd.append(self.conn_name)
    else:
        cmd.append("vlan%s" % self.vlanid)

    params = {
        "dev": self.vlandev,
        "id": str(self.vlanid),
        "ip4": self.ip4 or "",
        "gw4": self.gw4 or "",
        "ip6": self.ip6 or "",
        "gw6": self.gw6 or "",
        "autoconnect": self.bool_to_string(self.autoconnect),
    }
    for k, v in params.items():
        cmd.extend([k, v])

    return cmd