Repository: ansible/ansible

Issue:
azure_rm_dnsrecordset TXT record creation results in msrest.exceptions.SerializationError
<!---
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release, and devel branch are affected too.
Always add information AFTER of these html comments.
-->

##### ISSUE TYPE
<!--- Pick one below and delete the rest -->
 - Bug Report

##### COMPONENT NAME
<!---
Insert below this comment the name of the module, plugin, task or feature.
Do not include extra details here, e.g. "vyos_command" not "the network module vyos_command" or the full path
-->
azure_rm_dnsrecordset

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes below -->
```
(venv) [tony@localhost ansible_2.5-rc3]$ ansible --version
ansible 2.5.0rc3 (stable-2.5 144e5ae65a) last updated 2018/03/18 20:38:45 (GMT +100)
  config file = None
  configured module search path = [u'/home/tony/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/tony/devel/ansible_2.5-rc3/lib/ansible
  executable location = ./bin/ansible
  python version = 2.7.14 (default, Dec  9 2017, 20:52:12) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
```

##### CONFIGURATION
<!---
If using Ansible 2.4 or above, paste the results of "ansible-config dump --only-changed"
Otherwise, mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->

##### OS / ENVIRONMENT
<!---
Mention the OS you are running Ansible from, and the OS you are
managing, or say "N/A" for anything that is not platform-specific.
Also mention the specific version of what you are trying to control,
e.g. if this is a network bug the version of firmware on the network device.
-->
CentOS Linux release 7.4.1708 (Core)

```
$ pip list

adal (0.5.1)
ansible (2.5.0rc3)
applicationinsights (0.11.2)
argcomplete (1.9.4)
asn1crypto (0.24.0)
azure-cli-core (2.0.29)
azure-cli-nspkg (3.0.2)
azure-common (1.1.8)
azure-mgmt-batch (4.1.0)
azure-mgmt-compute (2.1.0)
azure-mgmt-containerinstance (0.3.1)
azure-mgmt-containerregistry (1.0.1)
azure-mgmt-containerservice (2.0.0)
azure-mgmt-dns (1.2.0)
azure-mgmt-keyvault (0.40.0)
azure-mgmt-network (1.7.1)
azure-mgmt-nspkg (2.0.0)
azure-mgmt-rdbms (0.2.0rc1)
azure-mgmt-resource (1.2.2)
azure-mgmt-sql (0.7.1)
azure-mgmt-storage (1.5.0)
azure-mgmt-web (0.32.0)
azure-nspkg (2.0.0)
azure-storage (0.35.1)
bcrypt (3.1.4)
certifi (2018.1.18)
cffi (1.11.5)
chardet (3.0.4)
colorama (0.3.9)
cryptography (2.1.4)
enum34 (1.1.6)
humanfriendly (4.8)
idna (2.6)
ipaddress (1.0.19)
isodate (0.6.0)
Jinja2 (2.10)
jmespath (0.9.3)
keyring (11.0.0)
knack (0.3.1)
MarkupSafe (1.0)
monotonic (1.4)
msrest (0.4.27)
msrestazure (0.4.22)
oauthlib (2.0.6)
packaging (17.1)
paramiko (2.4.1)
pip (9.0.2)
pyasn1 (0.4.2)
pycparser (2.18)
Pygments (2.2.0)
PyJWT (1.6.1)
PyNaCl (1.2.1)
pyOpenSSL (17.5.0)
pyparsing (2.2.0)
python-dateutil (2.7.0)
PyYAML (3.12)
requests (2.18.4)
requests-oauthlib (0.8.0)
SecretStorage (2.3.1)
setuptools (39.0.1)
six (1.11.0)
tabulate (0.7.7)
urllib3 (1.22)
wheel (0.30.0)
```

##### SUMMARY
<!--- Explain the problem briefly -->
Using azure_rm_dnsrecordset to create Azure DNS TXT record set results in msrest.exceptions.SerializationError

##### STEPS TO REPRODUCE
<!---
For bugs, show exactly how to reproduce the problem, using a minimal test-case.
For new features, show how the feature would be used.
-->

