-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Open
Labels
Debian 12kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.
Description
What happened?
Several Ansible tasks that invoke kubectl apply are currently marked as changed on every execution, even when the applied Kubernetes resources are already in the desired state. This breaks idempotency expectations and causes noisy or misleading change reporting.
What did you expect to happen?
The task should only be marked as changed when Kubernetes resources are actually:
- created
- configured (modified)
and not when:
- unchanged
Proposed improvement:
Using kubectl diff
- name: Check manifest drift
command: kubectl diff -f manifests.yaml
register: kubectl_diff
failed_when: kubectl_diff.rc > 1
changed_when: false
- name: Apply manifests when drift detected
command: kubectl apply -f manifests.yaml
when: kubectl_diff.rc == 1Using kubectl apply status
- name: Apply manifests like before
command: kubectl apply -f manifests.yaml
register: kubectl_apply
changed_when: "' created' in kubectl_apply.stdout or ' configured' in kubectl_apply.stdout"Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Debian 12kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.