From 99bcf1841082bb34db9da0899147325cc37f8973 Mon Sep 17 00:00:00 2001 From: Alexander Gubin Date: Wed, 26 Nov 2014 11:27:29 +0100 Subject: [PATCH] Fix lvol: Find LVM commands in PATH env --- lib/ansible/modules/extras/system/lvol.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/ansible/modules/extras/system/lvol.py b/lib/ansible/modules/extras/system/lvol.py index 96f1b846e27..e9d477edf86 100644 --- a/lib/ansible/modules/extras/system/lvol.py +++ b/lib/ansible/modules/extras/system/lvol.py @@ -152,8 +152,9 @@ def main(): else: unit = size_unit + lvs_cmd = module.get_bin_path("lvs", required=True) rc, current_lvs, err = module.run_command( - "lvs --noheadings -o lv_name,size --units %s --separator ';' %s" % (unit, vg)) + "%s --noheadings -o lv_name,size --units %s --separator ';' %s" % (lvs_cmd, unit, vg)) if rc != 0: if state == 'absent': @@ -185,7 +186,8 @@ def main(): if module.check_mode: changed = True else: - rc, _, err = module.run_command("lvcreate -n %s -%s %s%s %s" % (lv, size_opt, size, size_unit, vg)) + lvcreate_cmd = module.get_bin_path("lvcreate", required=True) + rc, _, err = module.run_command("%s -n %s -%s %s%s %s" % (lvcreate_cmd, lv, size_opt, size, size_unit, vg)) if rc == 0: changed = True else: @@ -197,7 +199,8 @@ def main(): module.exit_json(changed=True) if not force: module.fail_json(msg="Sorry, no removal of logical volume %s without force=yes." % (this_lv['name'])) - rc, _, err = module.run_command("lvremove --force %s/%s" % (vg, this_lv['name'])) + lvremove_cmd = module.get_bin_path("lvremove", required=True) + rc, _, err = module.run_command("%s --force %s/%s" % (lvremove_cmd, vg, this_lv['name'])) if rc == 0: module.exit_json(changed=True) else: @@ -209,11 +212,12 @@ def main(): ### resize LV tool = None if size > this_lv['size']: - tool = 'lvextend' + tool = module.get_bin_path("lvextend", required=True) elif size < this_lv['size']: if not force: module.fail_json(msg="Sorry, no shrinking of %s without force=yes." % (this_lv['name'])) - tool = 'lvreduce --force' + tool = module.get_bin_path("lvextend", required=True) + tool.append("--force") if tool: if module.check_mode: