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

DNS Info Modules #40

Open
wants to merge 59 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
60a89ca
Added DNS Info Modules
SebastianGode Oct 2, 2020
61ae16e
Fixed Whitespace
SebastianGode Oct 2, 2020
d6ab88f
Fixed Integration
SebastianGode Oct 5, 2020
019071c
added dns_flaoting_ip
SebastianGode Oct 9, 2020
5c007ee
Added docu FLIP and fixed pep8
SebastianGode Oct 9, 2020
e708dae
Fixed version_added
SebastianGode Nov 3, 2020
3c61ac6
Fixed version_added
SebastianGode Nov 3, 2020
888a57b
Deleted Date Filters
SebastianGode Nov 3, 2020
219e9c0
some help for sebastian
tischrei Nov 3, 2020
f8c07ae
Merge branch 'dns2' of github.com:opentelekomcloud/ansible-collection…
tischrei Nov 3, 2020
1a28ce0
Changed FQCN
SebastianGode Nov 4, 2020
580e86e
Fixed Sanity Checks
SebastianGode Nov 4, 2020
d0aa795
Fixed issue creating recordset
SebastianGode Nov 4, 2020
d62a07a
Functional complete - Missing Docu
SebastianGode Nov 4, 2020
cda1665
Fixed many errors in nameserver_info
SebastianGode Nov 5, 2020
a0804b4
Fixed spelling
SebastianGode Nov 5, 2020
3c6d76b
Removed Find function
SebastianGode Nov 5, 2020
358289f
Fixed pep8 issues
SebastianGode Nov 5, 2020
5c10501
Added correct Docu
SebastianGode Nov 5, 2020
2360b60
Added working example
SebastianGode Nov 5, 2020
d7005e6
recordset update
tischrei Nov 5, 2020
1ebcd49
New File for zone
SebastianGode Nov 6, 2020
8acf59b
Merge branch 'dns3' of https://github.com/opentelekomcloud/ansible-co…
SebastianGode Nov 6, 2020
02c1f29
First semi working zone script
SebastianGode Nov 10, 2020
212f16f
Added Zone creation
SebastianGode Nov 10, 2020
5fe003d
Fully working zone script - docu missing
SebastianGode Nov 10, 2020
4088dff
Fixed Pep8, added docu
SebastianGode Nov 10, 2020
4db6d44
Merge branch 'master' into dns3
SebastianGode Nov 10, 2020
c6ef466
Fixed Typo
SebastianGode Nov 10, 2020
6e08f4d
Merge branch 'dns3' of https://github.com/opentelekomcloud/ansible-co…
SebastianGode Nov 10, 2020
9a66401
Fixed Ansible Docu spaces and fixed changed on update
SebastianGode Nov 11, 2020
8134862
Fixed pep8
SebastianGode Nov 11, 2020
60535c8
Fixed pep8 + removed spaces
SebastianGode Nov 11, 2020
a13e3f2
changed version
SebastianGode Nov 13, 2020
fa37493
Added integration tests
SebastianGode Nov 13, 2020
b57ea75
Added Integration Tests
SebastianGode Nov 13, 2020
6c09287
Added big Integration Test
SebastianGode Nov 13, 2020
6592a0c
Fixed yamllint
SebastianGode Nov 13, 2020
9c6eb1b
Added integration test
SebastianGode Nov 13, 2020
b50a866
Fixed Yamllint
SebastianGode Nov 13, 2020
a330db7
Fixed Sanity
SebastianGode Nov 13, 2020
56ceedd
Fixed blank lines, fixed fqdn
SebastianGode Nov 16, 2020
a84ecce
Changed zone_find according to new PR
SebastianGode Nov 16, 2020
d60e624
Fixed Pep8
SebastianGode Nov 16, 2020
236dae6
Added DNS Private Zone Test + ignore errors
SebastianGode Nov 17, 2020
1a23f74
Fixed yamllint
SebastianGode Nov 17, 2020
7541152
Fixed yamllint -2
SebastianGode Nov 17, 2020
c0c5cf3
Fixed ignore_errors
SebastianGode Nov 17, 2020
95935e3
Fixed git
SebastianGode Nov 17, 2020
e1e939d
minor fix
tischrei Nov 17, 2020
1315524
Merge branch 'dns3' into dns2
tischrei Nov 17, 2020
64b465b
Merge branch 'master' into dns2
SebastianGode Nov 17, 2020
e5e8a1d
Added big integration test
SebastianGode Nov 17, 2020
f702fa5
Merge branch 'master' into dns2
SebastianGode Nov 19, 2020
6a2a5f4
Merge branch 'master' into dns2
SebastianGode Jan 25, 2021
299ac76
Merge branch 'master' into dns2
SebastianGode Jun 10, 2021
2dcf588
New Integration Tests for info modules
SebastianGode Jun 11, 2021
d59b99a
Make dns_zone_info Upstream compliant
SebastianGode Jun 11, 2021
905ff41
Fixed Sanity + Added Checkmode
SebastianGode Jun 11, 2021
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
4 changes: 4 additions & 0 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ action_groups:
otc:
- as_config_group
- as_config_info
- dns_floating_ip_info
- dns_nameserver_info
- dns_recordset_info
- dns_zone_info
- cce_cluster
- cce_cluster_cert_info
- cce_cluster_info
Expand Down
141 changes: 141 additions & 0 deletions plugins/modules/dns_floating_ip_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#!/usr/bin/python
SebastianGode marked this conversation as resolved.
Show resolved Hide resolved
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

