azure: fix creation of TXT dns record sets (#38368)

As per `azure.mgmt.dns.models.txt_record.TxtRecord`, expected value for a
record is of type `[str]`. Fix TXT argspec to specify type as `list`
instead of `str`.

Fixes #37581

Reference: https://docs.microsoft.com/en-us/python/api/azure.mgmt.dns.models.txtrecord?view=azure-python
pull/39878/head
Arun Babu Neelicattu 7 years ago committed by ansibot
parent 8c27ffdf90
commit eb430b2e57

@ -211,7 +211,7 @@ RECORD_ARGSPECS = dict(
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 @@ class AzureRMRecordSet(AzureRMModuleBase):
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

@ -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 }}"

Loading…
Cancel
Save