Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide compatibility for dns_zone module with openstack.cloud collection #105

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ action_groups:
- deh_host_info
- deh_host_type_info
- deh_server_info
- dns_zone
- floating_ip
- loadbalancer
- loadbalancer_info
Expand Down
31 changes: 22 additions & 9 deletions plugins/modules/dns_zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,24 @@
description:
- Cache duration (in second) on a local DNS server
type: int
zone_type:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'type' means whether primary or secondary dns zone (line 56), did you mean alias 'type'?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no. Its actually a recordset that is in openstack has "recordset_type", and on our side "type". For that we should on our side rename "type" attribute into "recordset_type" and with aliases: ['type'] provide backward compatibility.

Later: Well, we actually need to drop recordset module completely and only provide routing to the openstack one

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's rename it not to type, but "visibility"

type:
description:
- Zone Type, either public or private
type: str
choices: [public, private]
default: public

zone_type:
description:
- Primary or secondary type.
- This parameter is disabled, it only provides compatibility with openstack.cloud colection.
choices: [primary, secondary]
type: str
masters:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you add "masters", but do not use it

description:
- Master nameservers (only applies if zone_type is secondary).
- This parameter is disabled, it only provides compatibility with openstack.cloud colection.
type: list
elements: str
requirements: ["openstacksdk", "otcextensions"]
'''

Expand Down Expand Up @@ -96,7 +107,7 @@
type: int
sample: 300
zone_type:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think when we return result we need to explicitly rename zone_type to visibility

description: Zone Type, either public or private
description: Zone Type, either public or private.
type: str
sample: "private"
'''
Expand All @@ -107,7 +118,7 @@
opentelekomcloud.cloud.dns_zone:
name: "test.com."
state: present
zone_type: private
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zone_type: primary
visibility: private

type: private
router: 79c32783-e560-4e3a-95b1-5a0756441e12
description: test2
ttl: 5000
Expand All @@ -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'),
zone_type=dict(required=False, choices=['primary', 'secondary'], type='str')
)
module_kwargs = dict(
supports_check_mode=True
Expand All @@ -135,8 +148,8 @@ def run(self):
changed = False
query = {}

if self.params['zone_type'] == 'private':
query['type'] = self.params['zone_type']
if self.params['type'] == 'private':
query['zone_type'] = self.params['type']
query['name_or_id'] = self.params['name']
query['ignore_missing'] = True
zo = self.conn.dns.find_zone(**query)
Expand Down Expand Up @@ -171,7 +184,7 @@ def run(self):
self.exit_json(changed=True)
if zone_check is False:
# Check if VPC exists
if self.params['zone_type'] == 'private':
if self.params['type'] == 'private':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

visibilty

if not self.params['router']:
self.exit(
changed=False,
Expand All @@ -193,7 +206,7 @@ def run(self):
message=('No Router found with name or id: %s' %
self.params['router'])
)
attrs['zone_type'] = self.params['zone_type']
attrs['zone_type'] = self.params['type']
if self.params['description']:
attrs['description'] = self.params['description']
if self.params['email']:
Expand Down
34 changes: 18 additions & 16 deletions tests/integration/targets/dns/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
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.' ) }}"
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' )}}"
Expand Down Expand Up @@ -113,7 +113,7 @@
- dns_fl.ptr.description is defined

- name: Creating a public DNS Zone - check mode
opentelekomcloud.cloud.dns_zones:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, how was this working before? Weird

opentelekomcloud.cloud.dns_zone:
name: "{{ zone_public_name }}"
state: present
check_mode: true
Expand All @@ -126,7 +126,7 @@
- dns_zo_ch is changed

- name: Creating a public DNS Zone
opentelekomcloud.cloud.dns_zones:
opentelekomcloud.cloud.dns_zone:
name: "{{ zone_public_name }}"
state: present
register: dns_zo
Expand All @@ -142,7 +142,7 @@
- dns_zo.zone is defined

- name: Updating a public DNS Zone - check mode
opentelekomcloud.cloud.dns_zones:
opentelekomcloud.cloud.dns_zone:
name: "{{ zone_public_name }}"
state: present
description: "{{ description }}"
Expand All @@ -156,7 +156,7 @@
- dns_zo_ch is changed

- name: Updating a public DNS Zone
opentelekomcloud.cloud.dns_zones:
opentelekomcloud.cloud.dns_zone:
name: "{{ zone_public_name }}"
state: present
description: "{{ description }}"
Expand All @@ -173,10 +173,10 @@
- dns_zo.zone.description is defined

- name: Creating a DNS private Zone - check mode
opentelekomcloud.cloud.dns_zones:
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
Expand All @@ -188,10 +188,10 @@
- dns_zo_pr_ch is changed

- name: Creating a DNS private Zone
opentelekomcloud.cloud.dns_zones:
opentelekomcloud.cloud.dns_zone:
name: "{{ zone_private_name }}"
router: "{{ router_name }}"
zone_type: "private"
type: "private"
state: present
register: dns_zo_pr

Expand All @@ -206,10 +206,11 @@
- dns_zo_pr.zone is defined

- name: Updating a private DNS Zone - check mode
opentelekomcloud.cloud.dns_zones:
opentelekomcloud.cloud.dns_zone:
name: "{{ zone_private_name }}"
state: present
description: "{{ description }}"
type: "private"
check_mode: true
register: dns_zo_pr_ch

Expand All @@ -220,10 +221,11 @@
- dns_zo_pr_ch is changed

- name: Updating a private DNS Zone
opentelekomcloud.cloud.dns_zones:
opentelekomcloud.cloud.dns_zone:
name: "{{ zone_private_name }}"
state: present
description: "{{ description }}"
type: "private"
register: dns_zo_pr

- name: debug
Expand Down Expand Up @@ -332,15 +334,15 @@
register: dns_rs_dr

- name: Drop DNS public Zone
opentelekomcloud.cloud.dns_zones:
opentelekomcloud.cloud.dns_zone:
name: "{{ zone_public_name }}"
state: absent
register: dns_zo_pu_dr

- name: Drop DNS private Zone
opentelekomcloud.cloud.dns_zones:
opentelekomcloud.cloud.dns_zone:
name: "{{ zone_private_name }}"
zone_type: "private"
type: "private"
state: absent
register: dns_zo_pr_dr

Expand Down