From b476b2f665e8541ae7de3dbc2b2ae493a3c4eefe Mon Sep 17 00:00:00 2001 From: Heinrich Langos Date: Thu, 30 Oct 2025 16:55:02 +0100 Subject: [PATCH 1/4] Fix(zpool): Ensure consistent device path normalization for idempotency This fix resolves an idempotency failure that occurs when defining zpool vdevs using canonical device IDs (e.g., /dev/disk/by-id/...). The underlying issue was two-fold: 1. The base_device parsing logic was insufficient to strip partition suffixes (-partN) from these specific canonical paths. 2. The concurrent use of the 'real_paths=True' flag in zpool status output complicated path comparison. This patch implements the solution by: a) Enhancing the base_device function to correctly normalize /dev/disk/by-id/ paths. b) Removing the redundant 'real_paths=True' flag to stabilize path reporting. This solution was developed and implemented entirely by the Author of this commit. Signed-off-by: Ivan Skachko --- plugins/modules/zpool.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/modules/zpool.py b/plugins/modules/zpool.py index e83fa97927c..05fb0b68791 100644 --- a/plugins/modules/zpool.py +++ b/plugins/modules/zpool.py @@ -309,12 +309,17 @@ def base_device(self, device): match = re.match(r'^(/dev/(?:sd|vd)[a-z])\d+$', device) if match: return match.group(1) + + # disk/by-id drives + match = re.match(r'^(/dev/disk/by-id/(.*))-part\d+$', device) + if match: + return match.group(1) return device def get_current_layout(self): - with self.zpool_runner('subcommand full_paths real_paths name', check_rc=True) as ctx: - rc, stdout, stderr = ctx.run(subcommand='status', full_paths=True, real_paths=True) + with self.zpool_runner('subcommand full_paths name', check_rc=True) as ctx: + rc, stdout, stderr = ctx.run(subcommand='status', full_paths=True) vdevs = [] current = None @@ -433,8 +438,8 @@ def add_vdevs(self): return {'prepared': stdout} def list_vdevs_with_names(self): - with self.zpool_runner('subcommand full_paths real_paths name', check_rc=True) as ctx: - rc, stdout, stderr = ctx.run(subcommand='status', full_paths=True, real_paths=True) + with self.zpool_runner('subcommand full_paths name', check_rc=True) as ctx: + rc, stdout, stderr = ctx.run(subcommand='status', full_paths=True) in_cfg = False saw_pool = False vdevs = [] From 5ad795db4cceb25707224bf388e68be8da17b6a0 Mon Sep 17 00:00:00 2001 From: Ivan Skachko Date: Fri, 31 Oct 2025 09:35:29 +0100 Subject: [PATCH 2/4] Add changelog fragment for PR 11020 --- changelogs/fragments/11020-zpool-device-path-idempotency.yaml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/11020-zpool-device-path-idempotency.yaml diff --git a/changelogs/fragments/11020-zpool-device-path-idempotency.yaml b/changelogs/fragments/11020-zpool-device-path-idempotency.yaml new file mode 100644 index 00000000000..5b234a35ee9 --- /dev/null +++ b/changelogs/fragments/11020-zpool-device-path-idempotency.yaml @@ -0,0 +1,2 @@ +bugfixes: + - zpool - idempotency failed when canonical device IDs were used; the fix now ensures consistent device path normalization (https://github.com/ansible-collections/community.general/pull/11020). \ No newline at end of file From 72afd38f86c6b11c3ad53dcad329eec65129c9fd Mon Sep 17 00:00:00 2001 From: Ivan Skachko Date: Fri, 31 Oct 2025 23:26:40 +0100 Subject: [PATCH 3/4] Remove trailing space from the new line --- plugins/modules/zpool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/zpool.py b/plugins/modules/zpool.py index 05fb0b68791..76bc5e8a7f3 100644 --- a/plugins/modules/zpool.py +++ b/plugins/modules/zpool.py @@ -309,7 +309,7 @@ def base_device(self, device): match = re.match(r'^(/dev/(?:sd|vd)[a-z])\d+$', device) if match: return match.group(1) - + # disk/by-id drives match = re.match(r'^(/dev/disk/by-id/(.*))-part\d+$', device) if match: From ed52c1ffa8e4a5d81c418bf9c8cc5a3563fd70a8 Mon Sep 17 00:00:00 2001 From: puffymob Date: Sat, 1 Nov 2025 10:53:10 +0100 Subject: [PATCH 4/4] Update changelogs/fragments/11020-zpool-device-path-idempotency.yaml Co-authored-by: Felix Fontein --- changelogs/fragments/11020-zpool-device-path-idempotency.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/11020-zpool-device-path-idempotency.yaml b/changelogs/fragments/11020-zpool-device-path-idempotency.yaml index 5b234a35ee9..24f3906cd05 100644 --- a/changelogs/fragments/11020-zpool-device-path-idempotency.yaml +++ b/changelogs/fragments/11020-zpool-device-path-idempotency.yaml @@ -1,2 +1,2 @@ bugfixes: - - zpool - idempotency failed when canonical device IDs were used; the fix now ensures consistent device path normalization (https://github.com/ansible-collections/community.general/pull/11020). \ No newline at end of file + - zpool - idempotency failed when canonical device IDs were used; the fix now ensures consistent device path normalization (https://github.com/ansible-collections/community.general/issues/10771, https://github.com/ansible-collections/community.general/issues/10744, https://github.com/ansible-collections/community.general/pull/11020). \ No newline at end of file