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

netcup_dnsapi: Add timeout paramter #5301

Merged
merged 4 commits into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions changelogs/fragments/5301-netcup_dnsapi-timeout.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
minor_changes:
- netcup_dnsapi - add ``timeout`` parameter (https://github.com/ansible-collections/community.general/pull/5301)
marcquark marked this conversation as resolved.
Show resolved Hide resolved

21 changes: 20 additions & 1 deletion plugins/modules/net_tools/netcup_dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
default: present
choices: [ 'present', 'absent' ]
type: str
timeout:
description:
- HTTP(s) connection timeout
marcquark marked this conversation as resolved.
Show resolved Hide resolved
default: 5
type: int
marcquark marked this conversation as resolved.
Show resolved Hide resolved
requirements:
- "nc-dnsapi >= 0.1.3"
author: "Nicolai Buchwitz (@nbuchwitz)"
Expand Down Expand Up @@ -129,6 +134,18 @@
type: "AAAA"
value: "::1"
solo: true

- name: Increase the connection timeout to avoid problems with an unstable connection
community.general.netcup_dns:
api_key: "..."
api_password: "..."
customer_id: "..."
domain: "example.com"
name: "mail"
type: "A"
value: "127.0.0.1"
timeout: 30

'''

RETURN = '''
Expand Down Expand Up @@ -193,6 +210,7 @@ def main():
priority=dict(required=False, type='int'),
solo=dict(required=False, type='bool', default=False),
state=dict(required=False, choices=['present', 'absent'], default='present'),
timeout=dict(required=False, type='int', default=5),

),
supports_check_mode=True
Expand All @@ -211,14 +229,15 @@ def main():
priority = module.params.get('priority')
solo = module.params.get('solo')
state = module.params.get('state')
timeout = module.params.get('timeout')

if record_type == 'MX' and not priority:
module.fail_json(msg="record type MX required the 'priority' argument")

has_changed = False
all_records = []
try:
with nc_dnsapi.Client(customer_id, api_key, api_password) as api:
with nc_dnsapi.Client(customer_id, api_key, api_password, timeout) as api:
all_records = api.dns_records(domain)
record = DNSRecord(record, record_type, value, priority=priority)

Expand Down