]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
ceph-volume: add support check mode
authorSeena Fallah <seenafallah@gmail.com>
Thu, 14 Mar 2024 17:31:05 +0000 (18:31 +0100)
committerGuillaume Abrioux <gabrioux@ibm.com>
Sat, 16 Mar 2024 19:25:49 +0000 (20:25 +0100)
Run read-only actions on check mode

Signed-off-by: Seena Fallah <seenafallah@gmail.com>
(cherry picked from commit b60e0134a5d461fcbcfa5471992487ad88876d2e)

library/ceph_volume.py

index 8882e3bc03bbdad57f5b3ff39ade2aa938418cf8..ffa89986b7fcfb61cd48dbe8bec8d98ed8fb8e69 100644 (file)
@@ -476,6 +476,23 @@ def zap_devices(module, container_image):
     return cmd
 
 
+def allowed_in_check_mode(module):
+    '''
+    Check if the action is allowed in check mode
+    '''
+
+    action = module.params['action']
+    report = module.params.get('report', False)
+
+    # batch is allowed in check mode if report is set
+    if action == 'batch' and report:
+        return True
+
+    allowed_actions = ['list', 'inventory']
+
+    return action in allowed_actions
+
+
 def run_module():
     module_args = dict(
         cluster=dict(type='str', required=False, default='ceph'),
@@ -524,7 +541,7 @@ def run_module():
         delta='',
     )
 
-    if module.check_mode:
+    if module.check_mode and not allowed_in_check_mode(module):
         module.exit_json(**result)
 
     # start execution