From 8d7c2bafb5807bd9aef6aed538322d087f4a71a7 Mon Sep 17 00:00:00 2001 From: Rafael Guterres Jeffman Date: Sun, 17 Sep 2023 22:34:48 -0300 Subject: [PATCH] idoverideuser: Use module.params_get_type Use the commom parameter type handling method for parameters that accept a value or an empty string. --- plugins/modules/ipaidoverrideuser.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/plugins/modules/ipaidoverrideuser.py b/plugins/modules/ipaidoverrideuser.py index 2dc75091fc..48e44be1a3 100644 --- a/plugins/modules/ipaidoverrideuser.py +++ b/plugins/modules/ipaidoverrideuser.py @@ -439,9 +439,9 @@ def main(): # present description = ansible_module.params_get("description") name = ansible_module.params_get("name") - uid = ansible_module.params_get("uid") + uid = ansible_module.params_get_type("uid", int) gecos = ansible_module.params_get("gecos") - gidnumber = ansible_module.params_get("gidnumber") + gidnumber = ansible_module.params_get_type("gidnumber", int) homedir = ansible_module.params_get("homedir") shell = ansible_module.params_get("shell") sshpubkey = ansible_module.params_get("sshpubkey") @@ -479,20 +479,6 @@ def main(): ansible_module.params_fail_used_invalid(invalid, state, action) - # Ensure parameter values are valid and have proper type. - def int_or_empty_param(value, param): - if value is not None and value != "": - try: - value = int(value) - except ValueError: - ansible_module.fail_json( - msg="Invalid value '%s' for argument '%s'" % (value, param) - ) - return value - - uid = int_or_empty_param(uid, "uid") - gidnumber = int_or_empty_param(gidnumber, "gidnumber") - if certificate is not None: certificate = [cert.strip() for cert in certificate]