ipa_dnsrecord: Allow for TXT Records (#32427)

* ipa_dnsrecord: Allow for TXT Records

* Clarified version.

- Added note about in which version TXT-record was added.
pull/29138/head
Jimmy Hedman 7 years ago committed by ansibot
parent 9e59ccca9f
commit dc40efc13f

@ -31,15 +31,16 @@ options:
record_type: record_type:
description: description:
- The type of DNS record name - The type of DNS record name
- Currently, 'A', 'AAAA', and 'PTR' are supported - Currently, 'A', 'AAAA', 'PTR' and 'TXT' (added in 2.5) are supported
required: false required: false
default: 'A' default: 'A'
choices: ['A', 'AAAA', 'PTR'] choices: ['A', 'AAAA', 'PTR', 'TXT']
record_value: record_value:
description: description:
- Manage DNS record name with this value. - Manage DNS record name with this value.
- In the case of 'A' or 'AAAA' record types, this will be the IP address. - In the case of 'A' or 'AAAA' record types, this will be the IP address.
- In the case of 'PTR' record type, this will be the hostname. - In the case of 'PTR' record type, this will be the hostname.
- In the case of 'TXT' record type, this will be a text
required: true required: true
state: state:
description: State to ensure description: State to ensure
@ -71,6 +72,16 @@ EXAMPLES = '''
record_type: 'PTR' record_type: 'PTR'
record_value: 'internal.ipa.example.com' record_value: 'internal.ipa.example.com'
# Ensure a TXT record is present
- ipa_dnsrecord:
ipa_host: spider.example.com
ipa_pass: Passw0rd!
state: present
zone_name: example.com
record_name: _kerberos
record_type: 'TXT'
record_value: 'EXAMPLE.COM'
# Ensure that dns record is removed # Ensure that dns record is removed
- ipa_dnsrecord: - ipa_dnsrecord:
name: host01 name: host01
@ -112,6 +123,8 @@ class DNSRecordIPAClient(IPAClient):
item.update(aaaa_part_ip_address=details['record_value']) item.update(aaaa_part_ip_address=details['record_value'])
elif details['record_type'] == 'PTR': elif details['record_type'] == 'PTR':
item.update(ptr_part_hostname=details['record_value']) item.update(ptr_part_hostname=details['record_value'])
elif details['record_type'] == 'TXT':
item.update(txtrecord=details['record_value'])
return self._post_json(method='dnsrecord_add', name=zone_name, item=item) return self._post_json(method='dnsrecord_add', name=zone_name, item=item)
@ -134,6 +147,8 @@ def get_dnsrecord_dict(details=None):
module_dnsrecord.update(aaaarecord=details['record_value']) module_dnsrecord.update(aaaarecord=details['record_value'])
elif details['record_type'] == 'PTR' and details['record_value']: elif details['record_type'] == 'PTR' and details['record_value']:
module_dnsrecord.update(ptrrecord=details['record_value']) module_dnsrecord.update(ptrrecord=details['record_value'])
elif details['record_type'] == 'TXT' and details['record_value']:
module_dnsrecord.update(txtrecord=details['record_value'])
return module_dnsrecord return module_dnsrecord
@ -179,7 +194,7 @@ def ensure(module, client):
def main(): def main():
record_types = ['A', 'AAAA', 'PTR'] record_types = ['A', 'AAAA', 'PTR', 'TXT']
argument_spec = ipa_argument_spec() argument_spec = ipa_argument_spec()
argument_spec.update(zone_name=dict(type='str', required=True), argument_spec.update(zone_name=dict(type='str', required=True),
record_name=dict(type='str', aliases=['name'], required=True), record_name=dict(type='str', aliases=['name'], required=True),

Loading…
Cancel
Save