问题原文
原帖链接 · Jared · CC BY-SA 4.0
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 error 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 doing wrong? Am I missing some other required argument perhaps?
I'm using Ansible 2.9.10. Thanks.
已采纳解答
原帖链接 · Michael Hampton · CC BY-SA 4.0
I think the Ansible lvol module wants just the logical volume name as lv, but you have passed it the full path to the block device. Try passing it the LV name instead.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
