Skip to content

Commit

Permalink
Merge pull request #125 from ceph/mergify/bp/quincy/pr-124
Browse files Browse the repository at this point in the history
ceph_config: get_or_set_option() always does a 'get' (backport #124)
  • Loading branch information
guits authored Jun 15, 2022
2 parents 93e04c2 + 2a3d541 commit 54f7ac0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions library/ceph_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

from ansible.module_utils.basic import AnsibleModule # type: ignore
try:
from ansible.module_utils.ceph_common import exit_module, build_base_cmd_shell # type: ignore
from ansible.module_utils.ceph_common import exit_module, build_base_cmd_shell, fatal # type: ignore
except ImportError:
from module_utils.ceph_common import exit_module, build_base_cmd_shell # type: ignore
from module_utils.ceph_common import exit_module, build_base_cmd_shell, fatal # type: ignore

import datetime

Expand Down Expand Up @@ -90,7 +90,10 @@ def get_or_set_option(module: "AnsibleModule",
option: str,
value: str) -> Tuple[int, List[str], str, str]:
cmd = build_base_cmd_shell(module)
cmd.extend(['ceph', 'config', 'get', who, option])
cmd.extend(['ceph', 'config', action, who, option])

if action == 'set':
cmd.append(value)

rc, out, err = module.run_command(cmd)

Expand Down Expand Up @@ -133,9 +136,11 @@ def main() -> None:
changed = False

rc, cmd, out, err = get_or_set_option(module, 'get', who, option, value)
if rc:
fatal(message=f"Can't get current value. who={who} option={option}", module=module)

if action == 'set':
if value == out:
if value.lower() == out:
out = 'who={} option={} value={} already set. Skipping.'.format(who, option, value)
else:
rc, cmd, out, err = get_or_set_option(module, action, who, option, value)
Expand Down

0 comments on commit 54f7ac0

Please sign in to comment.