mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix lvol: Find LVM commands in PATH env
This commit is contained in:
parent
389c6e7b5e
commit
99bcf18410
1 changed files with 9 additions and 5 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue