]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
ceph_pool: add idempotency to absent state
authorDimitri Savineau <dsavinea@redhat.com>
Thu, 3 Sep 2020 17:11:31 +0000 (13:11 -0400)
committerDimitri Savineau <savineau.dimitri@gmail.com>
Fri, 25 Sep 2020 17:55:20 +0000 (13:55 -0400)
When using the "absent" state on a non existing pool then the ceph_pool
module will fail and return a python traceback.

Instead we should check if the pool exit or not and execute the pool
deletion according to the result.
The state changed is now set when the pool is actually deleted.

This also disable add_file_common_args because we don't manipulate
files with this module.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
(cherry picked from commit 047a3e2653eccf37b71366a8fb414c17a8163508)

library/ceph_pool.py

index 77cbf280d18f539eaa5bb3c22ae01b5caffcd173..8da6b2a98a07c0e1f0e73a3e8d5837239180bdad 100644 (file)
@@ -475,7 +475,6 @@ def run_module():
     module = AnsibleModule(
         argument_spec=module_args,
         supports_check_mode=True,
-        add_file_common_args=True,
     )
 
     # Gather module parameters in variables
@@ -597,7 +596,13 @@ def run_module():
             out = "Couldn't list pool(s) present on the cluster"
 
     elif state == "absent":
-        rc, cmd, out, err = exec_commands(module, remove_pool(cluster, name, user, user_key, container_image=container_image))
+        rc, cmd, out, err = exec_commands(module, check_pool_exist(cluster, name, user, user_key, container_image=container_image))
+        if rc == 0:
+            rc, cmd, out, err = exec_commands(module, remove_pool(cluster, name, user, user_key, container_image=container_image))
+            changed = True
+        else:
+            rc = 0
+            out = "Skipped, since pool {} doesn't exist".format(name)
 
 
     exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed)