From 14a35eb002650c1f1aa9e82b870bd3a6d5625ca5 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Thu, 25 Oct 2018 17:10:22 +0100 Subject: [PATCH] Fix lvg module idempotency In [1] changes were made to ensure that the physical devices were appropriately filtered, but the dev_list which is used to prepare the filter is modified from the original arguments to resolve any symlinks. This results in the existing devices given in the module args to be left out of the filter, resulting in the module trying to add the same device again every time the task is executed. In this PR we change dev_list to be a copy of the module arguments so that we're able to add the given pv list from the module arguments into the filter as well, ensuring that there is idempotence when running the task again. [1] https://github.com/ansible/ansible/pull/38446 (cherry picked from commit 1bae00b5d26816b3298e2363a5d1c3fe9f945865) --- lib/ansible/modules/system/lvg.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/system/lvg.py b/lib/ansible/modules/system/lvg.py index 8b52e48629e..b4d449ea581 100644 --- a/lib/ansible/modules/system/lvg.py +++ b/lib/ansible/modules/system/lvg.py @@ -150,7 +150,7 @@ def main(): dev_list = [] if module.params['pvs']: - dev_list = module.params['pvs'] + dev_list = list(module.params['pvs']) elif state == 'present': module.fail_json(msg="No physical volumes given.") @@ -167,7 +167,7 @@ def main(): # get pv list pvs_cmd = module.get_bin_path('pvs', True) if dev_list: - pvs_filter = ' || '. join(['pv_name = {0}'.format(x) for x in dev_list]) + pvs_filter = ' || '. join(['pv_name = {0}'.format(x) for x in dev_list + module.params['pvs']]) pvs_filter = "--select '%s'" % pvs_filter else: pvs_filter = ''