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..24f3906cd05 --- /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/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 diff --git a/plugins/modules/zpool.py b/plugins/modules/zpool.py index e83fa97927c..76bc5e8a7f3 100644 --- a/plugins/modules/zpool.py +++ b/plugins/modules/zpool.py @@ -310,11 +310,16 @@ def base_device(self, 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 = []