diff --git a/plugins/doc_fragments/zabbix.py b/plugins/doc_fragments/zabbix.py index 2d49da308..2cd64b00f 100644 --- a/plugins/doc_fragments/zabbix.py +++ b/plugins/doc_fragments/zabbix.py @@ -46,15 +46,15 @@ class ModuleDocFragment(object): description: - The timeout of API request (seconds). - This option is deprecated with the move to httpapi connection and will be removed in the next release + - The default value is C(10) type: int - default: 10 validate_certs: - description: - - If set to False, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. - - If not set the environment variable C(ZABBIX_VALIDATE_CERTS) will be used. - - This option is deprecated with the move to httpapi connection and will be removed in the next release - type: bool - default: true + description: + - If set to False, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. + - If not set the environment variable C(ZABBIX_VALIDATE_CERTS) will be used. + - This option is deprecated with the move to httpapi connection and will be removed in the next release + - The default value is C(true) + type: bool notes: - If you use I(login_password=zabbix), the word "zabbix" is replaced by "********" in all module output, because I(login_password) uses C(no_log). See L(this FAQ,https://docs.ansible.com/ansible/latest/network/user_guide/faq.html#why-is-my-output-sometimes-replaced-with) for more information. diff --git a/plugins/module_utils/helpers.py b/plugins/module_utils/helpers.py index 7071fe60b..6c9c0fca5 100644 --- a/plugins/module_utils/helpers.py +++ b/plugins/module_utils/helpers.py @@ -51,13 +51,11 @@ def zabbix_common_argument_spec(): no_log=True ), timeout=dict( - type='int', - default=10 + type='int' ), validate_certs=dict( type='bool', required=False, - default=True, fallback=(env_fallback, ['ZABBIX_VALIDATE_CERTS']) ), ) diff --git a/plugins/module_utils/wrappers.py b/plugins/module_utils/wrappers.py index 1e3a43555..a982108f8 100644 --- a/plugins/module_utils/wrappers.py +++ b/plugins/module_utils/wrappers.py @@ -36,8 +36,17 @@ def __init__(self, module, zbx=None): self._zapi = zbx else: server_url = module.params['server_url'] - validate_certs = module.params['validate_certs'] - timeout = module.params['timeout'] + + if module.params['validate_certs'] is None: + validate_certs = True + else: + validate_certs = module.params['validate_certs'] + + if module.params['timeout'] is None: + timeout = 10 + else: + timeout = module.params['timeout'] + self._zapi = ZabbixAPI(server_url, timeout=timeout, validate_certs=validate_certs) self.login() diff --git a/plugins/modules/zabbix_action.py b/plugins/modules/zabbix_action.py index 5d6b7cd9d..751a8a62a 100644 --- a/plugins/modules/zabbix_action.py +++ b/plugins/modules/zabbix_action.py @@ -1967,8 +1967,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) name = module.params['name'] diff --git a/plugins/modules/zabbix_authentication.py b/plugins/modules/zabbix_authentication.py index b0d47984f..d522f554d 100644 --- a/plugins/modules/zabbix_authentication.py +++ b/plugins/modules/zabbix_authentication.py @@ -559,8 +559,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) authentication_type = module.params['authentication_type'] diff --git a/plugins/modules/zabbix_autoregister.py b/plugins/modules/zabbix_autoregister.py index e68a87ef5..228b6449e 100644 --- a/plugins/modules/zabbix_autoregister.py +++ b/plugins/modules/zabbix_autoregister.py @@ -198,8 +198,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) tls_accept = module.params['tls_accept'] diff --git a/plugins/modules/zabbix_discovery_rule.py b/plugins/modules/zabbix_discovery_rule.py index e233ed993..b556d4cb8 100644 --- a/plugins/modules/zabbix_discovery_rule.py +++ b/plugins/modules/zabbix_discovery_rule.py @@ -649,8 +649,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) state = module.params['state'] diff --git a/plugins/modules/zabbix_globalmacro.py b/plugins/modules/zabbix_globalmacro.py index aeb0ba721..0c1686394 100644 --- a/plugins/modules/zabbix_globalmacro.py +++ b/plugins/modules/zabbix_globalmacro.py @@ -244,8 +244,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) macro_name = normalize_macro_name(module.params['macro_name']) diff --git a/plugins/modules/zabbix_group_info.py b/plugins/modules/zabbix_group_info.py index 7631e256f..fb22e3a25 100644 --- a/plugins/modules/zabbix_group_info.py +++ b/plugins/modules/zabbix_group_info.py @@ -97,8 +97,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) if module._name == 'zabbix_group_facts': diff --git a/plugins/modules/zabbix_host.py b/plugins/modules/zabbix_host.py index dd127ad1d..55a4d61ab 100644 --- a/plugins/modules/zabbix_host.py +++ b/plugins/modules/zabbix_host.py @@ -1048,8 +1048,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) host_name = module.params['host_name'] diff --git a/plugins/modules/zabbix_host_events_info.py b/plugins/modules/zabbix_host_events_info.py index b16724857..48a56f3fc 100644 --- a/plugins/modules/zabbix_host_events_info.py +++ b/plugins/modules/zabbix_host_events_info.py @@ -274,8 +274,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) trigger_severity_map = {'not_classified': 0, 'information': 1, 'warning': 2, 'average': 3, 'high': 4, 'disaster': 5} diff --git a/plugins/modules/zabbix_hostmacro.py b/plugins/modules/zabbix_hostmacro.py index 12ce8d9aa..de3e0f064 100644 --- a/plugins/modules/zabbix_hostmacro.py +++ b/plugins/modules/zabbix_hostmacro.py @@ -226,8 +226,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) host_name = module.params['host_name'] diff --git a/plugins/modules/zabbix_housekeeping.py b/plugins/modules/zabbix_housekeeping.py index 2eed4677d..c574aef24 100644 --- a/plugins/modules/zabbix_housekeeping.py +++ b/plugins/modules/zabbix_housekeeping.py @@ -367,8 +367,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) hk_events_mode = module.params['hk_events_mode'] diff --git a/plugins/modules/zabbix_maintenance.py b/plugins/modules/zabbix_maintenance.py index 5da574641..814386bc4 100644 --- a/plugins/modules/zabbix_maintenance.py +++ b/plugins/modules/zabbix_maintenance.py @@ -363,8 +363,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) maint = MaintenanceModule(module) diff --git a/plugins/modules/zabbix_map.py b/plugins/modules/zabbix_map.py index f6a95fac5..376a82d36 100644 --- a/plugins/modules/zabbix_map.py +++ b/plugins/modules/zabbix_map.py @@ -783,8 +783,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) if not HAS_PYDOTPLUS: diff --git a/plugins/modules/zabbix_mediatype.py b/plugins/modules/zabbix_mediatype.py index 21c27b09f..0ed643b57 100644 --- a/plugins/modules/zabbix_mediatype.py +++ b/plugins/modules/zabbix_mediatype.py @@ -718,8 +718,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) state = module.params['state'] diff --git a/plugins/modules/zabbix_proxy.py b/plugins/modules/zabbix_proxy.py index 4be56fca6..2c18e6fb4 100644 --- a/plugins/modules/zabbix_proxy.py +++ b/plugins/modules/zabbix_proxy.py @@ -363,8 +363,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) proxy_name = module.params['proxy_name'] diff --git a/plugins/modules/zabbix_proxy_info.py b/plugins/modules/zabbix_proxy_info.py index f0865dd63..c181b45ce 100644 --- a/plugins/modules/zabbix_proxy_info.py +++ b/plugins/modules/zabbix_proxy_info.py @@ -167,8 +167,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) name = module.params['proxy_name'] diff --git a/plugins/modules/zabbix_screen.py b/plugins/modules/zabbix_screen.py index 09496e1e4..fc7a561e1 100644 --- a/plugins/modules/zabbix_screen.py +++ b/plugins/modules/zabbix_screen.py @@ -382,8 +382,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) screens = module.params['screens'] diff --git a/plugins/modules/zabbix_script.py b/plugins/modules/zabbix_script.py index 0f02cff8c..cde8b3804 100644 --- a/plugins/modules/zabbix_script.py +++ b/plugins/modules/zabbix_script.py @@ -415,8 +415,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) name = module.params['name'] diff --git a/plugins/modules/zabbix_service.py b/plugins/modules/zabbix_service.py index f84db923e..e46ca550d 100644 --- a/plugins/modules/zabbix_service.py +++ b/plugins/modules/zabbix_service.py @@ -654,8 +654,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) name = module.params['name'] diff --git a/plugins/modules/zabbix_template.py b/plugins/modules/zabbix_template.py index 482ea8c3b..f158751ad 100644 --- a/plugins/modules/zabbix_template.py +++ b/plugins/modules/zabbix_template.py @@ -733,8 +733,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) template_name = module.params['template_name'] diff --git a/plugins/modules/zabbix_template_info.py b/plugins/modules/zabbix_template_info.py index 9317abd51..89df1abd5 100644 --- a/plugins/modules/zabbix_template_info.py +++ b/plugins/modules/zabbix_template_info.py @@ -284,8 +284,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) template_name = module.params['template_name'] diff --git a/plugins/modules/zabbix_user.py b/plugins/modules/zabbix_user.py index 8a4b4bece..3358dfb38 100644 --- a/plugins/modules/zabbix_user.py +++ b/plugins/modules/zabbix_user.py @@ -677,8 +677,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) username = module.params['username'] diff --git a/plugins/modules/zabbix_user_directory.py b/plugins/modules/zabbix_user_directory.py index b8077c35f..e5bcaca95 100644 --- a/plugins/modules/zabbix_user_directory.py +++ b/plugins/modules/zabbix_user_directory.py @@ -159,8 +159,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) parameters = { diff --git a/plugins/modules/zabbix_user_info.py b/plugins/modules/zabbix_user_info.py index 18a1e826d..55a9c4a61 100644 --- a/plugins/modules/zabbix_user_info.py +++ b/plugins/modules/zabbix_user_info.py @@ -151,8 +151,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) username = module.params['username'] diff --git a/plugins/modules/zabbix_user_role.py b/plugins/modules/zabbix_user_role.py index e73455d16..bd2ceb607 100644 --- a/plugins/modules/zabbix_user_role.py +++ b/plugins/modules/zabbix_user_role.py @@ -177,8 +177,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection ' 'and will be removed in the next release' % p) diff --git a/plugins/modules/zabbix_usergroup.py b/plugins/modules/zabbix_usergroup.py index 78e0c18c2..1651fa64e 100644 --- a/plugins/modules/zabbix_usergroup.py +++ b/plugins/modules/zabbix_usergroup.py @@ -449,8 +449,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) name = module.params['name'] diff --git a/plugins/modules/zabbix_valuemap.py b/plugins/modules/zabbix_valuemap.py index 1fddd340d..232fc1797 100644 --- a/plugins/modules/zabbix_valuemap.py +++ b/plugins/modules/zabbix_valuemap.py @@ -231,8 +231,8 @@ def main(): zabbix_utils.require_creds_params(module) - for p in ['server_url', 'login_user', 'login_password']: - if p in module.params and module.params[p]: + for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']: + if p in module.params and not module.params[p] is None: module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p) vm = ValuemapModule(module)