1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-02-04 07:51:50 +00:00

[PR #11172/ebcad7e6 backport][stable-12] zfs: mark change correctly when updating properties whose current value differs, even if they already have a non-default value (Fixes #11019) (#11234)

zfs: mark change correctly when updating properties whose current value differs, even if they already have a non-default value (Fixes #11019) (#11172)

* zfs - mark change correctly when updating properties whose current value differs, even if they already have a non-default value (https://github.com/ansible-collections/community.general/issues/11019).



* changelog: rename fragment to match PR number



* Update changelogs/fragments/11172-zfs-changed-extra-props.yml



---------



(cherry picked from commit ebcad7e6d1)

Signed-off-by: handisyde <github@handisyde.com>
Co-authored-by: Paul Mercier-Handisyde <33284285+handisyde@users.noreply.github.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
patchback[bot] 2025-11-30 15:03:32 +01:00 committed by GitHub
parent fb00ba1b0a
commit 3d42ad4c6c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,3 @@
---
bugfixes:
- zfs - mark change correctly when updating properties whose current value differs, even if they already have a non-default value (https://github.com/ansible-collections/community.general/issues/11019, https://github.com/ansible-collections/community.general/pull/11172).

View file

@ -185,9 +185,11 @@ class Zfs:
def set_properties_if_changed(self):
diff = {"before": {"extra_zfs_properties": {}}, "after": {"extra_zfs_properties": {}}}
current_properties = self.list_properties()
previous_values = {}
for prop, value in self.extra_zfs_properties.items():
current_value = self.get_property(prop, current_properties)
if current_value != value:
previous_values[prop] = current_value
self.set_property(prop, value)
diff["before"]["extra_zfs_properties"][prop] = current_value
diff["after"]["extra_zfs_properties"][prop] = value
@ -198,7 +200,7 @@ class Zfs:
value = self.get_property(prop, updated_properties)
if value is None:
self.module.fail_json(msg=f"zfsprop was not present after being successfully set: {prop}")
if self.get_property(prop, current_properties) != value:
if prop in previous_values and previous_values[prop] != value:
self.changed = True
if prop in diff["after"]["extra_zfs_properties"]:
diff["after"]["extra_zfs_properties"][prop] = value