mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-02 19:32:47 +00:00
lvg: don't fail if an unknown physical device is encountered (#38446)
Physical devices are listed using 'pvs' command. Then, for
'/dev/dm-*' devices 'dmsetup' command is used to find pv_name.
An error occurs when 'pvs' command list an unknown device:
$ pvs --noheadings -o pv_name,vg_name --separator ';'
/dev/dm-0;vg_var
/dev/mapper/sdb3_backups;vg_data_backups
$ dmsetup info -C --noheadings -o name /dev/dm-0
Device dm-0 not found
Then the module fails:
{
"changed": false,
"err": "Device dm-0 not found\nCommand failed\n",
"msg": "Failed executing dmsetup command.",
"rc": 1
}
This failure can be avoided when the unknown device isn't used in
module parameter 'pvs'.
This commit is contained in:
@@ -158,7 +158,12 @@ def main():
|
||||
|
||||
# get pv list
|
||||
pvs_cmd = module.get_bin_path('pvs', True)
|
||||
rc, current_pvs, err = module.run_command("%s --noheadings -o pv_name,vg_name --separator ';'" % pvs_cmd)
|
||||
if dev_list:
|
||||
pvs_filter = ' || '. join(['pv_name = {0}'.format(x) for x in dev_list])
|
||||
pvs_filter = "--select '%s'" % pvs_filter
|
||||
else:
|
||||
pvs_filter = ''
|
||||
rc, current_pvs, err = module.run_command("%s --noheadings -o pv_name,vg_name --separator ';' %s" % (pvs_cmd, pvs_filter))
|
||||
if rc != 0:
|
||||
module.fail_json(msg="Failed executing pvs command.", rc=rc, err=err)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user