diff --git a/plugins/module_utils/ansible_freeipa_module.py b/plugins/module_utils/ansible_freeipa_module.py
index 4840dcd4623979e1453b27879d7328a7f1bdc30c..c6307aea0ac1e41319687dea65a7d4062b68956d 100644
--- a/plugins/module_utils/ansible_freeipa_module.py
+++ b/plugins/module_utils/ansible_freeipa_module.py
@@ -699,6 +699,30 @@ else:
             """
             return module_params_get(self, name)
 
+        def params_fail_used_invalid(self, invalid_params, state, action=None):
+            """
+            Fail module execution if one of the invalid parameters is not None.
+
+            Parameters
+            ----------
+            invalid_params:
+                List of parameters that must value 'None'.
+            state:
+                State being tested.
+            action:
+                Action being tested (optional).
+
+            """
+            if action is None:
+                msg = "Argument '{0}' can not be used with state '{1}'"
+            else:
+                msg = "Argument '{0}' can not be used with action "\
+                      "'{2}' and state '{1}'"
+
+            for param in invalid_params:
+                if self.params.get(param) is not None:
+                    self.fail_json(msg=msg.format(param, state, action))
+
         def ipa_command(self, command, name, args):
             """
             Execute an IPA API command with a required `name` argument.
diff --git a/plugins/modules/ipaautomember.py b/plugins/modules/ipaautomember.py
index 9a93cd23c1d8b662daa79d615b010ef35fad5fc0..7230ea57f920fa3376cd561a8c953e4f64ef7499 100644
--- a/plugins/modules/ipaautomember.py
+++ b/plugins/modules/ipaautomember.py
@@ -245,12 +245,17 @@ def main():
     rebuild_users = ansible_module.params_get("users")
     rebuild_hosts = ansible_module.params_get("hosts")
 
-    if (rebuild_hosts or rebuild_users) and state != "rebuild":
-        ansible_module.fail_json(
-            msg="'hosts' and 'users' are only valid with state: rebuild")
-    if not automember_type and state != "rebuild":
-        ansible_module.fail_json(
-            msg="'automember_type' is required unless state: rebuild")
+    # Check parameters
+    invalid = []
+
+    if state != "rebuild":
+        invalid = ["rebuild_hosts", "rebuild_users"]
+
+        if not automember_type and state != "rebuild":
+            ansible_module.fail_json(
+                msg="'automember_type' is required unless state: rebuild")
+
+    ansible_module.params_fail_used_invalid(invalid, state, action)
 
     # Init
     changed = False
diff --git a/plugins/modules/ipadelegation.py b/plugins/modules/ipadelegation.py
index 3ebbe88c01d31458a80afb2127e1479c37842f6f..335930568da0483274a2db85b88ab3df2658e572 100644
--- a/plugins/modules/ipadelegation.py
+++ b/plugins/modules/ipadelegation.py
@@ -176,17 +176,14 @@ def main():
 
     # Check parameters
 
+    invalid = []
+
     if state == "present":
         if len(names) != 1:
             ansible_module.fail_json(
                 msg="Only one delegation be added at a time.")
         if action == "member":
             invalid = ["permission", "membergroup", "group"]
-            for x in invalid:
-                if vars()[x] is not None:
-                    ansible_module.fail_json(
-                        msg="Argument '%s' can not be used with action "
-                        "'%s' and state '%s'" % (x, action, state))
 
     if state == "absent":
         if len(names) < 1:
@@ -194,11 +191,8 @@ def main():
         invalid = ["permission", "membergroup", "group"]
         if action == "delegation":
             invalid.append("attribute")
-        for x in invalid:
-            if vars()[x] is not None:
-                ansible_module.fail_json(
-                    msg="Argument '%s' can not be used with action "
-                    "'%s' and state '%s'" % (x, action, state))
+
+    ansible_module.params_fail_used_invalid(invalid, state, action)
 
     if permission is not None:
         perm = [p for p in permission if p not in ("read", "write")]
