Repository: ansible-collections/community.general

Issue:
ipa_dnsrecord: please implement management of NS type records
### Summary

I am trying to create an NS record using the following ansible script
```yaml
      community.general.ipa_dnsrecord:
        ipa_host: "{{ ipa_host }}"
        ipa_user: "{{ ipa_user }}"
        ipa_pass: "{{ ipa_password }}"
        state: present
        zone_name: "{{ domain }}"
        record_type: "NS"
        record_name: "consul"
        record_value: "consul-server-1.{{ domain }}."
      run_once: true
```
and am getting the following error:
```
value of record_type must be one of: A, AAAA, A6, CNAME, DNAME, PTR, TXT, SRV, MX, got: NS
```

A, CNAME and SRV records are working fine.

### Issue Type

Feature Idea

### Component Name

[plugins/modules/ipa_dnsrecord.py](https://github.com/ansible-collections/community.general/blob/main/plugins/modules/ipa_dnsrecord.py)

### Additional Information

<!--- Paste example playbooks or commands between quotes below -->
```yaml
      community.general.ipa_dnsrecord:
        ipa_host: "{{ ipa_host }}"
        ipa_user: "{{ ipa_user }}"
        ipa_pass: "{{ ipa_password }}"
        state: present
        zone_name: "{{ domain }}"
        record_type: "NS"
        record_name: "consul"
        record_value: "consul-server-1.{{ domain }}."
      run_once: true
```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
Files identified in the description:
* [`plugins/modules/ipa_dnsrecord.py`](https://github.com/ansible-collections/community.general/blob/main/plugins/modules/ipa_dnsrecord.py)

If these files are incorrect, 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/devel/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @Akasurde @Nosmoht @fxfitz @justchris1
[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/plugins/modules/ipa_dnsrecord.py b/plugins/modules/ipa_dnsrecord.py
--- a/plugins/modules/ipa_dnsrecord.py
+++ b/plugins/modules/ipa_dnsrecord.py
@@ -35,12 +35,13 @@
   record_type:
     description:
     - The type of DNS record name.
-    - Currently, 'A', 'AAAA', 'A6', 'CNAME', 'DNAME', 'PTR', 'TXT', 'SRV' and 'MX' are supported.
+    - Currently, 'A', 'AAAA', 'A6', 'CNAME', 'DNAME', 'NS', 'PTR', 'TXT', 'SRV' and 'MX' are supported.
     - "'A6', 'CNAME', 'DNAME' and 'TXT' are added in version 2.5."
     - "'SRV' and 'MX' are added in version 2.8."
+    - "'NS' are added in comunity.general 8.2.0."
     required: false
     default: 'A'
-    choices: ['A', 'AAAA', 'A6', 'CNAME', 'DNAME', 'MX', 'PTR', 'SRV', 'TXT']
+    choices: ['A', 'AAAA', 'A6', 'CNAME', 'DNAME', 'MX', 'NS', 'PTR', 'SRV', 'TXT']
     type: str
   record_value:
     description:
@@ -51,6 +52,7 @@
     - In the case of 'A6' record type, this will be the A6 Record data.
     - In the case of 'CNAME' record type, this will be the hostname.
     - In the case of 'DNAME' record type, this will be the DNAME target.
+    - In the case of 'NS' record type, this will be the name server hostname. Hostname must already have a valid A or AAAA record.
     - In the case of 'PTR' record type, this will be the hostname.
     - In the case of 'TXT' record type, this will be a text.
     - In the case of 'SRV' record type, this will be a service record.
@@ -64,6 +66,7 @@
     - In the case of 'A6' record type, this will be the A6 Record data.
     - In the case of 'CNAME' record type, this will be the hostname.
     - In the case of 'DNAME' record type, this will be the DNAME target.
+    - In the case of 'NS' record type, this will be the name server hostname. Hostname must already have a valid A or AAAA record.
     - In the case of 'PTR' record type, this will be the hostname.
     - In the case of 'TXT' record type, this will be a text.
     - In the case of 'SRV' record type, this will be a service record.
@@ -162,6 +165,16 @@
     ipa_user: admin
     ipa_pass: topsecret
     state: absent
+
+- name: Ensure an NS record for a subdomain is present
+  community,general.ipa_dnsrecord:
+    name: subdomain
+    zone_name: example.com
+    record_type: 'NS'
+    record_value: 'ns1.subdomain.exmaple.com'
+    ipa_host: ipa.example.com
+    ipa_user: admin
+    ipa_pass: ChangeMe!
 '''
 
 RETURN = r'''
@@ -205,6 +218,8 @@ def dnsrecord_add(self, zone_name=None, record_name=None, details=None):
                 item.update(cname_part_hostname=value)
             elif details['record_type'] == 'DNAME':
                 item.update(dname_part_target=value)
+            elif details['record_type'] == 'NS':
+                item.update(ns_part_hostname=value)
             elif details['record_type'] == 'PTR':
                 item.update(ptr_part_hostname=value)
             elif details['record_type'] == 'TXT':
@@ -241,6 +256,8 @@ def get_dnsrecord_dict(details=None):
         module_dnsrecord.update(cnamerecord=details['record_values'])
     elif details['record_type'] == 'DNAME' and details['record_values']:
         module_dnsrecord.update(dnamerecord=details['record_values'])
+    elif details['record_type'] == 'NS' and details['record_values']:
+        module_dnsrecord.update(nsrecord=details['record_values'])
     elif details['record_type'] == 'PTR' and details['record_values']:
         module_dnsrecord.update(ptrrecord=details['record_values'])
     elif details['record_type'] == 'TXT' and details['record_values']:
@@ -311,7 +328,7 @@ def ensure(module, client):
 
 
 def main():
-    record_types = ['A', 'AAAA', 'A6', 'CNAME', 'DNAME', 'PTR', 'TXT', 'SRV', 'MX']
+    record_types = ['A', 'AAAA', 'A6', 'CNAME', 'DNAME', 'NS', 'PTR', 'TXT', 'SRV', 'MX']
     argument_spec = ipa_argument_spec()
     argument_spec.update(
         zone_name=dict(type='str', required=True),


Test patch: