From 06c8a670550a1fd4f7898b266cf155ba755c2bb4 Mon Sep 17 00:00:00 2001 From: Marc Leuser Date: Wed, 21 Sep 2022 21:37:05 +0200 Subject: [PATCH 1/4] netcup_dnsapi: Add timeout paramter --- plugins/modules/net_tools/netcup_dns.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/plugins/modules/net_tools/netcup_dns.py b/plugins/modules/net_tools/netcup_dns.py index e6bf3de0c34..2ba76859d6c 100644 --- a/plugins/modules/net_tools/netcup_dns.py +++ b/plugins/modules/net_tools/netcup_dns.py @@ -72,6 +72,11 @@ default: present choices: [ 'present', 'absent' ] type: str + timeout: + description: + - HTTP(s) connection timeout + default: 5 + type: int requirements: - "nc-dnsapi >= 0.1.3" author: "Nicolai Buchwitz (@nbuchwitz)" @@ -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 = ''' @@ -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 @@ -211,6 +229,7 @@ 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") @@ -218,7 +237,7 @@ def main(): 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) From 8d0b06a2f332439e1f8aa2b8f0202c8d4e8ccf61 Mon Sep 17 00:00:00 2001 From: Marc Leuser Date: Wed, 21 Sep 2022 21:51:12 +0200 Subject: [PATCH 2/4] add changelog fragment --- changelogs/fragments/5301-netcup_dnsapi-timeout.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelogs/fragments/5301-netcup_dnsapi-timeout.yml diff --git a/changelogs/fragments/5301-netcup_dnsapi-timeout.yml b/changelogs/fragments/5301-netcup_dnsapi-timeout.yml new file mode 100644 index 00000000000..7ea6d7a3a19 --- /dev/null +++ b/changelogs/fragments/5301-netcup_dnsapi-timeout.yml @@ -0,0 +1,3 @@ +minor_changes: + - netcup_dnsapi - add ``timeout`` parameter (https://github.com/ansible-collections/community.general/pull/5301) + From 9b85a8b6629dc3c7016fe5eee146deab31aab665 Mon Sep 17 00:00:00 2001 From: Marc Leuser Date: Wed, 21 Sep 2022 22:18:28 +0200 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Felix Fontein --- changelogs/fragments/5301-netcup_dnsapi-timeout.yml | 2 +- plugins/modules/net_tools/netcup_dns.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/changelogs/fragments/5301-netcup_dnsapi-timeout.yml b/changelogs/fragments/5301-netcup_dnsapi-timeout.yml index 7ea6d7a3a19..1d84a21c23b 100644 --- a/changelogs/fragments/5301-netcup_dnsapi-timeout.yml +++ b/changelogs/fragments/5301-netcup_dnsapi-timeout.yml @@ -1,3 +1,3 @@ minor_changes: - - netcup_dnsapi - add ``timeout`` parameter (https://github.com/ansible-collections/community.general/pull/5301) + - netcup_dnsapi - add ``timeout`` parameter (https://github.com/ansible-collections/community.general/pull/5301). diff --git a/plugins/modules/net_tools/netcup_dns.py b/plugins/modules/net_tools/netcup_dns.py index 2ba76859d6c..5d082c29809 100644 --- a/plugins/modules/net_tools/netcup_dns.py +++ b/plugins/modules/net_tools/netcup_dns.py @@ -74,9 +74,10 @@ type: str timeout: description: - - HTTP(s) connection timeout + - HTTP(S) connection timeout in seconds. default: 5 type: int + version_added: 5.7.0 requirements: - "nc-dnsapi >= 0.1.3" author: "Nicolai Buchwitz (@nbuchwitz)" From d452eb5e0e92935af2767c02ac841cb268b98131 Mon Sep 17 00:00:00 2001 From: Marc Leuser Date: Wed, 21 Sep 2022 22:24:46 +0200 Subject: [PATCH 4/4] remove unnecessary newline --- changelogs/fragments/5301-netcup_dnsapi-timeout.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/changelogs/fragments/5301-netcup_dnsapi-timeout.yml b/changelogs/fragments/5301-netcup_dnsapi-timeout.yml index 1d84a21c23b..e7afd5b2835 100644 --- a/changelogs/fragments/5301-netcup_dnsapi-timeout.yml +++ b/changelogs/fragments/5301-netcup_dnsapi-timeout.yml @@ -1,3 +1,2 @@ minor_changes: - netcup_dnsapi - add ``timeout`` parameter (https://github.com/ansible-collections/community.general/pull/5301). -