diff --git a/plugins/modules/ipadnsconfig.py b/plugins/modules/ipadnsconfig.py
index 843237f02cb24bece960d6d61405a8c9489b7c24..889b7ee7c79b76ef032463f6bd55ce193dd4894c 100644
--- a/plugins/modules/ipadnsconfig.py
+++ b/plugins/modules/ipadnsconfig.py
@@ -196,11 +196,7 @@ def main():
     if state == 'absent':
         invalid = ['forward_policy', 'allow_sync_ptr']
 
-    for x in invalid:
-        if vars()[x] is not None:
-            ansible_module.fail_json(
-                msg="Argument '%s' can not be used with state '%s'" %
-                (x, state))
+    ansible_module.params_fail_used_invalid(invalid, state)
 
     # Init
 
diff --git a/plugins/modules/ipadnsforwardzone.py b/plugins/modules/ipadnsforwardzone.py
index 492a31732a928ff6a338d75769be0a2cd58bc6c6..09ff09b99eb6723f3e8bdb828f8a5a85d9856fdf 100644
--- a/plugins/modules/ipadnsforwardzone.py
+++ b/plugins/modules/ipadnsforwardzone.py
@@ -229,6 +229,7 @@ def main():
     else:
         operation = "add"
 
+    invalid = []
     if state in ["enabled", "disabled"]:
         if action == "member":
             ansible_module.fail_json(
@@ -237,22 +238,14 @@ def main():
         invalid = [
             "forwarders", "forwardpolicy", "skip_overlap_check", "permission"
         ]
-        for x in invalid:
-            if vars()[x] is not None:
-                ansible_module.fail_json(
-                    msg="Argument '%s' can not be used with action "
-                    "'%s', state `%s`" % (x, action, state))
         wants_enable = (state == "enabled")
 
     if operation == "del":
         invalid = [
             "forwarders", "forwardpolicy", "skip_overlap_check", "permission"
         ]
-        for x in invalid:
-            if vars()[x] is not None:
-                ansible_module.fail_json(
-                    msg="Argument '%s' can not be used with action "
-                    "'%s', state `%s`" % (x, action, state))
+
+    ansible_module.params_fail_used_invalid(invalid, state, action)
 
     changed = False
     exit_args = {}
diff --git a/plugins/modules/ipadnsrecord.py b/plugins/modules/ipadnsrecord.py
index 69b9212ab03f9577ed3b3bc441902dfe25b3de58..9f8d27720c1a30fe8782b91541c4777983cb4f00 100644
--- a/plugins/modules/ipadnsrecord.py
+++ b/plugins/modules/ipadnsrecord.py
@@ -1201,11 +1201,7 @@ def check_parameters(module, state, zone_name, record):
         invalid = list(_PART_MAP.keys())
         invalid.extend(['create_reverse', 'dns_ttl'])
 
-    for x in invalid:
-        if x in record:
-            module.fail_json(
-                msg="Variable `%s` cannot be used in state `%s`" %
-                    (x, state))
+    module.params_fail_used_invalid(invalid, state)
 
 
 def get_entry_from_module(module, name):
diff --git a/plugins/modules/ipadnszone.py b/plugins/modules/ipadnszone.py
index 30ceef271f3c872d79bf5bf8d8a97308c31ae434..c1354d3aca2ae6e31c1447d23c5e4c7b247f0277 100644
--- a/plugins/modules/ipadnszone.py
+++ b/plugins/modules/ipadnszone.py
@@ -429,13 +429,10 @@ class DNSZoneModule(FreeIPABaseModule):
             self.fail_json(
                 msg="Either `name` or `name_from_ip` must be provided."
             )
-        if self.ipa_params.state != "present" and self.ipa_params.name_from_ip:
-            self.fail_json(
-                msg=(
-                    "Cannot use argument `name_from_ip` with state `%s`."
-                    % self.ipa_params.state
-                )
-            )
+        if self.ipa_params.state != "present":
+            invalid = ["name_from_ip"]
+
+            self.params_fail_used_invalid(invalid, self.ipa_params.state)
 
     def define_ipa_commands(self):
         for zone_name in self.get_zone_names():
diff --git a/plugins/modules/ipagroup.py b/plugins/modules/ipagroup.py
index a502f935b35d26dd58c6ec9166d156d2192c9c41..2815b460dd8ffa9802d03f51813f3d36f208fe1c 100644
--- a/plugins/modules/ipagroup.py
+++ b/plugins/modules/ipagroup.py
@@ -314,6 +314,7 @@ def main():
     state = ansible_module.params_get("state")
 
     # Check parameters
+    invalid = []
 
     if state == "present":
         if len(names) != 1:
@@ -322,11 +323,6 @@ def main():
         if action == "member":
             invalid = ["description", "gid", "posix", "nonposix", "external",
                        "nomembers"]
-            for x in invalid:
-                if vars()[x] is not None:
-                    ansible_module.fail_json(
-                        msg="Argument '%s' can not be used with action "
-                        "'%s'" % (x, action))
 
     if state == "absent":
         if len(names) < 1:
@@ -336,11 +332,8 @@ def main():
                    "nomembers"]
         if action == "group":
             invalid.extend(["user", "group", "service", "externalmember"])
