diff --git a/meta/runtime.yml b/meta/runtime.yml index c55bcbb1..78372ae3 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -31,6 +31,7 @@ action_groups: - deh_host_info - deh_host_type_info - deh_server_info + - dns_zone - dns_recordset_info - dds_flavor_info - dds_instance_info diff --git a/plugins/modules/dns_zone.py b/plugins/modules/dns_zone.py index e3ec924f..fa3530e6 100644 --- a/plugins/modules/dns_zone.py +++ b/plugins/modules/dns_zone.py @@ -47,13 +47,24 @@ description: - Cache duration (in second) on a local DNS server type: int - zone_type: + type: description: - Zone Type, either public or private type: str choices: [public, private] default: public - + type: + description: + - Primary or secondary type. + - This parameter is disabled, it only provides compatibility with openstack.cloud colection. + choices: [primary, secondary] + type: str + masters: + description: + - Master nameservers (only applies if type is secondary). + - This parameter is disabled, it only provides compatibility with openstack.cloud colection. + type: list + elements: str requirements: ["openstacksdk", "otcextensions"] ''' @@ -95,8 +106,8 @@ description: Cache duration (in second) on a local DNS server type: int sample: 300 - zone_type: - description: Zone Type, either public or private + type: + description: Zone Type, either public or private. type: str sample: "private" ''' @@ -107,7 +118,7 @@ opentelekomcloud.cloud.dns_zone: name: "test.com." state: present - zone_type: private + type: private router: 79c32783-e560-4e3a-95b1-5a0756441e12 description: test2 ttl: 5000 @@ -120,12 +131,14 @@ class DNSZonesModule(OTCModule): argument_spec = dict( description=dict(required=False), + type=dict(type='str', choices=['public', 'private'], default='public'), email=dict(required=False), name=dict(required=True), router=dict(required=False), state=dict(type='str', choices=['present', 'absent'], default='present'), ttl=dict(required=False, type='int'), - zone_type=dict(type='str', choices=['public', 'private'], default='public') + masters=dict(required=False, type='list', elements='str'), + type=dict(required=False, choices=['primary', 'secondary'], type='str') ) module_kwargs = dict( supports_check_mode=True @@ -135,7 +148,7 @@ def run(self): changed = False attrs = {} query = { - 'type': self.params['zone_type'], + 'type': self.params['type'], 'name_or_id': self.params['name'] } @@ -170,7 +183,7 @@ def run(self): self.exit_json(changed=True) if not needs_update: # Check if VPC exists - if self.params['zone_type'] == 'private': + if self.params['type'] == 'private': if not self.params['router']: self.exit( changed=False, @@ -192,8 +205,9 @@ def run(self): message=('No Router found with name or id: %s' % self.params['router']) ) - if self.params['zone_type']: - attrs['zone_type'] = self.params['zone_type'] + + if self.params['type']: + attrs['type'] = self.params['type'] if self.params['description']: attrs['description'] = self.params['description'] if self.params['email']: diff --git a/tests/integration/targets/dns/tasks/main.yaml b/tests/integration/targets/dns/tasks/main.yaml index dab0bac5..a5cf85ff 100644 --- a/tests/integration/targets/dns/tasks/main.yaml +++ b/tests/integration/targets/dns/tasks/main.yaml @@ -15,12 +15,12 @@ fl_ip: "{{ fl.floating_ip.floating_ip_address }}" ptrdname: "{{ ( prefix + 'dns.com.' ) }}" description: "{{ ( prefix + 'description-dns' ) }}" - zone_public_name: "{{ ( prefix + '-dnszone.com.' ) }}" - zone_private_name: "{{ ( prefix + '-dnszone.com.' ) }}" - rs_name: "{{ ( prefix + '-rs.' + prefix + '-dnszone.com.' ) }}" - network_name: "{{ ( prefix + '-dnsnetwork' ) }}" - subnet_name: "{{ ( prefix + '-dnssubnet' ) }}" - router_name: "{{ ( prefix + '-dnsrouter' ) }}" + zone_public_name: "{{ ( prefix + '-dnszonepublic.com.' ) }}" + zone_private_name: "{{ ( prefix + '-dnszoneprivate.com.' ) }}" + rs_name: "{{ ( prefix + '-rs.' + prefix + '-dnszonepublic.com.' ) }}" + network_name: "{{ ( prefix + '-dnsnetwork' )}}" + subnet_name: "{{ ( prefix + '-dnssubnet' )}}" + router_name: "{{ ( prefix + '-dnsrouter' )}}" - name: Create network for DNS private Zone openstack.cloud.network: @@ -176,7 +176,7 @@ opentelekomcloud.cloud.dns_zone: name: "{{ zone_private_name }}" router: "{{ router_name }}" - zone_type: "private" + type: "private" state: present check_mode: true register: dns_zo_pr_ch @@ -191,7 +191,7 @@ opentelekomcloud.cloud.dns_zone: name: "{{ zone_private_name }}" router: "{{ router_name }}" - zone_type: "private" + type: "private" state: present register: dns_zo_pr @@ -210,6 +210,7 @@ name: "{{ zone_private_name }}" state: present description: "{{ description }}" + type: "private" check_mode: true register: dns_zo_pr_ch @@ -224,6 +225,7 @@ name: "{{ zone_private_name }}" state: present description: "{{ description }}" + type: "private" register: dns_zo_pr - name: debug @@ -366,7 +368,7 @@ - name: Drop DNS private Zone opentelekomcloud.cloud.dns_zone: name: "{{ zone_private_name }}" - zone_type: "private" + type: "private" state: absent register: dns_zo_pr_dr failed_when: false