<!--- Paste example playbooks or commands between quotes below -->
```yaml
---
- name: demonstrate azure_rm_dnsrecordset TXT record issue
  hosts: localhost
  connection: local
  gather_facts: False

  vars:
    az_resource_group: Testing
    az_location: ukwest
    az_dnszone: 'test.uk'


  tasks:

    - name: create resource group
      azure_rm_resourcegroup:
        name: "{{ az_resource_group }}"
        location: "{{ az_location }}"
        state: present
      register: azure_resourcegroup

    - name: create a DNS zone
      azure_rm_dnszone:
        resource_group: "{{ az_resource_group }}"
        name: "{{ az_dnszone }}"
        state: present

    - name: ensure an "A" record set with multiple records
      azure_rm_dnsrecordset:
        resource_group: "{{ az_resource_group }}"
        relative_name: www
        zone_name: "{{ az_dnszone }}"
        record_type: A
        state: present
        records:
          - entry: 192.168.100.101
          - entry: 192.168.100.102
          - entry: 192.168.100.103

    - name: create TXT record in a new record set
      azure_rm_dnsrecordset:
        resource_group: "{{ az_resource_group }}"
        relative_name: "mail.{{ az_dnszone }}"
        zone_name: "{{ az_dnszone }}"
        record_type: TXT
        records:
        - entry: 'v=spf1 a -all'
```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
Both A and TXT records created in the Azure hosted DNS Zone

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->
A records are created but TXT record attempt generates an error
<!--- Paste verbatim command output between quotes below -->
```
(venv) [tony@localhost ansible_2.5-rc3]$ ansible-playbook azure_rm_dnsrecordset.yml -vvvv
ansible-playbook 2.5.0rc3 (stable-2.5 144e5ae65a) last updated 2018/03/18 20:38:45 (GMT +100)
  config file = None
  configured module search path = [u'/home/tony/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/tony/devel/ansible_2.5-rc3/lib/ansible
  executable location = ./bin/ansible-playbook
  python version = 2.7.14 (default, Dec  9 2017, 20:52:12) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
No config file found; using defaults
setting up inventory plugins
 [WARNING]: Unable to parse /etc/ansible/hosts as an inventory source

 [WARNING]: No inventory was parsed, only implicit localhost is available

 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

Loading callback plugin default of type stdout, v2.0 from /home/tony/devel/ansible_2.5-rc3/lib/ansible/plugins/callback/default.pyc

PLAYBOOK: azure_rm_dnsrecordset.yml ******************************************************************************************************************************
1 plays in azure_rm_dnsrecordset.yml

PLAY [demonstrate azure_rm_dnsrecordset TXT record issue] ********************************************************************************************************
META: ran handlers

TASK [create resource group] *************************************************************************************************************************************
task path: /home/tony/devel/ansible_2.5-rc3/azure_rm_dnsrecordset.yml:15
Using module file /home/tony/devel/ansible_2.5-rc3/lib/ansible/modules/cloud/azure/azure_rm_resourcegroup.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: tony
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/tony/.ansible/tmp/ansible-tmp-1521408427.44-127941676971799 `" && echo ansible-tmp-1521408427.44-127941676971799="` echo /home/tony/.ansible/tmp/ansible-tmp-1521408427.44-127941676971799 `" ) && sleep 0'
<127.0.0.1> PUT /home/tony/.ansible/tmp/ansible-local-17458sfU_dJ/tmpHcSrjk TO /home/tony/.ansible/tmp/ansible-tmp-1521408427.44-127941676971799/azure_rm_resourcegroup.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/tony/.ansible/tmp/ansible-tmp-1521408427.44-127941676971799/ /home/tony/.ansible/tmp/ansible-tmp-1521408427.44-127941676971799/azure_rm_resourcegroup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/home/tony/devel/ansible_2.5-rc3/venv/bin/python /home/tony/.ansible/tmp/ansible-tmp-1521408427.44-127941676971799/azure_rm_resourcegroup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/tony/.ansible/tmp/ansible-tmp-1521408427.44-127941676971799/ > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
    "changed": true,
    "contains_resources": false,
    "invocation": {
        "module_args": {
            "ad_user": null,
            "api_profile": "latest",
            "append_tags": true,
            "auth_source": null,
            "cert_validation_mode": null,
            "client_id": null,
            "cloud_environment": null,
            "force": false,
            "location": "ukwest",
            "name": "Testing",
            "password": null,
            "profile": null,
            "secret": null,
            "state": "present",
            "subscription_id": null,
            "tags": null,
            "tenant": null
        }
    },
    "state": {
        "id": "/subscriptions/c87516cf-4782-45a0-8597-fb290288f2e7/resourceGroups/Testing",
        "location": "ukwest",
        "name": "Testing",
        "provisioning_state": "Succeeded",
        "tags": null
    }
}

