From 4df2cab42a40e0663d2cfdab297117e96d78e49a Mon Sep 17 00:00:00 2001
From: Rafael Guterres Jeffman <rjeffman@redhat.com>
Date: Thu, 17 Feb 2022 15:22:18 -0300
Subject: [PATCH] module templates: Add delete_commit code template.

This patch add the lines necessary to allow the use of the attribute
`delete_continue`, as it is a commom attribute, and if newer commom
attributes are added to IPAAnsibleModule in the future, the usage will
be similar.
---
 utils/templates/ipamodule+member.py.in | 10 +++++++++-
 utils/templates/ipamodule.py.in        |  8 +++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/utils/templates/ipamodule+member.py.in b/utils/templates/ipamodule+member.py.in
index 90152502..dc682cf9 100644
--- a/utils/templates/ipamodule+member.py.in
+++ b/utils/templates/ipamodule+member.py.in
@@ -36,6 +36,7 @@ short description: Manage FreeIPA $name
 description: Manage FreeIPA $name and $name members
 extends_documentation_fragment:
   - ipamodule_base_docs
+  - ipamoudle_base_docs.delete_continue
 options:
   name:
     description: The list of $name name strings.
@@ -152,6 +153,7 @@ def main():
                        choices=["present", "absent"]),
         ),
         supports_check_mode=True,
+        ipa_module_options=["delete_continue"]
     )
 
     ansible_module._ansible_debug = True
@@ -169,6 +171,8 @@ def main():
     PARAMETER2 = ansible_module.params_get_lowercase("PARAMETER2")
     action = ansible_module.params_get("action")
 
+    delete_continue = ansible_module.params_get("delete_continue")
+
     # state
     state = ansible_module.params_get("state")
 
@@ -249,7 +253,9 @@ def main():
             elif state == "absent":
                 if action == "$name":
                     if res_find is not None:
-                        commands.append([name, "$name_del", {}])
+                        commands.append(
+                            [name, "$name_del", {"continue": delete_continue}]
+                        )
 
                 elif action == "member":
                     if res_find is None:
@@ -275,10 +281,12 @@ def main():
                                  }])
 
             # Remove members
+
             if PARAMETER2_del:
                 commands.append([name, "$name_remove_member",
                                  {
                                      "PARAMETER2": PARAMETER2_del,
+                                     "continue": delete_continue,
                                  }])
 
         # Execute commands
diff --git a/utils/templates/ipamodule.py.in b/utils/templates/ipamodule.py.in
index b66be523..07fe2ac4 100644
--- a/utils/templates/ipamodule.py.in
+++ b/utils/templates/ipamodule.py.in
@@ -36,6 +36,7 @@ short description: Manage FreeIPA $name
 description: Manage FreeIPA $name
 extends_documentation_fragment:
   - ipamodule_base_docs
+  - ipamodule_base_docs.delete_continue
 options:
   name:
     description: The list of $name name strings.
@@ -124,6 +125,7 @@ def main():
                        choices=["present", "absent"]),
         ),
         supports_check_mode=True,
+        ipa_module_options=["delete_continue"],
     )
 
     ansible_module._ansible_debug = True
@@ -140,6 +142,8 @@ def main():
     # these parameters, use IPAAnsibleModule.params_get_lowercase.
     PARAMETER2 = ansible_module.params_get_lowercase("PARAMETER2")
 
+    delete_continue = ansible_module.params_get("delete_continue")
+
     # state
     state = ansible_module.params_get("state")
 
@@ -191,7 +195,9 @@ def main():
 
             elif state == "absent":
                 if res_find is not None:
-                    commands.append([name, "$name_del", {}])
+                    commands.append(
+                        [name, "$name_del", {"continue": delete_continue}]
+                    )
 
             else:
                 ansible_module.fail_json(msg="Unkown state '%s'" % state)
-- 
GitLab