大网数据广告活动
服务器运维问答

Cannot extend logical volume with ansible lvol module

· 52CE 我爱测

I cannot extend an LVM logical volume with ansible lvol module This is an excerpt from my playbook: - name: Create lv (lvcreate) become: true lvol: vg: "{{item.vg_name}} " lv: "{{item.lv_name}} " force: yes size: "{{ item.size | …

问题原文

原帖链接 · Imre · CC BY-SA 4.0

I cannot extend an LVM logical volume with ansible lvol module This is an excerpt from my playbook:

- name: Create lv (lvcreate)
  become: true
  lvol:
    vg: "{{item.vg_name}} "
    lv: "{{item.lv_name}} "
    force: yes
    size: "{{ item.size | default('+100%FREE') }}"
    resizefs: yes
  ignore_errors: yes
  loop: "{{ volumes }}"

And this is the volumes definition:

volumes:
  - vg_name: probavg
    pv_name: /dev/sdb,/dev/sdc
    lv_name: lv1
    mount_point: /fs1
    fstype: xfs

I get this error message:

TASK [Create lv (lvcreate)] ************************************************************************************************************************************************************** Friday 30 July 2021 14:26:26 +0200 (0:00:01.344) 0:00:01.577 *********** failed: [teszt29] (item={u'size': u'+100%FREE', u'mount_point': u'/fs1', u'vg_name': u'probavg', u'lv_name': u'lv1', u'pv_name': u'/dev/sdb,/dev/sdc', u'fstype': u'xfs'}) => {"ansible_loop_var": "item", "changed": false, "err": " Logical Volume "lv1" already exists in volume group "probavg"\n", "item": {"fstype": "xfs", "lv_name": "lv1", "mount_point": "/fs1", "pv_name": "/dev/sdb,/dev/sdc", "size": "+100%FREE", "vg_name": "probavg"}, "msg": "Creating logical volume 'lv1 ' failed", "rc": 5} ...ignoring

Of course it does exist; I want to extend it. (The vg has already been extended with /dev/sdc) Can anybody help?

My ansible version is 2.8.5

已采纳解答

原帖链接 · Gerald Schneider · CC BY-SA 4.0

You have spaces in the values of your lv and vg names:

    vg: "{{item.vg_name}} "
    lv: "{{item.lv_name}} "
                         ^- here

Remove them.

    vg: "{{item.vg_name}}"
    lv: "{{item.lv_name}}"

Ansible might think "oh, 'lv1 ' doesn't exist yet, I only see 'lv1'" and tries to create it.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-07-30)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。