-        for x in invalid:
-            if vars()[x] is not None:
-                ansible_module.fail_json(
-                    msg="Argument '%s' can not be used with state '%s'" %
-                    (x, state))
+
+    ansible_module.params_fail_used_invalid(invalid, state, action)
 
     if external is False:
         ansible_module.fail_json(
diff --git a/plugins/modules/ipahbacrule.py b/plugins/modules/ipahbacrule.py
index 1d6a3b2fe4e881b883b9e66f015734e7fefef866..3547b95afc3e9eaa19d911caa9af8518bcc06a9b 100644
--- a/plugins/modules/ipahbacrule.py
+++ b/plugins/modules/ipahbacrule.py
@@ -247,6 +247,8 @@ def main():
 
     # Check parameters
 
+    invalid = []
+
     if state == "present":
         if len(names) != 1:
             ansible_module.fail_json(
@@ -254,11 +256,6 @@ def main():
         if action == "member":
             invalid = ["description", "usercategory", "hostcategory",
                        "servicecategory", "nomembers"]
-            for x in invalid:
-                if vars()[x] is not None:
-                    ansible_module.fail_json(
-                        msg="Argument '%s' can not be used with action "
-                        "'%s'" % (x, action))
         else:
             if hostcategory == 'all' and any([host, hostgroup]):
                 ansible_module.fail_json(
@@ -278,11 +275,6 @@ def main():
         if action == "hbacrule":
             invalid.extend(["host", "hostgroup", "hbacsvc", "hbacsvcgroup",
                             "user", "group"])
-        for x in invalid:
-            if vars()[x] is not None:
-                ansible_module.fail_json(
-                    msg="Argument '%s' can not be used with state '%s'" %
-                    (x, state))
 
     elif state in ["enabled", "disabled"]:
         if len(names) < 1:
@@ -294,14 +286,11 @@ def main():
         invalid = ["description", "usercategory", "hostcategory",
                    "servicecategory", "nomembers", "host", "hostgroup",
                    "hbacsvc", "hbacsvcgroup", "user", "group"]
-        for x in invalid:
-            if vars()[x] is not None:
-                ansible_module.fail_json(
-                    msg="Argument '%s' can not be used with state '%s'" %
-                    (x, state))
     else:
         ansible_module.fail_json(msg="Invalid state '%s'" % state)
 
+    ansible_module.params_fail_used_invalid(invalid, state, action)
+
     # Init
 
     changed = False
diff --git a/plugins/modules/ipahbacsvc.py b/plugins/modules/ipahbacsvc.py
index 12c8476d76b84a93d2fbbc23229e656ba0d5ff01..30e9fddec3496249dd305af338aa7556db64e432 100644
--- a/plugins/modules/ipahbacsvc.py
+++ b/plugins/modules/ipahbacsvc.py
@@ -127,6 +127,7 @@ def main():
 
     # Check parameters
 
+    invalid = []
     if state == "present":
         if len(names) != 1:
             ansible_module.fail_json(
@@ -137,11 +138,8 @@ def main():
             ansible_module.fail_json(
                 msg="No name given.")
         invalid = ["description"]
-        for x in invalid:
-            if vars()[x] is not None:
-                ansible_module.fail_json(
-                    msg="Argument '%s' can not be used with state '%s'" %
-                    (x, state))
+
+    ansible_module.params_fail_used_invalid(invalid, state)
 
     # Init
 
diff --git a/plugins/modules/ipahbacsvcgroup.py b/plugins/modules/ipahbacsvcgroup.py
index 1e6e3439b846f65933326125a5b405b28da6471d..60f05d2de37e3bb5af4c76909aad3cc6757e8325 100644
--- a/plugins/modules/ipahbacsvcgroup.py
+++ b/plugins/modules/ipahbacsvcgroup.py
@@ -187,17 +187,14 @@ def main():
 
     # Check parameters
 
+    invalid = []
+
     if state == "present":
         if len(names) != 1:
             ansible_module.fail_json(
                 msg="Only one hbacsvcgroup can be added at a time.")
         if action == "member":
             invalid = ["description", "nomembers"]
-            for x in invalid:
-                if vars()[x] is not None:
-                    ansible_module.fail_json(
-                        msg="Argument '%s' can not be used with action "
-                        "'%s'" % (x, action))
 
     if state == "absent":
         if len(names) < 1:
@@ -206,11 +203,8 @@ def main():
         invalid = ["description", "nomembers"]
         if action == "hbacsvcgroup":
             invalid.extend(["hbacsvc"])
-        for x in invalid:
-            if vars()[x] is not None:
-                ansible_module.fail_json(
-                    msg="Argument '%s' can not be used with state '%s'" %
-                    (x, state))
+
+    ansible_module.params_fail_used_invalid(invalid, state, action)
 
     # Init
 
diff --git a/plugins/modules/ipahost.py b/plugins/modules/ipahost.py
index 934030014a34c485b8a084e33ee1cc7dd0bee824..aa94ccec1b3efdb0a77095b61752235e42d15eb9 100644
--- a/plugins/modules/ipahost.py
+++ b/plugins/modules/ipahost.py
@@ -530,6 +530,7 @@ def check_parameters(   # pylint: disable=unused-argument
         userclass, auth_ind, requires_pre_auth, ok_as_delegate,
         ok_to_auth_as_delegate, force, reverse, ip_address, update_dns,
         update_password):
+    invalid = []
     if state == "present":
         if action == "member":
             # certificate, managedby_host, principal,
@@ -539,11 +540,6 @@ def check_parameters(   # pylint: disable=unused-argument
                        "userclass", "auth_ind", "requires_pre_auth",
                        "ok_as_delegate", "ok_to_auth_as_delegate", "force",
                        "reverse", "update_dns", "update_password"]
-            for x in invalid:
-                if vars()[x] is not None:
-                    module.fail_json(
-                        msg="Argument '%s' can not be used with action "
-                        "'%s'" % (x, action))
 
     if state == "absent":
         invalid = ["description", "locality", "location", "platform", "os",
@@ -551,11 +547,6 @@ def check_parameters(   # pylint: disable=unused-argument
                    "userclass", "auth_ind", "requires_pre_auth",
                    "ok_as_delegate", "ok_to_auth_as_delegate", "force",
                    "reverse", "update_password"]
-        for x in invalid:
-            if vars()[x] is not None:
-                module.fail_json(
-                    msg="Argument '%s' can not be used with state '%s'" %
-                    (x, state))
         if action == "host":
             invalid = [
                 "certificate", "managedby_host", "principal",
@@ -565,11 +556,8 @@ def check_parameters(   # pylint: disable=unused-argument
                 "allow_retrieve_keytab_host",
                 "allow_retrieve_keytab_hostgroup"
             ]
-            for x in invalid:
-                if vars()[x] is not None:
-                    module.fail_json(
-                        msg="Argument '%s' can only be used with action "
-                        "'member' for state '%s'" % (x, state))
+
+    module.params_fail_used_invalid(invalid, state, action)
 
 
 # pylint: disable=unused-argument
diff --git a/plugins/modules/ipahostgroup.py b/plugins/modules/ipahostgroup.py
index b2f553f730fa27e0c5cfc13ee9406f5745af63ca..cf9ce90c7b1e1fcfcc41926ff7614d9d4707e9da 100644
--- a/plugins/modules/ipahostgroup.py
+++ b/plugins/modules/ipahostgroup.py
@@ -224,6 +224,7 @@ def main():
 
     # Check parameters
 
+    invalid = []
     if state == "present":
         if len(names) != 1:
             ansible_module.fail_json(
@@ -231,11 +232,6 @@ def main():
         invalid = ["rename"]
         if action == "member":
             invalid.extend(["description", "nomembers"])
-        for x in invalid:
-            if vars()[x] is not None:
-                ansible_module.fail_json(
-                    msg="Argument '%s' can not be used with action "
-                    "'%s'" % (x, action))
 
     if state == "renamed":
         if len(names) != 1:
@@ -249,11 +245,6 @@ def main():
             "description", "nomembers", "host", "hostgroup",
             "membermanager_user", "membermanager_group"
         ]
-        for x in invalid:
-            if vars()[x] is not None:
-                ansible_module.fail_json(
-                    msg="Argument '%s' can not be used with state '%s'" %
-                    (x, state))
 
     if state == "absent":
         if len(names) < 1:
@@ -262,11 +253,8 @@ def main():
         invalid = ["description", "nomembers", "rename"]
         if action == "hostgroup":
             invalid.extend(["host", "hostgroup"])
-        for x in invalid:
-            if vars()[x] is not None:
-                ansible_module.fail_json(
-                    msg="Argument '%s' can not be used with state '%s'" %
-                    (x, state))
+
+    ansible_module.params_fail_used_invalid(invalid, state, action)
 
     # Init
 
diff --git a/plugins/modules/ipalocation.py b/plugins/modules/ipalocation.py
index 7f10b94459fa0d0171eaf669fc1a2e37f6ac6d4e..9b017cd03cbb0b2b0cc5dc6328cc8acb9c6f9211 100644
--- a/plugins/modules/ipalocation.py
+++ b/plugins/modules/ipalocation.py
@@ -116,7 +116,7 @@ def main():
     state = ansible_module.params_get("state")
 
     # Check parameters
-
+    invalid = []
     if state == "present":
         if len(names) != 1:
             ansible_module.fail_json(
@@ -126,11 +126,8 @@ def main():
         if len(names) < 1:
             ansible_module.fail_json(msg="No name given.")
         invalid = ["description"]
-        for x in invalid:
-            if vars()[x] is not None:
-                ansible_module.fail_json(
-                    msg="Argument '%s' can not be used with state '%s'" %
-                    (x, state))
+
+    ansible_module.params_fail_used_invalid(invalid, state)
 
     # Init
 
diff --git a/plugins/modules/ipapermission.py b/plugins/modules/ipapermission.py
index 657d934ff7ff1f8f922c806e8f5aed7d77a79273..b10161336428a65cfb328ca35a6b4857d49eef8c 100644
--- a/plugins/modules/ipapermission.py
+++ b/plugins/modules/ipapermission.py
@@ -304,11 +304,7 @@ def main():
             invalid += ["right", "attrs", "memberof",
                         "extra_target_filter", "rawfilter"]
 
-    for x in invalid:
-        if vars()[x] is not None:
-            ansible_module.fail_json(
-                msg="Argument '%s' can not be used with action "
-                "'%s' and state '%s'" % (x, action, state))
+    ansible_module.params_fail_used_invalid(invalid, state, action)
 
     if bindtype == "self" and ansible_module.ipa_check_version("<", "4.8.7"):
         ansible_module.fail_json(
diff --git a/plugins/modules/ipaprivilege.py b/plugins/modules/ipaprivilege.py
index 7b32468fd8af5c5ce1f271ea93d96835d07b41c0..82d65c362f32df46f3409a8bf6065f3c73873db3 100644
--- a/plugins/modules/ipaprivilege.py
+++ b/plugins/modules/ipaprivilege.py
@@ -205,11 +205,7 @@ def main():
                 msg="Action '%s' can not be used with state '%s'"
                     % (action, state))
 
-    for x in invalid:
-        if vars()[x] is not None:
-            ansible_module.fail_json(
-                msg="Argument '%s' can not be used with action "
-                "'%s' and state '%s'" % (x, action, state))
+    ansible_module.params_fail_used_invalid(invalid, state, action)
 
     # Init
 
diff --git a/plugins/modules/ipapwpolicy.py b/plugins/modules/ipapwpolicy.py
index 55bedd072d648a59666b5671f906005b6060daa5..6f1fd06c82c215c0ee9b8baca9bd3f1fcaac0928 100644
--- a/plugins/modules/ipapwpolicy.py
+++ b/plugins/modules/ipapwpolicy.py
@@ -210,6 +210,7 @@ def main():
     state = ansible_module.params_get("state")
 
     # Check parameters
+    invalid = []
 
     if names is None:
         names = [u"global_policy"]
@@ -228,11 +229,8 @@ def main():
         invalid = ["maxlife", "minlife", "history", "minclasses",
                    "minlength", "priority", "maxfail", "failinterval",
                    "lockouttime"]
-        for x in invalid:
-            if vars()[x] is not None:
-                ansible_module.fail_json(
-                    msg="Argument '%s' can not be used with state '%s'" %
-                    (x, state))
+
+    ansible_module.params_fail_used_invalid(invalid, state)
 
     # Init
 
diff --git a/plugins/modules/iparole.py b/plugins/modules/iparole.py
index 55b1e1e32bee742a0940c6edc56546c0167afef4..63d674fd59afeea1346de39a3e847c57ca217414 100644
--- a/plugins/modules/iparole.py
+++ b/plugins/modules/iparole.py
@@ -151,11 +151,7 @@ def check_parameters(module):
         if action != "member":
             invalid.extend(['privilege'])
 
-    for arg in invalid:
-        if module.params_get(arg) is not None:
-            module.fail_json(
-                msg="Argument '%s' can not be used with action '%s'" %
-                (arg, state))
+    module.params_fail_used_invalid(invalid, state, action)
 
 
 def member_intersect(module, attr, memberof, res_find):
diff --git a/plugins/modules/ipaselfservice.py b/plugins/modules/ipaselfservice.py
index 53bd5b3b6a626763f183c173cc7945395decce41..7bd26aff52142080323be644e41474126b4c1750 100644
--- a/plugins/modules/ipaselfservice.py
+++ b/plugins/modules/ipaselfservice.py
@@ -158,6 +158,7 @@ def main():
     state = ansible_module.params_get("state")
 
     # Check parameters
+    invalid = []
 
     if state == "present":
         if len(names) != 1:
@@ -165,11 +166,6 @@ def main():
                 msg="Only one selfservice be added at a time.")
         if action == "member":
             invalid = ["permission"]
-            for x in invalid:
-                if vars()[x] is not None:
-                    ansible_module.fail_json(
-                        msg="Argument '%s' can not be used with action "
-                        "'%s' and state '%s'" % (x, action, state))
 
     if state == "absent":
         if len(names) < 1:
@@ -177,11 +173,8 @@ def main():
         invalid = ["permission"]
         if action == "selfservice":
             invalid.append("attribute")
-        for x in invalid:
-            if vars()[x] is not None:
-                ansible_module.fail_json(
-                    msg="Argument '%s' can not be used with action "
-                    "'%s' and state '%s'" % (x, action, state))
+
+    ansible_module.params_fail_used_invalid(invalid, state, action)
 
     if permission is not None:
         perm = [p for p in permission if p not in ("read", "write")]
diff --git a/plugins/modules/ipaserver.py b/plugins/modules/ipaserver.py
index 38e219f4f01c034d102fd4371fe094837ec5f544..ac52ca18d8e4ae5567fe60be134c409a9479cc99 100644
--- a/plugins/modules/ipaserver.py
+++ b/plugins/modules/ipaserver.py
@@ -313,11 +313,7 @@ def main():
             ansible_module.fail_json(msg="No name given.")
         invalid = ["location", "service_weight", "hidden", "no_members"]
 
-    for x in invalid:
-        if vars()[x] is not None:
-            ansible_module.fail_json(
-                msg="Argument '%s' can not be used with state '%s'" %
-                (x, state))
+    ansible_module.params_fail_used_invalid(invalid, state)
 
     # Init
 
diff --git a/plugins/modules/ipaservice.py b/plugins/modules/ipaservice.py
index 29ef992bb808ccc9283b6e0e42ec3575ebf4dc7b..b69a95cb75b357d9af8aaf3d8c20961d4984b5b8 100644
--- a/plugins/modules/ipaservice.py
+++ b/plugins/modules/ipaservice.py
@@ -335,11 +335,7 @@ def check_parameters(module, state, action, names, parameters):
     else:
         module.fail_json(msg="Invalid state '%s'" % (state))
 
-    for _invalid in invalid:
-        if _invalid in parameters and parameters[_invalid] is not None:
-            module.fail_json(
-                msg="Argument '%s' can not be used with state '%s', "
-                "action '%s'" % (_invalid, state, action))
+    module.params_fail_used_invalid(invalid, state, action)
 
 
 def init_ansible_module():
diff --git a/plugins/modules/ipasudocmd.py b/plugins/modules/ipasudocmd.py
index 20548ecfbca0da5dfd3a8eada8c7a8694d848a67..614f45b41ff53dcff7b06f9bf51fc358cfce0ad5 100644
--- a/plugins/modules/ipasudocmd.py
+++ b/plugins/modules/ipasudocmd.py
@@ -124,13 +124,11 @@ def main():
     state = ansible_module.params_get("state")
 
     # Check parameters
+    invalid = []
     if state == "absent":
         invalid = ["description"]
-        for x in invalid:
-            if vars()[x] is not None:
-                ansible_module.fail_json(
-                    msg="Argument '%s' can not be used with state '%s'" %
-                    (x, state))
+
+    ansible_module.params_fail_used_invalid(invalid, state)
 
     # Init
 
diff --git a/plugins/modules/ipasudocmdgroup.py b/plugins/modules/ipasudocmdgroup.py
index e260b699a055b3443ed580790f27f735fdf186f8..42f29fb87035a4f4c494235cbe6659157121a02a 100644
--- a/plugins/modules/ipasudocmdgroup.py
+++ b/plugins/modules/ipasudocmdgroup.py
@@ -168,6 +168,7 @@ def main():
     state = ansible_module.params_get("state")
 
     # Check parameters
+    invalid = []
 
     if state == "present":
         if len(names) != 1:
@@ -175,11 +176,6 @@ def main():
                 msg="Only one sudocmdgroup can be added at a time.")
         if action == "member":
             invalid = ["description", "nomembers"]
-            for x in invalid:
-                if vars()[x] is not None:
-                    ansible_module.fail_json(
-                        msg="Argument '%s' can not be used with action "
-                        "'%s'" % (x, action))
 
     if state == "absent":
         if len(names) < 1:
@@ -188,11 +184,8 @@ def main():
         invalid = ["description", "nomembers"]
         if action == "sudocmdgroup":
             invalid.extend(["sudocmd"])
-        for x in invalid:
-            if vars()[x] is not None:
-                ansible_module.fail_json(
-                    msg="Argument '%s' can not be used with state '%s'" %
-                    (x, state))
+
+    ansible_module.params_fail_used_invalid(invalid, state, action)
 
     # Init
 
diff --git a/plugins/modules/ipasudorule.py b/plugins/modules/ipasudorule.py
index a149c75ceb12eb1db2d9b254e766033550a0373a..8d72d893ba4934395b3dad742347186caeb66da2 100644
--- a/plugins/modules/ipasudorule.py
+++ b/plugins/modules/ipasudorule.py
@@ -311,6 +311,7 @@ def main():
     state = ansible_module.params_get("state")
 
     # Check parameters
+    invalid = []
 
     if state == "present":
         if len(names) != 1:
@@ -321,11 +322,6 @@ def main():
                        "cmdcategory", "runasusercategory",
                        "runasgroupcategory", "order", "nomembers"]
 
-            for arg in invalid:
-                if arg in vars() and vars()[arg] is not None:
-                    ansible_module.fail_json(
-                        msg="Argument '%s' can not be used with action "
-                        "'%s'" % (arg, action))
         else:
             if hostcategory == 'all' and any([host, hostgroup]):
                 ansible_module.fail_json(
@@ -349,11 +345,6 @@ def main():
                             "runasuser", "runasgroup", "allow_sudocmd",
                             "allow_sudocmdgroup", "deny_sudocmd",
                             "deny_sudocmdgroup", "sudooption"])
-        for arg in invalid:
-            if vars()[arg] is not None:
-                ansible_module.fail_json(
-                    msg="Argument '%s' can not be used with state '%s'" %
-                    (arg, state))
 
     elif state in ["enabled", "disabled"]:
         if len(names) < 1:
@@ -368,14 +359,11 @@ def main():
                    "user", "group", "allow_sudocmd", "allow_sudocmdgroup",
                    "deny_sudocmd", "deny_sudocmdgroup", "runasuser",
                    "runasgroup", "order", "sudooption"]
-        for arg in invalid:
-            if vars()[arg] is not None:
-                ansible_module.fail_json(
-                    msg="Argument '%s' can not be used with state '%s'" %
-                    (arg, state))
     else:
         ansible_module.fail_json(msg="Invalid state '%s'" % state)
 
+    ansible_module.params_fail_used_invalid(invalid, state, action)
+
     # Init
 
     changed = False
diff --git a/plugins/modules/ipauser.py b/plugins/modules/ipauser.py
index 1ffee44806bee7ea14bb962323dfeea7812955f4..f88e8d8fc7fb971f057250af391469d5ee56291d 100644
--- a/plugins/modules/ipauser.py
+++ b/plugins/modules/ipauser.py
@@ -597,6 +597,7 @@ def check_parameters(  # pylint: disable=unused-argument
         userauthtype, userclass, radius, radiususer, departmentnumber,
         employeenumber, employeetype, preferredlanguage, certificate,
         certmapdata, noprivate, nomembers, preserve, update_password):
+    invalid = []
     if state == "present":
         if action == "member":
             invalid = ["first", "last", "fullname", "displayname", "initials",
@@ -608,11 +609,6 @@ def check_parameters(  # pylint: disable=unused-argument
                        "departmentnumber", "employeenumber", "employeetype",
                        "preferredlanguage", "noprivate", "nomembers",
                        "preserve", "update_password"]
-            for x in invalid:
-                if vars()[x] is not None:
-                    module.fail_json(
-                        msg="Argument '%s' can not be used with action "
-                        "'%s'" % (x, action))
 
     else:
         invalid = ["first", "last", "fullname", "displayname", "initials",
@@ -628,16 +624,13 @@ def check_parameters(  # pylint: disable=unused-argument
             invalid.extend(["principal", "manager",
                             "certificate", "certmapdata",
                             ])
-        for x in invalid:
-            if vars()[x] is not None:
-                module.fail_json(
-                    msg="Argument '%s' can not be used with state '%s'" %
-                    (x, state))
 
         if state != "absent" and preserve is not None:
             module.fail_json(
                 msg="Preserve is only possible for state=absent")
 
+    module.params_fail_used_invalid(invalid, state, action)
+
     if certmapdata is not None:
         for x in certmapdata:
             certificate = x.get("certificate")
diff --git a/plugins/modules/ipavault.py b/plugins/modules/ipavault.py
index abd5eddffd25ff0b4838bc957217bf02377e0242..0274b705fb9df4a010cc2ba41010511586740593 100644
--- a/plugins/modules/ipavault.py
+++ b/plugins/modules/ipavault.py
@@ -483,11 +483,7 @@ def check_parameters(  # pylint: disable=unused-argument
             module.fail_json(
                 msg="State `retrieved` do not support action `member`.")
 
-    for arg in invalid:
-        if vars()[arg] is not None:
-            module.fail_json(
-                msg="Argument '%s' can not be used with state '%s', "
-                    "action '%s'" % (arg, state, action))
+    module.params_fail_used_invalid(invalid, state, action)
 
 
 def check_encryption_params(  # pylint: disable=unused-argument