diff --git a/utils/templates/ipamodule+member.py.in b/utils/templates/ipamodule+member.py.in
index 7e7ad8ea18b1bc90cc1d49e0d3834881870364a2..d3438b1b4cc224e16420cdeb35cf437044fe72de 100644
--- a/utils/templates/ipamodule+member.py.in
+++ b/utils/templates/ipamodule+member.py.in
@@ -185,11 +185,7 @@ def main():
         if action == "$name":
             invalid.append("PARAMETER2")
 
-    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/utils/templates/ipamodule.py.in b/utils/templates/ipamodule.py.in
index b179a0b8f66ac8fb78a5cbd5a814b90b3e91c757..e305c9765d6f404c4956811986759d91f48f2703 100644
--- a/utils/templates/ipamodule.py.in
+++ b/utils/templates/ipamodule.py.in
@@ -151,11 +151,7 @@ def main():
             ansible_module.fail_json(msg="No name given.")
         invalid = ["PARAMETER1", "PARAMETER2"]
 
-    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