TASK [Create a DNS zone] *****************************************************************************************************************************************
task path: /home/tony/devel/ansible_2.5-rc3/azure_rm_dnsrecordset.yml:22
Using module file /home/tony/devel/ansible_2.5-rc3/lib/ansible/modules/cloud/azure/azure_rm_dnszone.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: tony
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/tony/.ansible/tmp/ansible-tmp-1521408430.64-25732376220852 `" && echo ansible-tmp-1521408430.64-25732376220852="` echo /home/tony/.ansible/tmp/ansible-tmp-1521408430.64-25732376220852 `" ) && sleep 0'
<127.0.0.1> PUT /home/tony/.ansible/tmp/ansible-local-17458sfU_dJ/tmpcB038t TO /home/tony/.ansible/tmp/ansible-tmp-1521408430.64-25732376220852/azure_rm_dnszone.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/tony/.ansible/tmp/ansible-tmp-1521408430.64-25732376220852/ /home/tony/.ansible/tmp/ansible-tmp-1521408430.64-25732376220852/azure_rm_dnszone.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/home/tony/devel/ansible_2.5-rc3/venv/bin/python /home/tony/.ansible/tmp/ansible-tmp-1521408430.64-25732376220852/azure_rm_dnszone.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/tony/.ansible/tmp/ansible-tmp-1521408430.64-25732376220852/ > /dev/null 2>&1 && sleep 0'
 [WARNING]: Azure API profile latest does not define an entry for DnsManagementClient

changed: [localhost] => {
    "changed": true,
    "check_mode": false,
    "invocation": {
        "module_args": {
            "ad_user": null,
            "api_profile": "latest",
            "append_tags": true,
            "auth_source": null,
            "cert_validation_mode": null,
            "client_id": null,
            "cloud_environment": null,
            "name": "testing.uk",
            "password": null,
            "profile": null,
            "resource_group": "Testing",
            "secret": null,
            "state": "present",
            "subscription_id": null,
            "tags": null,
            "tenant": null
        }
    },
    "state": {
        "id": "/subscriptions/c87516cf-4782-45a0-8597-fb290288f2e7/resourceGroups/testing/providers/Microsoft.Network/dnszones/testing.uk",
        "name": "testing.uk",
        "name_servers": [
            "ns1-07.azure-dns.com.",
            "ns2-07.azure-dns.net.",
            "ns3-07.azure-dns.org.",
            "ns4-07.azure-dns.info."
        ],
        "number_of_record_sets": 2,
        "tags": {}
    }
}

TASK [ensure an "A" record set with multiple records] ************************************************************************************************************
task path: /home/tony/devel/ansible_2.5-rc3/azure_rm_dnsrecordset.yml:28
Using module file /home/tony/devel/ansible_2.5-rc3/lib/ansible/modules/cloud/azure/azure_rm_dnsrecordset.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: tony
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/tony/.ansible/tmp/ansible-tmp-1521408434.66-105106934414168 `" && echo ansible-tmp-1521408434.66-105106934414168="` echo /home/tony/.ansible/tmp/ansible-tmp-1521408434.66-105106934414168 `" ) && sleep 0'
<127.0.0.1> PUT /home/tony/.ansible/tmp/ansible-local-17458sfU_dJ/tmpgQXMRj TO /home/tony/.ansible/tmp/ansible-tmp-1521408434.66-105106934414168/azure_rm_dnsrecordset.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/tony/.ansible/tmp/ansible-tmp-1521408434.66-105106934414168/ /home/tony/.ansible/tmp/ansible-tmp-1521408434.66-105106934414168/azure_rm_dnsrecordset.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/home/tony/devel/ansible_2.5-rc3/venv/bin/python /home/tony/.ansible/tmp/ansible-tmp-1521408434.66-105106934414168/azure_rm_dnsrecordset.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/tony/.ansible/tmp/ansible-tmp-1521408434.66-105106934414168/ > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
    "changed": true,
    "invocation": {
        "module_args": {
            "ad_user": null,
            "api_profile": "latest",
            "append_tags": true,
            "auth_source": null,
            "cert_validation_mode": null,
            "client_id": null,
            "cloud_environment": null,
            "password": null,
            "profile": null,
            "record_mode": "purge",
            "record_type": "A",
            "records": [
                {
                    "entry": "192.168.100.101",
                    "ipv4_address": "192.168.100.101"
                },
                {
                    "entry": "192.168.100.102",
                    "ipv4_address": "192.168.100.102"
                },
                {
                    "entry": "192.168.100.103",
                    "ipv4_address": "192.168.100.103"
                }
            ],
            "relative_name": "www",
            "resource_group": "Testing",
            "secret": null,
            "state": "present",
            "subscription_id": null,
            "tags": null,
            "tenant": null,
            "time_to_live": 3600,
            "zone_name": "testing.uk"
        }
    }
}

TASK [create TXT record in a new record set] *********************************************************************************************************************
task path: /home/tony/devel/ansible_2.5-rc3/azure_rm_dnsrecordset.yml:40
Using module file /home/tony/devel/ansible_2.5-rc3/lib/ansible/modules/cloud/azure/azure_rm_dnsrecordset.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: tony
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/tony/.ansible/tmp/ansible-tmp-1521408438.89-195623484547904 `" && echo ansible-tmp-1521408438.89-195623484547904="` echo /home/tony/.ansible/tmp/ansible-tmp-1521408438.89-195623484547904 `" ) && sleep 0'
<127.0.0.1> PUT /home/tony/.ansible/tmp/ansible-local-17458sfU_dJ/tmpHaYgU6 TO /home/tony/.ansible/tmp/ansible-tmp-1521408438.89-195623484547904/azure_rm_dnsrecordset.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/tony/.ansible/tmp/ansible-tmp-1521408438.89-195623484547904/ /home/tony/.ansible/tmp/ansible-tmp-1521408438.89-195623484547904/azure_rm_dnsrecordset.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/home/tony/devel/ansible_2.5-rc3/venv/bin/python /home/tony/.ansible/tmp/ansible-tmp-1521408438.89-195623484547904/azure_rm_dnsrecordset.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/tony/.ansible/tmp/ansible-tmp-1521408438.89-195623484547904/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_sRX1FZ/ansible_module_azure_rm_dnsrecordset.py", line 387, in <module>
    main()
  File "/tmp/ansible_sRX1FZ/ansible_module_azure_rm_dnsrecordset.py", line 384, in main
    AzureRMRecordSet()
  File "/tmp/ansible_sRX1FZ/ansible_module_azure_rm_dnsrecordset.py", line 273, in __init__
    super(AzureRMRecordSet, self).__init__(self.module_arg_spec, required_if=required_if, supports_check_mode=True)
  File "/tmp/ansible_sRX1FZ/ansible_modlib.zip/ansible/module_utils/azure_rm_common.py", line 345, in __init__
  File "/tmp/ansible_sRX1FZ/ansible_module_azure_rm_dnsrecordset.py", line 338, in exec_module
    rsout = self.dns_client.record_sets.create_or_update(self.resource_group, self.zone_name, self.relative_name, self.record_type, record_set)
  File "/home/tony/devel/ansible_2.5-rc3/venv/lib/python2.7/site-packages/azure/mgmt/dns/operations/record_sets_operations.py", line 189, in create_or_update
    body_content = self._serialize.body(parameters, 'RecordSet')
  File "/home/tony/devel/ansible_2.5-rc3/venv/lib/python2.7/site-packages/msrest/serialization.py", line 476, in body
    return self._serialize(data, data_type, **kwargs)
  File "/home/tony/devel/ansible_2.5-rc3/venv/lib/python2.7/site-packages/msrest/serialization.py", line 399, in _serialize
    target_obj, data_type, **kwargs)
  File "/home/tony/devel/ansible_2.5-rc3/venv/lib/python2.7/site-packages/msrest/serialization.py", line 611, in serialize_data
    return self._serialize(data, **kwargs)
  File "/home/tony/devel/ansible_2.5-rc3/venv/lib/python2.7/site-packages/msrest/serialization.py", line 422, in _serialize
    orig_attr, attr_type, **kwargs)
  File "/home/tony/devel/ansible_2.5-rc3/venv/lib/python2.7/site-packages/msrest/serialization.py", line 604, in serialize_data
    data, data_type[1:-1], **kwargs)
  File "/home/tony/devel/ansible_2.5-rc3/venv/lib/python2.7/site-packages/msrest/serialization.py", line 660, in serialize_iter
    self.serialize_data(d, iter_type, **kwargs))
  File "/home/tony/devel/ansible_2.5-rc3/venv/lib/python2.7/site-packages/msrest/serialization.py", line 611, in serialize_data
    return self._serialize(data, **kwargs)
  File "/home/tony/devel/ansible_2.5-rc3/venv/lib/python2.7/site-packages/msrest/serialization.py", line 422, in _serialize
    orig_attr, attr_type, **kwargs)
  File "/home/tony/devel/ansible_2.5-rc3/venv/lib/python2.7/site-packages/msrest/serialization.py", line 604, in serialize_data
    data, data_type[1:-1], **kwargs)
  File "/home/tony/devel/ansible_2.5-rc3/venv/lib/python2.7/site-packages/msrest/serialization.py", line 655, in serialize_iter
    raise SerializationError("Refuse str type as a valid iter type.")
msrest.exceptions.SerializationError: Refuse str type as a valid iter type.

fatal: [localhost]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_sRX1FZ/ansible_module_azure_rm_dnsrecordset.py\", line 387, in <module>\n    main()\n  File \"/tmp/ansible_sRX1FZ/ansible_module_azure_rm_dnsrecordset.py\", line 384, in main\n    AzureRMRecordSet()\n  File \"/tmp/ansible_sRX1FZ/ansible_module_azure_rm_dnsrecordset.py\", line 273, in __init__\n    super(AzureRMRecordSet, self).__init__(self.module_arg_spec, required_if=required_if, supports_check_mode=True)\n  File \"/tmp/ansible_sRX1FZ/ansible_modlib.zip/ansible/module_utils/azure_rm_common.py\", line 345, in __init__\n  File \"/tmp/ansible_sRX1FZ/ansible_module_azure_rm_dnsrecordset.py\", line 338, in exec_module\n    rsout = self.dns_client.record_sets.create_or_update(self.resource_group, self.zone_name, self.relative_name, self.record_type, record_set)\n  File \"/home/tony/devel/ansible_2.5-rc3/venv/lib/python2.7/site-packages/azure/mgmt/dns/operations/record_sets_operations.py\", line 189, in create_or_update\n    body_content = self._serialize.body(parameters, 'RecordSet')\n  File \"/home/tony/devel/ansible_2.5-rc3/venv/lib/python2.7/site-packages/msrest/serialization.py\", line 476, in body\n    return self._serialize(data, data_type, **kwargs)\n  File \"/home/tony/devel/ansible_2.5-rc3/venv/lib/python2.7/site-packages/msrest/serialization.py\", line 399, in _serialize\n    target_obj, data_type, **kwargs)\n  File \"/home/tony/devel/ansible_2.5-rc3/venv/lib/python2.7/site-packages/msrest/serialization.py\", line 611, in serialize_data\n    return self._serialize(data, **kwargs)\n  File \"/home/tony/devel/ansible_2.5-rc3/venv/lib/python2.7/site-packages/msrest/serialization.py\", line 422, in _serialize\n    orig_attr, attr_type, **kwargs)\n  File \"/home/tony/devel/ansible_2.5-rc3/venv/lib/python2.7/site-packages/msrest/serialization.py\", line 604, in serialize_data\n    data, data_type[1:-1], **kwargs)\n  File \"/home/tony/devel/ansible_2.5-rc3/venv/lib/python2.7/site-packages/msrest/serialization.py\", line 660, in serialize_iter\n    self.serialize_data(d, iter_type, **kwargs))\n  File \"/home/tony/devel/ansible_2.5-rc3/venv/lib/python2.7/site-packages/msrest/serialization.py\", line 611, in serialize_data\n    return self._serialize(data, **kwargs)\n  File \"/home/tony/devel/ansible_2.5-rc3/venv/lib/python2.7/site-packages/msrest/serialization.py\", line 422, in _serialize\n    orig_attr, attr_type, **kwargs)\n  File \"/home/tony/devel/ansible_2.5-rc3/venv/lib/python2.7/site-packages/msrest/serialization.py\", line 604, in serialize_data\n    data, data_type[1:-1], **kwargs)\n  File \"/home/tony/devel/ansible_2.5-rc3/venv/lib/python2.7/site-packages/msrest/serialization.py\", line 655, in serialize_iter\n    raise SerializationError(\"Refuse str type as a valid iter type.\")\nmsrest.exceptions.SerializationError: Refuse str type as a valid iter type.\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE",
    "rc": 1
}
        to retry, use: --limit @/home/tony/devel/ansible_2.5-rc3/azure_rm_dnsrecordset.retry

PLAY RECAP *******************************************************************************************************************************************************
localhost                  : ok=3    changed=3    unreachable=0    failed=1

```