DOCUMENTATION = '''
module: dns_floating_ip_info
short_description: Get DNS PTR Records
extends_documentation_fragment: opentelekomcloud.cloud.otc
version_added: "0.1.2"
SebastianGode marked this conversation as resolved.
Show resolved Hide resolved
author: "Sebastian Gode (@SebastianGode)"
description:
- Get DNS PTR Records from the OTC.
options:
address:
description:
- EIP address
type: str
description:
description:
- Description of the Record
type: str
id:
description:
- PTR record ID
type: str
ptrdname:
description:
- Domain name of the PTR record
type: str
status:
description:
- Resource status
type: str
ttl:
description:
- PTR record cache duration (in second) on a local DNS server
type: int

requirements: ["openstacksdk", "otcextensions"]
'''

RETURN = '''
ptr_records:
SebastianGode marked this conversation as resolved.
Show resolved Hide resolved
description: Get DNS PTR Records
type: complex
returned: On Success.
contains:
address:
description: EIP address
type: str
sample: "100.138.123.199"
description:
description: Description of the Record
type: str
sample: "MyRecord123"
id:
description: PTR record id
type: str
sample: "eu-de:fe864230-d3bc-4391-8a32-394c3e9ca22d"
ptrdname:
description: Domain name of the PTR record
type: str
sample: "example.com"
status:
description: Resource status
type: str
sample: "ACTIVE"
ttl:
description: PTR record cache duration (in second) on a local DNS server
type: int
sample: 300

'''

EXAMPLES = '''
# Get PRT Info:
- name: Getting Info
opentelekomcloud.cloud.dns_floating_ip_info:
description: "Test"
ptrdname: "example.com"

'''

from ansible_collections.opentelekomcloud.cloud.plugins.module_utils.otc import OTCModule


class DNSFloatingIpInfoModule(OTCModule):
argument_spec = dict(
address=dict(required=False),
description=dict(required=False),
id=dict(required=False),
ptrdname=dict(required=False),
status=dict(required=False),
ttl=dict(required=False, type='int')
)

def run(self):

query = {}
data = []

if self.params['address']:
query['address'] = self.params['address']
if self.params['id']:
query['id'] = self.params['id']
if self.params['ptrdname']:
query['ptrdname'] = self.params['ptrdname']
if self.params['ttl']:
query['ttl'] = self.params['ttl']
if self.params['description']:
query['description'] = self.params['description']
if self.params['status']:
query['status'] = self.params['status']

for raw in self.conn.dns.floating_ips(**query):
dt = raw.to_dict()
dt.pop('location')
data.append(dt)

self.exit(
changed=False,
ptr_records=data
)


def main():
module = DNSFloatingIpInfoModule()
module()


if __name__ == '__main__':
main()
144 changes: 144 additions & 0 deletions plugins/modules/dns_nameserver_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
#!/usr/bin/python
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

DOCUMENTATION = '''
module: dns_nameserver_info
short_description: Get DNS Nameserver Infos
extends_documentation_fragment: opentelekomcloud.cloud.otc
version_added: "0.1.2"
SebastianGode marked this conversation as resolved.
Show resolved Hide resolved
author: "Sebastian Gode (@SebastianGode)"
description:
- Get DNS Namerserver infos from the OTC.
options:
address:
description:
- IP address of a DNS Server
type: str
hostname:
description:
- Hostname of a DNS server
type: str
priority:
description:
- Priority of a name server
type: str
zone:
description:
- DNS Zone ID
type: str
required: true

requirements: ["openstacksdk", "otcextensions"]
'''

RETURN = '''
SebastianGode marked this conversation as resolved.
Show resolved Hide resolved
dns_nameservers:
description: List of DNS Nameservers
type: complex
returned: On Success.
contains:
address:
description: IP address of a DNS server
type: str
sample: "100.138.123.199"
hostname:
description: Hostname of a DNS server
type: str
sample: "Myhostname"
priority:
description: Priority of a name server
type: str
sample: "1"
zone:
description: Specifies the DNS zone
type: str
sample: "fe40808272701cbe0172cbca17f91882"
'''

EXAMPLES = '''
# Get Nameserver Info about a zone:

- name: Get nameserver Info
opentelekomcloud.cloud.dns_nameserver_info:
zone: fe40808272701cbe0172cbca17f91882
hostname: "MyHostname"

'''

from ansible_collections.opentelekomcloud.cloud.plugins.module_utils.otc import OTCModule


class DNSNameserverInfoModule(OTCModule):
argument_spec = dict(
address=dict(required=False),
hostname=dict(required=False),
priority=dict(required=False),
zone=dict(required=True)
)

def run(self):

data = []
query = {}

if self.params['zone']:
zi = self.conn.dns.find_zone(
SebastianGode marked this conversation as resolved.
Show resolved Hide resolved
name_or_id=self.params['zone'],
ignore_missing=True)
if zi:
query['zone'] = zi.id
else:
self.exit(
changed=False,
message=('No zone found with name or id: %s' %
self.params['zone'])
)

for raw in self.conn.dns.nameservers(**query):
SebastianGode marked this conversation as resolved.
Show resolved Hide resolved
dt = raw.to_dict()
SebastianGode marked this conversation as resolved.
Show resolved Hide resolved
dt.pop('location')
data.append(dt)

# Filter data by deleting all entries without the right criteria as our Query doesn't support other queries
i = 0
while i < len(data):
if self.params['address']:
if data[i]['address'] != self.params['address']:
del data[i]
i = 0
continue
if self.params['hostname']:
if data[i]['hostname'] != self.params['hostname']:
del data[i]
i = 0
continue
if self.params['priority']:
if data[i]['priority'] != self.params['priority']:
del data[i]
i = 0
continue
i = i + 1

self.exit(
changed=False,
dns_nameservers=data
)


def main():
module = DNSNameserverInfoModule()
module()


if __name__ == '__main__':
main()
Loading