Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ceph_orch_apply: fix idempotency (backport #297) #299

Merged
merged 1 commit into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion library/ceph_orch_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,21 @@ def apply_spec(module: "AnsibleModule",
return rc, cmd, out, err


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 run_module() -> None:

module_args = dict(
Expand Down Expand Up @@ -137,7 +152,7 @@ def run_module() -> None:
expected = parse_spec(module.params.get('spec'))
current_spec = retrieve_current_spec(module, expected)

if not current_spec or current_spec != expected:
if change_required(current_spec, expected):
rc, cmd, out, err = apply_spec(module, spec)
changed = True
else:
Expand Down
Loading