Short version: how do you resize/extend a logical volume with ansible?
It includes built-in support for managing both physical volumes and volume groups and logical volumes.
Based on the following info from that second link, I'm assuming it's capable of extending logical volumes:
- "This module creates, removes or resizes logical volumes."
- resizefs: Resize the underlying filesystem together with the logical volume.
Plus, the following example in the documentation:
- name: Extend the logical volume to take all remaining space of the PVs and resize the underlying filesystem
lvol:
vg: firefly
lv: test
size: 100%PVS
resizefs: true
However, my attempts to resize result in failure. I have these vars defined:
lvm_group: vg00
lvm_volumes:
- name: /dev/mapper/vg00-lv_home
size: 5G
and I'm running this task:
- name: configure LVM logical volumes
lvol:
vg: "{{ lvm_group }}"
lv: "{{ item.name }}"
size: "{{ item.size }}"
resizefs: yes
with_items:
"{{ lvm_volumes }}"
Note: I've tried with resizefs set to both yes (as in the documentation) and true (as in the example).
However, I get this failure when running:
failed: [169.198.54.175] (item={u'name': u'/dev/mapper/vg00-lv_home', u'size': u'5G'}) => changed=false
ansible_loop_var: item
err: |2-
Logical Volume "lv_home" already exists in volume group "vg00"
item:
name: /dev/mapper/vg00-lv_home
size: 5G
msg: Creating logical volume '/dev/mapper/vg00-lv_home' failed
rc: 5
Can anyone help me understand what I'm going wrong? Am I missing some other required argument perhaps?
I'm using ansible 2.9.10. Thanks.
Best Answer
I think the Ansible
lvol
module wants just the logical volume name aslv
, but you have passed it the full path to the block device. Try passing it the LV name instead.