ceph-volume: add support check mode

Run read-only actions on check mode

Signed-off-by: Seena Fallah <seenafallah@gmail.com>
pull/7505/head
Seena Fallah 2024-03-14 18:31:05 +01:00 committed by Guillaume Abrioux
parent 49ec2479ea
commit b60e0134a5
1 changed files with 18 additions and 1 deletions

View File

@ -476,6 +476,23 @@ def zap_devices(module, container_image):
return cmd 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(): def run_module():
module_args = dict( module_args = dict(
cluster=dict(type='str', required=False, default='ceph'), cluster=dict(type='str', required=False, default='ceph'),
@ -524,7 +541,7 @@ def run_module():
delta='', delta='',
) )
if module.check_mode: if module.check_mode and not allowed_in_check_mode(module):
module.exit_json(**result) module.exit_json(**result)
# start execution # start execution