-
Notifications
You must be signed in to change notification settings - Fork 14
DNS Info Modules #40
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
base: main
Are you sure you want to change the base?
DNS Info Modules #40
Changes from 3 commits
60a89ca
61ae16e
d6ab88f
019071c
5c007ee
e708dae
3c61ac6
888a57b
219e9c0
f8c07ae
1a28ce0
580e86e
d0aa795
d62a07a
cda1665
a0804b4
3c6d76b
358289f
5c10501
2360b60
d7005e6
1ebcd49
8acf59b
02c1f29
212f16f
5fe003d
4088dff
4db6d44
c6ef466
6e08f4d
9a66401
8134862
60535c8
a13e3f2
fa37493
b57ea75
6c09287
6592a0c
9c6eb1b
b50a866
a330db7
56ceedd
a84ecce
d60e624
236dae6
1a23f74
7541152
c0c5cf3
95935e3
e1e939d
1315524
64b465b
e5e8a1d
f702fa5
6a2a5f4
299ac76
2dcf588
d59b99a
905ff41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
#!/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_floating_ip_info | ||
short_description: Get DNS PTR Records | ||
extends_documentation_fragment: opentelekomcloud.cloud.otc | ||
version_added: "0.0.1" | ||
SebastianGode marked this conversation as resolved.
Outdated
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 Nameserver Info about a zone: | ||
- name: Getting Info | ||
dns_floating_ip_info: | ||
SebastianGode marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
description: "Test" | ||
|
||
''' | ||
|
||
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): | ||
|
||
data = [] | ||
|
||
for raw in self.conn.dns.floating_ips(): | ||
dt = raw.to_dict() | ||
dt.pop('location') | ||
data.append(dt) | ||
|
||
# Filter data by deleting all entries without the right criteria | ||
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['id']: | ||
if data[i]['id'] != self.params['id']: | ||
del data[i] | ||
i = 0 | ||
continue | ||
if self.params['ptrdname']: | ||
if data[i]['ptrdname'] != self.params['ptrdname']: | ||
del data[i] | ||
i = 0 | ||
continue | ||
if self.params['ttl']: | ||
if data[i]['ttl'] != self.params['ttl']: | ||
del data[i] | ||
i = 0 | ||
continue | ||
if self.params['description']: | ||
if data[i]['description'] != self.params['description']: | ||
del data[i] | ||
i = 0 | ||
continue | ||
if self.params['status']: | ||
if data[i]['status'] != self.params['status']: | ||
del data[i] | ||
i = 0 | ||
continue | ||
i = i + 1 | ||
|
||
self.exit( | ||
changed=False, | ||
ptr_records=data | ||
) | ||
|
||
|
||
def main(): | ||
module = DNSFloatingIpInfoModule() | ||
module() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
#!/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.0.3" | ||
SebastianGode marked this conversation as resolved.
Outdated
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 | ||
dns_nameserver_info: | ||
SebastianGode marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
zone: fe40808272701cbe0172cbca17f91882 | ||
|
||
''' | ||
|
||
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']) | ||
) | ||
|
||
if self.params['priority']: | ||
query['priority'] = self.params['priority'] | ||
if self.params['priority']: | ||
SebastianGode marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
query['address'] = self.params['priority'] | ||
if self.params['priority']: | ||
query['priority'] = self.params['priority'] | ||
|
||
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) | ||
|
||
self.exit( | ||
changed=False, | ||
dns_nameservers=data | ||
) | ||
|
||
|
||
def main(): | ||
module = DNSNameserverInfoModule() | ||
module() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Uh oh!
There was an error while loading. Please reload this page.