From cdc9e6b3418dd8a441c6127f41046193e3f4601d Mon Sep 17 00:00:00 2001 From: Seena Fallah Date: Fri, 15 Mar 2024 21:51:29 +0100 Subject: [PATCH] ceph_config: add support config remove Add support rm action. Signed-off-by: Seena Fallah (cherry picked from commit fa2eb2532e1f4b8d4a9ea9280ffa9ad3d1cf2a0e) --- library/ceph_config.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/library/ceph_config.py b/library/ceph_config.py index 1bd1d7387..3557b34da 100644 --- a/library/ceph_config.py +++ b/library/ceph_config.py @@ -103,6 +103,24 @@ def set_option(module, return rc, cmd, out.strip(), err +def rm_option(module, + who, + option, + container_image=None): + + args = [] + args.extend([who, option]) + + cmd = generate_cmd(sub_cmd=['config', 'rm'], + args=args, + cluster=module.params.get('cluster'), + container_image=container_image) + + rc, out, err = module.run_command(cmd) + + return rc, cmd, out.strip(), err + + def get_config_dump(module, container_image=None): cmd = generate_cmd(sub_cmd=['config', 'dump', '--format', 'json'], args=[], @@ -126,7 +144,7 @@ def main() -> None: module = AnsibleModule( argument_spec=dict( who=dict(type='str', required=True), - action=dict(type='str', required=False, choices=['get', 'set'], default='set'), + action=dict(type='str', required=False, choices=['get', 'set', 'rm'], default='set'), option=dict(type='str', required=True), value=dict(type='str', required=False), fsid=dict(type='str', required=False), @@ -170,12 +188,16 @@ def main() -> None: else: rc, cmd, out, err = set_option(module, who, option, value, container_image=container_image) changed = True - else: + elif action == 'get': if current_value is None: out = '' err = 'No value found for who={} option={}'.format(who, option) else: out = current_value + elif action == 'rm': + if current_value: + rc, cmd, out, err = rm_option(module, who, option, container_image=container_image) + changed = True exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd,