-
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
Open
SebastianGode
wants to merge
59
commits into
main
Choose a base branch
from
dns2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
DNS Info Modules #40
Changes from all commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
60a89ca
Added DNS Info Modules
SebastianGode 61ae16e
Fixed Whitespace
SebastianGode d6ab88f
Fixed Integration
SebastianGode 019071c
added dns_flaoting_ip
SebastianGode 5c007ee
Added docu FLIP and fixed pep8
SebastianGode e708dae
Fixed version_added
SebastianGode 3c61ac6
Fixed version_added
SebastianGode 888a57b
Deleted Date Filters
SebastianGode 219e9c0
some help for sebastian
tischrei f8c07ae
Merge branch 'dns2' of github.com:opentelekomcloud/ansible-collection…
tischrei 1a28ce0
Changed FQCN
SebastianGode 580e86e
Fixed Sanity Checks
SebastianGode d0aa795
Fixed issue creating recordset
SebastianGode d62a07a
Functional complete - Missing Docu
SebastianGode cda1665
Fixed many errors in nameserver_info
SebastianGode a0804b4
Fixed spelling
SebastianGode 3c6d76b
Removed Find function
SebastianGode 358289f
Fixed pep8 issues
SebastianGode 5c10501
Added correct Docu
SebastianGode 2360b60
Added working example
SebastianGode d7005e6
recordset update
tischrei 1ebcd49
New File for zone
SebastianGode 8acf59b
Merge branch 'dns3' of https://github.com/opentelekomcloud/ansible-co…
SebastianGode 02c1f29
First semi working zone script
SebastianGode 212f16f
Added Zone creation
SebastianGode 5fe003d
Fully working zone script - docu missing
SebastianGode 4088dff
Fixed Pep8, added docu
SebastianGode 4db6d44
Merge branch 'master' into dns3
SebastianGode c6ef466
Fixed Typo
SebastianGode 6e08f4d
Merge branch 'dns3' of https://github.com/opentelekomcloud/ansible-co…
SebastianGode 9a66401
Fixed Ansible Docu spaces and fixed changed on update
SebastianGode 8134862
Fixed pep8
SebastianGode 60535c8
Fixed pep8 + removed spaces
SebastianGode a13e3f2
changed version
SebastianGode fa37493
Added integration tests
SebastianGode b57ea75
Added Integration Tests
SebastianGode 6c09287
Added big Integration Test
SebastianGode 6592a0c
Fixed yamllint
SebastianGode 9c6eb1b
Added integration test
SebastianGode b50a866
Fixed Yamllint
SebastianGode a330db7
Fixed Sanity
SebastianGode 56ceedd
Fixed blank lines, fixed fqdn
SebastianGode a84ecce
Changed zone_find according to new PR
SebastianGode d60e624
Fixed Pep8
SebastianGode 236dae6
Added DNS Private Zone Test + ignore errors
SebastianGode 1a23f74
Fixed yamllint
SebastianGode 7541152
Fixed yamllint -2
SebastianGode c0c5cf3
Fixed ignore_errors
SebastianGode 95935e3
Fixed git
SebastianGode e1e939d
minor fix
tischrei 1315524
Merge branch 'dns3' into dns2
tischrei 64b465b
Merge branch 'master' into dns2
SebastianGode e5e8a1d
Added big integration test
SebastianGode f702fa5
Merge branch 'master' into dns2
SebastianGode 6a2a5f4
Merge branch 'master' into dns2
SebastianGode 299ac76
Merge branch 'master' into dns2
SebastianGode 2dcf588
New Integration Tests for info modules
SebastianGode d59b99a
Make dns_zone_info Upstream compliant
SebastianGode 905ff41
Fixed Sanity + Added Checkmode
SebastianGode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_floating_ip_info | ||
short_description: Get DNS PTR Records | ||
extends_documentation_fragment: opentelekomcloud.cloud.otc | ||
version_added: "0.2.1" | ||
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') | ||
) | ||
module_kwargs = dict( | ||
supports_check_mode=True | ||
) | ||
|
||
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
#!/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.2.1" | ||
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) | ||
) | ||
module_kwargs = dict( | ||
supports_check_mode=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() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.