Discussion:
Files identified in the description:
* [lib/ansible/modules/cloud/azure/azure_rm_dnsrecordset.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/azure/azure_rm_dnsrecordset.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @haroldwongms @nitzmahone @trstringer @xscript @yuwzho @zikalino
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
@tonyskidmore i will check this issue
@zikalino Any news on this?
Everything up to date
```
╭─stubbsrem@tnf27 ~/code/ide 
╰─$ pip -V           
pip 9.0.3 from /usr/local/lib/python3.5/dist-packages (python 3.5)
╭─stubbsrem@tnf27 ~/code/ide  
╰─$ pip list         
adal (0.5.0)
anglerfish (2.5.0)
ansible (2.6.0)
ansible-cmdb (1.25)
ansible-container (0.9.2)
ansible-lint (3.4.15)
applicationinsights (0.11.2)
apturl (0.5.2)
argcomplete (1.9.4)
asn1crypto (0.23.0)
awscli (1.11.13)
azure (3.0.0)
azure-batch (4.0.0)
azure-batch-extensions (1.0.1)
azure-cli (2.0.30)
azure-cli-acr (2.0.22)
azure-cli-acs (2.0.30)
azure-cli-advisor (0.5.0)
azure-cli-appservice (0.1.30)
azure-cli-backup (1.1.0)
azure-cli-batch (3.1.11)
azure-cli-batchai (0.1.6)
azure-cli-billing (0.1.7)
azure-cli-cdn (0.0.13)
azure-cli-cloud (2.0.12)
azure-cli-cognitiveservices (0.1.11)
azure-cli-command-modules-nspkg (2.0.1)
azure-cli-configure (2.0.14)
azure-cli-consumption (0.2.2)
azure-cli-container (0.1.20)
azure-cli-core (2.0.30)
azure-cli-cosmosdb (0.1.19)
azure-cli-dla (0.0.18)
azure-cli-dls (0.0.20)
azure-cli-eventgrid (0.1.11)
azure-cli-eventhubs (0.1.1)
azure-cli-extension (0.0.11)
azure-cli-feedback (2.1.0)
azure-cli-find (0.2.8)
azure-cli-interactive (0.3.18)
azure-cli-iot (0.1.18)
azure-cli-keyvault (2.0.20)
azure-cli-lab (0.0.20)
azure-cli-monitor (0.1.4)
azure-cli-network (2.0.26)
azure-cli-nspkg (3.0.2)
azure-cli-profile (2.0.21)
azure-cli-rdbms (0.2.0)
azure-cli-redis (0.2.11)
azure-cli-reservations (0.1.1)
azure-cli-resource (2.0.26)
azure-cli-role (2.0.21)
azure-cli-servicebus (0.1.1)
azure-cli-servicefabric (0.0.11)
azure-cli-sql (2.0.24)
azure-cli-storage (2.0.30)
azure-cli-vm (2.0.29)
azure-common (1.1.8)
azure-cosmosdb-nspkg (2.0.2)
azure-cosmosdb-table (1.0.2)
azure-datalake-store (0.0.19)
azure-eventgrid (0.1.0)
azure-graphrbac (0.40.0)
azure-keyvault (0.3.7)
azure-mgmt (2.0.0)
azure-mgmt-advisor (1.0.1)
azure-mgmt-applicationinsights (0.1.1)
azure-mgmt-authorization (0.40.0)
azure-mgmt-batch (4.1.0)
azure-mgmt-batchai (0.2.0)
azure-mgmt-billing (0.1.0)
azure-mgmt-cdn (1.0.0)
azure-mgmt-cognitiveservices (1.0.0)
azure-mgmt-commerce (1.0.1)
azure-mgmt-compute (4.0.0rc1)
azure-mgmt-consumption (2.0.0)
azure-mgmt-containerinstance (0.4.0)
azure-mgmt-containerregistry (1.0.1)
azure-mgmt-containerservice (3.0.1)
azure-mgmt-cosmosdb (0.3.1)
azure-mgmt-datafactory (0.4.0)
azure-mgmt-datalake-analytics (0.2.0)
azure-mgmt-datalake-nspkg (2.0.0)
azure-mgmt-datalake-store (0.2.0)
azure-mgmt-devtestlabs (2.0.0)
azure-mgmt-dns (2.0.0rc1)
azure-mgmt-eventgrid (0.4.0)
azure-mgmt-eventhub (1.2.0)
azure-mgmt-hanaonazure (0.1.0)
azure-mgmt-iothub (0.4.0)
azure-mgmt-iothubprovisioningservices (0.1.0)
azure-mgmt-keyvault (0.40.0)
azure-mgmt-loganalytics (0.1.0)
azure-mgmt-logic (2.1.0)
azure-mgmt-machinelearningcompute (0.4.0)
azure-mgmt-managementpartner (0.1.0)
azure-mgmt-marketplaceordering (0.1.0)
azure-mgmt-media (0.2.0)
azure-mgmt-monitor (0.5.0)
azure-mgmt-msi (0.1.0)
azure-mgmt-network (2.0.0rc1)
azure-mgmt-notificationhubs (1.0.0)
azure-mgmt-nspkg (2.0.0)
azure-mgmt-powerbiembedded (1.0.0)
azure-mgmt-rdbms (1.0.0)
azure-mgmt-recoveryservices (0.1.0)
azure-mgmt-recoveryservicesbackup (0.1.1)
azure-mgmt-redis (4.1.0)
azure-mgmt-relay (0.1.0)
azure-mgmt-reservations (0.1.0)
azure-mgmt-resource (1.2.1)
azure-mgmt-scheduler (1.1.3)
azure-mgmt-search (1.0.0)
azure-mgmt-servermanager (1.2.0)
azure-mgmt-servicebus (0.4.0)
azure-mgmt-servicefabric (0.1.0)
azure-mgmt-sql (0.8.5)
azure-mgmt-storage (1.5.0)
azure-mgmt-subscription (0.1.0)
azure-mgmt-trafficmanager (0.40.0)
azure-mgmt-web (0.35.0)
azure-multiapi-storage (0.2.0)
azure-nspkg (2.0.0)
azure-servicebus (0.21.1)
azure-servicefabric (6.1.2.9)
azure-servicemanagement-legacy (0.20.6)
azure-storage (0.34.3)
azure-storage-blob (1.1.0)
azure-storage-common (1.1.0)
azure-storage-file (1.1.0)
azure-storage-nspkg (3.0.0)
azure-storage-queue (1.1.0)
bcrypt (3.1.3)
beautifulsoup4 (4.6.0)
blinker (1.4)
botocore (1.4.70)
Brlapi (0.6.4)
certifi (2017.11.5)
cffi (1.11.0)
chardet (3.0.4)
chrome-gnome-shell (0.0.0)
colorama (0.3.9)
command-not-found (0.3)
configparser (3.5.0)
cryptography (2.2.2)
defer (1.0.6)
dictdiffer (0.6.1)
dnspython (1.15.0)
docker (2.5.1)
docker-py (1.10.6)
docker-pycreds (0.2.1)
docutils (0.13.1)
feedgenerator (1.9)
future (0.16.0)
futures (3.1.1)
html5lib (0.999)
httplib2 (0.10.3)
humanfriendly (4.10)
idna (2.6)
ipaddress (1.0.18)
isodate (0.6.0)
jedi (0.10.2)
Jinja2 (2.9.6)
jmespath (0.9.0)
json-rpc (1.10.3)
jsonxs (0.6)
keyring (11.0.0)
knack (0.3.2)
kubernetes (1.0.2)
language-selector (0.1)
louis (2.6.4)
lxml (4.1.1)
Mako (1.0.3)
Markdown (2.6.8)
MarkupSafe (0.23)
mccabe (0.6.1)
mock (2.0.0)
msrest (0.4.26)
msrestazure (0.4.22)
oauth2client (4.1.2)
oauthlib (2.0.6)
openshift (0.0.1)
openshot-qt (2.4.1.dev1)
packaging (17.1)
paramiko (2.3.1)
pbr (4.0.1)
pelican (3.7.1)
pexpect (4.0.1)
Pillow (3.1.2)
pip (9.0.3)
pluggy (0.5.2)
prompt-toolkit (1.0.15)
ptyprocess (0.5)
pyasn1 (0.3.6)
pyasn1-modules (0.1.4)
pycodestyle (2.3.1)
pycparser (2.18)
pycups (1.9.73)
pycurl (7.43.0)
pydocstyle (2.0.0)
pydocumentdb (2.3.1)
pyflakes (1.5.0)
pygame (1.9.3)
Pygments (2.2.0)
pygobject (3.20.0)
PyJWT (1.6.0)
pylama (7.3.3)
PyNaCl (1.1.2)
pyOpenSSL (17.5.0)
pyparsing (2.2.0)
pyperclip (1.6.0)
pysphere (0.1.7)
python-apt (1.1.0b1+ubuntu0.16.4.1)
python-dateutil (2.6.0)
python-debian (0.1.27)
python-language-server (0.5.0)
python-string-utils (0.6.0)
python-systemd (231)
pytz (2017.2)
pyvmomi (6.5.0.2017.5.post1)
pyvoicechanger (1.0.0)
pyxdg (0.25)
PyYAML (3.12)
pyzmq (15.2.0)
reportlab (3.3.0)
requests (2.18.4)
requests-oauthlib (0.8.0)
roman (2.0.0)
rsa (3.4.2)
ruamel.yaml (0.15.33)
s3transfer (0.1.9)
scp (0.10.2)
SecretStorage (2.3.1)
sessioninstaller (0.0.0)
setuptools (36.5.0)
six (1.10.0)
snowballstemmer (1.2.1)
sshtunnel (0.1.3)
structlog (17.2.0)
system-service (0.3)
tabulate (0.7.7)
torrench (1.0.56)
ubuntu-drivers-common (0.0.0)
ufw (0.35)
unattended-upgrades (0.1)
Unidecode (0.4.21)
urllib3 (1.22)
usb-creator (0.3.0)
ushlex (0.99)
vsts-cd-manager (1.0.1)
wcwidth (0.1.7)
websocket-client (0.44.0)
wheel (0.29.0)
Whoosh (2.7.4)
xdiagnose (3.8.4.1)
xkit (0.0.0)
xmltodict (0.11.0)
yapf (0.17.0)
╭─stubbsrem@tnf27 ~/code/ide  
╰─$ ansible --version
ansible 2.6.0 (devel 45b5a486c6) last updated 2018/04/04 20:20:21 (GMT +100)
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/stubbsrem/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/stubbsrem/ansible/lib/ansible
  executable location = /home/stubbsrem/ansible/bin/ansible
  python version = 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609]
╭─stubbsrem@tnf27 ~/code/ide  
╰─$ 
```

Resolving patch:
diff --git a/lib/ansible/modules/cloud/azure/azure_rm_dnsrecordset.py b/lib/ansible/modules/cloud/azure/azure_rm_dnsrecordset.py
--- a/lib/ansible/modules/cloud/azure/azure_rm_dnsrecordset.py
+++ b/lib/ansible/modules/cloud/azure/azure_rm_dnsrecordset.py
@@ -211,7 +211,7 @@
         target=dict(type='str', required=True, aliases=['entry'])
     ),
     TXT=dict(
-        value=dict(type='str', required=True, aliases=['entry'])
+        value=dict(type='list', required=True, aliases=['entry'])
     ),
     # FUTURE: ensure all record types are supported (see https://github.com/Azure/azure-sdk-for-python/tree/master/azure-mgmt-dns/azure/mgmt/dns/models)
 )
