# Buggy code
def __init__(self, module):
    self.module = module

    if module.params["zone"] is None:
        if module.params["record"][-1] != ".":
            self.module.fail_json(
                msg="record must be absolute when omitting zone parameter"
            )
        self.zone = self.lookup_zone()
    else:
        self.zone = module.params["zone"]

        if self.zone[-1] != ".":
            self.zone += "."

    if module.params["record"][-1] != ".":
        self.fqdn = module.params["record"] + "." + self.zone
    else:
        self.fqdn = module.params["record"]

    if module.params["key_name"]:
        try:
            self.keyring = dns.tsigkeyring.from_text(
                {module.params["key_name"]: module.params["key_secret"]}
            )
        except TypeError:
            module.fail_json(msg="Missing key_secret")
        except binascii_error as e:
            module.fail_json(msg="TSIG key error: %s" % to_native(e))
    else:
        self.keyring = None

    if module.params["key_algorithm"] == "hmac-md5":
        self.algorithm = "HMAC-MD5.SIG-ALG.REG.INT"
    else:
        self.algorithm = module.params["key_algorithm"]

    if self.module.params["type"].lower() == "txt":
        self.value = list(map(self.txt_helper, self.module.params["value"]))
    else:
        self.value = self.module.params["value"]

    self.dns_rc = 0


# Traceback (TypeError)
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/net_tools/nsupdate.py
Pipelining is enabled.
<dns01.lpr> ESTABLISH SSH CONNECTION FOR USER: None
<dns01.lpr> SSH: EXEC ssh -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o 'IdentityFile="/etc/ansible/master.rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/eb56091f4e dns01.lpr '/bin/sh -c '"'"'/usr/bin/python &amp;&amp; sleep 0'"'"''
<dns01.lpr> (1, '', 'Traceback (most recent call last):\n  File "<stdin>", line 114, in <module>\n  File "<stdin>", line 106, in _ansiballz_main\n  File "<stdin>", line 49, in invoke_module\n  File "/tmp/ansible_nsupdate_payload_OWViZX/__main__.py", line 430, in <module>\n  File "/tmp/ansible_nsupdate_payload_OWViZX/__main__.py", line 408, in main\n  File "/tmp/ansible_nsupdate_payload_OWViZX/__main__.py", line 225, in __init__\nTypeError: argument 2 to map() must support iteration\n')
<dns01.lpr> Failed to connect to the host via ssh: Traceback (most recent call last):
File "<stdin>", line 114, in <module>
File "<stdin>", line 106, in _ansiballz_main
File "<stdin>", line 49, in invoke_module
File "/tmp/ansible_nsupdate_payload_OWViZX/__main__.py", line 430, in <module>
File "/tmp/ansible_nsupdate_payload_OWViZX/__main__.py", line 408, in main
File "/tmp/ansible_nsupdate_payload_OWViZX/__main__.py", line 225, in __init__
TypeError: argument 2 to map() must support iteration
The full traceback is:
Traceback (most recent call last):
File "<stdin>", line 114, in <module>
File "<stdin>", line 106, in _ansiballz_main
File "<stdin>", line 49, in invoke_module
File "/tmp/ansible_nsupdate_payload_OWViZX/__main__.py", line 430, in <module>
File "/tmp/ansible_nsupdate_payload_OWViZX/__main__.py", line 408, in main
File "/tmp/ansible_nsupdate_payload_OWViZX/__main__.py", line 225, in __init__
TypeError: argument 2 to map() must support iteration

failed: [dns01.lpr] (item={u'state': u'absent', u'type': u'TXT', u'name': u'_acme-challenge.awx', u'ttl': u'3600'}) => {
"ansible_loop_var": "item",
"changed": false,
"item": {
"name": "_acme-challenge.awx",
"state": "absent",
"ttl": "3600",
"type": "TXT"
},
"module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 114, in <module>\n  File \"<stdin>\", line 106, in _ansiballz_main\n  File \"<stdin>\", line 49, in invoke_module\n  File \"/tmp/ansible_nsupdate_payload_OWViZX/__main__.py\", line 430, in <module>\n  File \"/tmp/ansible_nsupdate_payload_OWViZX/__main__.py\", line 408, in main\n  File \"/tmp/ansible_nsupdate_payload_OWViZX/__main__.py\", line 225, in __init__\nTypeError: argument 2 to map() must support iteration\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}

# Fixed code
def __init__(self, module):
    self.module = module

    if module.params["zone"] is None:
        if module.params["record"][-1] != ".":
            self.module.fail_json(
                msg="record must be absolute when omitting zone parameter"
            )
        self.zone = self.lookup_zone()
    else:
        self.zone = module.params["zone"]

        if self.zone[-1] != ".":
            self.zone += "."

    if module.params["record"][-1] != ".":
        self.fqdn = module.params["record"] + "." + self.zone
    else:
        self.fqdn = module.params["record"]

    if module.params["key_name"]:
        try:
            self.keyring = dns.tsigkeyring.from_text(
                {module.params["key_name"]: module.params["key_secret"]}
            )
        except TypeError:
            module.fail_json(msg="Missing key_secret")
        except binascii_error as e:
            module.fail_json(msg="TSIG key error: %s" % to_native(e))
    else:
        self.keyring = None

    if module.params["key_algorithm"] == "hmac-md5":
        self.algorithm = "HMAC-MD5.SIG-ALG.REG.INT"
    else:
        self.algorithm = module.params["key_algorithm"]

    if (
        self.module.params["type"].lower() == "txt"
        and self.module.params["value"] is not None
    ):
        self.value = list(map(self.txt_helper, self.module.params["value"]))
    else:
        self.value = self.module.params["value"]

    self.dns_rc = 0