diff --git a/changelogs/fragments/1833-zfs-creation-only-properties.yaml b/changelogs/fragments/1833-zfs-creation-only-properties.yaml new file mode 100644 index 0000000000..deb972a6d2 --- /dev/null +++ b/changelogs/fragments/1833-zfs-creation-only-properties.yaml @@ -0,0 +1,2 @@ +bugfixes: + - zfs - some ZFS properties could be passed when the dataset/volume did not exist, but would fail if the dataset already existed, even if the property matched what was specified in the ansible task (https://github.com/ansible-collections/community.general/issues/868, https://github.com/ansible-collections/community.general/pull/1833). diff --git a/plugins/modules/storage/zfs/zfs.py b/plugins/modules/storage/zfs/zfs.py index 8013dd1128..fe693a5045 100644 --- a/plugins/modules/storage/zfs/zfs.py +++ b/plugins/modules/storage/zfs/zfs.py @@ -203,7 +203,10 @@ class Zfs(object): rc, out, err = self.module.run_command(" ".join(cmd)) properties = dict() for prop, value, source in [l.split('\t')[1:4] for l in out.splitlines()]: - if source == 'local': + # include source '-' so that creation-only properties are not removed + # to avoids errors when the dataset already exists and the property is not changed + # this scenario is most likely when the same playbook is run more than once + if source == 'local' or source == '-': properties[prop] = value # Add alias for enhanced sharing properties if self.enhanced_sharing: