1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-02-03 23:41:51 +00:00

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).

Signed-off-by: handisyde <github@handisyde.com>

* changelog: rename fragment to match PR number

Signed-off-by: handisyde <github@handisyde.com>

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

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Signed-off-by: handisyde <github@handisyde.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Paul Mercier-Handisyde 2025-11-30 14:51:14 +01:00 committed by GitHub
parent f27839673c
commit ebcad7e6d1
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