From 0333dd0ef5be49a1e774a05e24e1954c730a6cad Mon Sep 17 00:00:00 2001 From: Teoman ONAY Date: Thu, 16 May 2024 10:11:29 +0200 Subject: [PATCH] ceph_orch_apply: code change for clarity Signed-off-by: Teoman ONAY (cherry picked from commit 2d357818a4d7a23e567dcda6f9ce814fa0be577a) --- library/ceph_orch_apply.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/library/ceph_orch_apply.py b/library/ceph_orch_apply.py index a498a57..4848e98 100644 --- a/library/ceph_orch_apply.py +++ b/library/ceph_orch_apply.py @@ -91,21 +91,6 @@ def retrieve_current_spec(module: AnsibleModule, expected_spec: Dict) -> Dict: return yaml.safe_load(out[1]) -def change_required(current: Dict, expected: Dict) -> bool: - """ checks if the current config differs from what is expected """ - if not current: - return True - - for key, value in expected.items(): - if key in current: - if current[key] != value: - return True - continue - else: - return True - return False - - def apply_spec(module: "AnsibleModule", data: str) -> Tuple[int, List[str], str, str]: cmd = build_base_cmd_orch(module) @@ -152,7 +137,7 @@ def run_module() -> None: expected = parse_spec(module.params.get('spec')) current_spec = retrieve_current_spec(module, expected) - if change_required(current_spec, expected): + if not current_spec or current_spec != expected: rc, cmd, out, err = apply_spec(module, spec) changed = True else: