From d2375e07a6100b0c7aa4dbf533aaa6db90c9d87d Mon Sep 17 00:00:00 2001 From: Sebastian Tobie Date: Sun, 23 Apr 2023 09:16:48 +0200 Subject: [PATCH] fixed the raise of KeyError since all values are None if unset --- plugins/module_utils/module.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/module_utils/module.py b/plugins/module_utils/module.py index 801f9f0..d8fe8f4 100644 --- a/plugins/module_utils/module.py +++ b/plugins/module_utils/module.py @@ -96,10 +96,10 @@ class AnsibleModule(object): def get(self, key: str, default: T = None) -> T: """returns an Parameter of the Module.""" - if key not in self.params: - raise KeyError() if self.params[key] is None and default is not None: return default + elif self.params[key] is None and default is None: + raise KeyError() return self.params[key] def changed_get(self):