@@ -375,7 +375,11 @@ def records_changed(self, input_records, server_records):
 def gethash(self):
     if not getattr(self, '_cachedhash', None):
         spec = inspect.getargspec(self.__init__)
-        valuetuple = tuple([getattr(self, x, None) for x in spec.args if x != 'self'])
+        valuetuple = tuple(
+            map(lambda v: v if not isinstance(v, list) else str(v), [
+                getattr(self, x, None) for x in spec.args if x != 'self'
+            ])
+        )
         self._cachedhash = hash(valuetuple)
     return self._cachedhash
 


Test patch:
diff --git a/test/integration/targets/azure_rm_dnsrecordset/tasks/main.yml b/test/integration/targets/azure_rm_dnsrecordset/tasks/main.yml
--- a/test/integration/targets/azure_rm_dnsrecordset/tasks/main.yml
+++ b/test/integration/targets/azure_rm_dnsrecordset/tasks/main.yml
@@ -158,6 +158,26 @@
     that: 
       - results.changed
 
+- name: create TXT records in a new record set
+  azure_rm_dnsrecordset:
+    resource_group: "{{ resource_group }}"
+    relative_name: "_txt.{{ domain_name }}.com"
+    zone_name: "{{ domain_name }}.com"
+    record_type: TXT
+    state: present
+    records:
+      - entry: "v=spf1 a -all"
+      - entry: "foo"
+      - entry:
+          - "bar"
+          - "baz"
+  register: results
+
+- name: Assert that TXT record set was created
+  assert:
+    that:
+      - results.changed
+
 - name: Delete DNS zone
   azure_rm_dnszone:
     resource_group: "{{ resource_group }}"