diff --git a/utils/templates/ipamodule+member.py.in b/utils/templates/ipamodule+member.py.in
index daa7fdd49b3d8a51658ed129a49df236c8b16781..714c0d7eb11ec6ebb42e30bf09ae1017ae0ae5c7 100644
--- a/utils/templates/ipamodule+member.py.in
+++ b/utils/templates/ipamodule+member.py.in
@@ -113,7 +113,7 @@ RETURN = """
 
 from ansible.module_utils.ansible_freeipa_module import \
     IPAAnsibleModule, compare_args_ipa, gen_add_del_lists, gen_add_list, \
-    gen_intersection_list
+    gen_intersection_list, ipalib_errors
 from ansible.module_utils import six
 
 if six.PY3:
@@ -124,7 +124,7 @@ def find_$name(module, name):
     """Find if a $name with the given name already exist."""
     try:
         _result = module.ipa_command("$name_show", name, {"all": True})
-    except Exception:  # pylint: disable=broad-except
+    except ipalib_errors.NotFound:
         # An exception is raised if $name name is not found.
         return None
     return _result["result"]
diff --git a/utils/templates/ipamodule.py.in b/utils/templates/ipamodule.py.in
index 0dc282dd6baf66fde262844d25b37b029c11e278..afb119a8a8cf553c576664090230fcee8abb145e 100644
--- a/utils/templates/ipamodule.py.in
+++ b/utils/templates/ipamodule.py.in
@@ -89,7 +89,7 @@ RETURN = """
 
 
 from ansible.module_utils.ansible_freeipa_module import \
-    IPAAnsibleModule, compare_args_ipa
+    IPAAnsibleModule, compare_args_ipa, ipalib_errors
 from ansible.module_utils import six
 
 if six.PY3:
@@ -100,7 +100,7 @@ def find_$name(module, name):
     """Find if a $name with the given name already exist."""
     try:
         _result = module.ipa_command("$name_show", name, {"all": True})
-    except Exception:  # pylint: disable=broad-except
+    except ipalib_errors.NotFound:
         # An exception is raised if $name name is not found.
         return None
     return _result["result"]